David
David

Reputation: 2563

WCF Service with webHttpBinding; 404 error

does a service, which is configured like in the box below, throwing a 404 when there is a mismatch in the parameter? In this case the parameter is a complex type and every call to the SearchJson method returns a 404... ( is it even allowed with the WebInvoke option and WITHOUT the UriTemplate? )

The service is up and running ( i can call the Testpage with the "Generate your client ..?wsdl"-stuff )

The service method is configured as:

    [OperationContract]
    [FaultContract(typeof(Exception))]
    [WebInvoke(ResponseFormat = WebMessageFormat.Json, 
            BodyStyle = WebMessageBodyStyle.WrappedRequest, 
            RequestFormat = WebMessageFormat.Json)]
    SearchResponse SearchJson(SearchRequest req);

Any ideas how to solve this?

btw. this is what i use for testing... no matter what parameter i change, a 404 is returned... i can only trigger a different behavior when i change the WebInvoke to WebGet and use a simple-type as parameter ( like string )... then i get a 405

WebRequest req = HttpWebRequest.Create("http://localhost:8800/SearchService/SearchJson");
req.Method = "POST";
req.ContentType = "application/json";
req.ContentLength = 354;
WebResponse resp = req.GetResponse();

Here is the the config:

  <service name="SearchEngine.SearchService" behaviorConfiguration="HTTPGetBehavior">
    <endpoint address="SearchEngine.SearchService" 
              behaviorConfiguration="ajaxBehavior" 
              binding="webHttpBinding" 
               contract="SearchEngine.ISearchInterface" />
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8800/SearchService" />
      </baseAddresses>
    </host>
  </service>

Upvotes: 1

Views: 4478

Answers (2)

David
David

Reputation: 2563

ok, i got it...

i don't know why, but if i use "WebServiceHost" instead of "ServiceHost" to employ the WCF-Service i can at least get the requests through.. my SearchRequest object is empty, but i hopefully will figure out why..

Upvotes: 1

Andrew Hare
Andrew Hare

Reputation: 351516

HTTP 404 means that the requested resource was not found. This is most likely being returned from IIS and I would double check the address of the service you are invoking.

Since the service itself it up and running I would imagine that there is a typo in the address you are using in your client.

Upvotes: 0

Related Questions