Question

I'm working on my first WCF service and am getting an error when trying to launch the service inside of visual studio. So, it will be running under Cassini.

The error is:

Error: Cannot obtain Metadata from http://localhost:1393/BEService.svc

Here is my configuration

         <behaviors>
        <serviceBehaviors>
            <behavior name="metadataBehavior">
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="metadataBehavior" name="DataServices.BEService">
            <endpoint address="" binding="basicHttpBinding" contract="DataServices.IBEService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:1393" />
                </baseAddresses>
            </host>
        </service>
    </services>

Here is my interface that defines the service contract:

 [ServiceContract]
    public interface IBEService
    {
        [OperationContract]
        string Get271EDI(string EDI, DDKSLib.Enums.EDIRequestor requestor);
    }

Here is the class that implements it :

public class BEService : IBEService
    {

        public string Get271EDI(string EDI, Enums.EDIRequestor requestor)
        {
            return "this is a test";
        }
    }

What am I missing?

Was it helpful?

Solution 2

When changing the WCF configuration, the editor moved all of the configuration to an app.config file. However, a lot of articles i read referenced configuration being in the web.config instead. So, I moved them to the web.config and deleted the app.config. Everything started working. Then, I ran into this question which answered my question about when to use web.config vs app.config..

OTHER TIPS

Maybe I am mistaking, but I think you need to use a base address for service when endpoint is empty or relative and you don't use IIS, isn't it?

<host>
   <baseAddresses>
       <add baseAddress="http://localhost:1393/MyService"/>
   </baseAddresses>
</host>

Here is an article about WCF Addressing

EDIT: You should check more into detail the error that you get. I think there are some inner details which may help you solving the case. It could be that something in your implementation is not conforming to the WCF rules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top