WCF RESTFul Service - 404 with endpoint not found with two services

I have two WCF services. Exchange1.svc and Exchange2.svc are both installed as RESTful JSON. Exchange1.svc works fine, but when I try to post to Exchange2.svc, I get an endpoint not found message.

What am I doing wrong?

My IExchange2 interface:

[ServiceContract]
public interface IExchange2
{
    [System.ServiceModel.OperationContract(Name = "InsertReading")]
    [WebInvoke(UriTemplate = "/InsertReading?memberID={memberID}", Method = "POST", ResponseFormat = WebMessageFormat.Json)]
    void InsertReading(string memberID);
}

      

The URL I'm trying to hit is: http: // localhost: 49701 / Exchange2.svc / DiaInsertReading? MemberID = 6519548

My config:

<system.serviceModel>
<behaviors>
    <endpointBehaviors>
        <behavior name="MyNamespace.Exchange1Behavior">
            <webHttp/>
        </behavior>
        <behavior name="MyNamespace.Exchange2Behavior">
            <webHttp/>
        </behavior>             
    </endpointBehaviors>
</behaviors>
<services>
    <service name="MyNamespace.Exchange1">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="MyNamespace.Exchange1Behavior" contract="MyNamespace.IExchange1" />
    </service>
    <service name="MyNamespace.Exchange2">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="MyNamespace.Exchange2Behavior" contract="MyNamespace.IExchange2" />
    </service></services></system.serviceModel>

      

+3


source to share


2 answers


I edited my post since the answer didn't help. Since you are hosting in IIS with svc, you do not need to specify the address in your binding as I said in my previous answer. The base address will be the location of your server. Example http://localhost:49701/Exchange2.svc

. If you click this address, you will be taken to the WCF service web page.

Since you are using the POST method, you can post data in the body of the request. If you have a fiddler installed, in composer you can set the way to publish and the address to http://localhost:49701/Exchange2.svc/InsertReading

if this is your address for your service. In the body of the request body, you set { memberID:"123" }

change 123 to whatever value you want to send to your service.



Or you can send data to: http://localhost:49701/Exchange2.svc/InsertReading?memberID=123

If you execute your request, it should return a 200 OK response.

+2


source


In your web.config file, specify the endpoint

<service name="MyNamespace.Exchange2">
<endpoint address="Exchange2" binding="webHttpBinding" behaviorConfiguration="MyNamespace.Exchange2Behavior" contract="MyNamespace.IExchange2" />

      



Then add this endpoint to your url as:

http://localhost:49071/Exchange2/DiaInsertReading?memberID=6519548

      

+1


source







All Articles