I have two WCF services Exchange1.svc and Exchange2.svc both setup to be RESTful JSON consummables. 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 is:
[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 is:
<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>
I have edited my post since the answer did not help. Since you are hosting in IIS with svc you don’t need to set an address in your binding as I was saying in my previous answer. The baseaddress will be the location of you server. Ex:
http://localhost:49701/Exchange2.svc. If you hit this address you should get to a WCF Service webpage.Since you are using POST method you can send the data in the request body. If you have fiddler installed, in the composer you can set the method to post and address to
http://localhost:49701/Exchange2.svc/InsertReadingif this is your address to 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 the data in the address like:
http://localhost:49701/Exchange2.svc/InsertReading?memberID=123If you now execute your request it should return a response 200 OK.