10

I've built a WCF service that's exposed both through SOAP and RESTfully. All SOAP actions work as advertised. GETS/PUTS do as well, but when I try to do a POST to an action in my service, I get the following error returned:

"Endpoint not found"

IPersonEditServiceContract snippet:

[OperationContract]
[WebInvoke(Method="POST", 
   UriTemplate="/persons", 
   RequestFormat=WebMessageFormat.Xml, 
   ResponseFormat=WebMessageFormat.Xml)]
SavePersonResponse SavePerson(SavePersonRequest request);


[OperationContract]
WebGet(UriTemplate = "/persons/{personId}",
   ResponseFormat = WebMessageFormat.Xml,
   BodyStyle = WebMessageBodyStyle.Bare,
   RequestFormat = WebMessageFormat.Xml)]
Person GetClaimantById(string personId);

Service is configured this way:

<behaviors>
   <endpointBehaviors>
    <behavior name="restBehavior">
     <webHttp />
    </behavior>
   </endpointBehaviors>
</behaviors>
<services>
  <service>
    <endpoint address="" binding="basicHttpBinding" 
        name="DefaultEndpoint"
        bindingNamespace="http://mycompany.com/ServiceContracts"
        contract="IPersonEditServiceContract" />
     <endpoint 
         address="rest" binding="webHttpBinding"
         name="RESTEndpoint" 
         bindingNamespace="http://mycompany.com/ServiceContracts"
         contract="IPersonEditServiceContract" 
         behaviorConfiguration="restBehavior"/>
  </service>
</services>

Since I can do other RESTful operations against the same endpoint, I'm not entirely sure why it gives me that semi-helpful error.

Ideas?

joshua.ewer
  • 3,944
  • 3
  • 25
  • 35

1 Answers1

5

I would think WCF is giving the error because it really can't find the endpoint. Are you hitting it using POST to the right URL under /rest? Try Fiddler to create POST call.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • 2
    it magically went away; have no idea what the problem was. but, since you're the only one that answered, thanks! BTW, I use fiddler for simple tests, really like soapUI for building some mocks and test projects from a similar angle. – joshua.ewer Mar 25 '09 at 17:12
  • 34
    Please don't mark the answer unless the question has actually been answered. Its confusing for users who show up later with the same problem. – reach4thelasers Jul 31 '11 at 17:46
  • I'm having the same issue. My HttpGet works, however I created a similar method that I want to use POST with, and I get the endpoint not found error. Did you figure out what the true issue was? – mservidio Dec 27 '11 at 18:07
  • I am having the same issue, but by saying 'it went away by itself' that isn't helpful. Did you find the issue? With mine the service still works sometimes with a post, but it doesn't always seem to work. Can never browse to it though it just says endpoint not found. – peter Jan 11 '12 at 01:17
  • 1
    can we remove this post or unmark the answer somehow, in case a useful response comes around? – Chris Dec 10 '12 at 19:09
  • @Chris I can't delete this answer since it's been accepted. Maybe joshua.ewer can post an answer himself and accept it. – Eugene Yokota Dec 10 '12 at 19:55
  • `it magically went away` because requests generated from browsers are `GET` not `POST`, when simulated actual `POST` using fiddler, webmethod is found & thus no error(HTTP 404, 405). – Pranav Singh Apr 29 '14 at 13:40