views:

714

answers:

3

Hi, 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>
A: 

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.

Andrew Hare
No, that's out of the question ;)THere is for sure no typo in the function call...
David
+1  A: 

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..

David
The WebServiceHost will do all the fancy REST trickery needed for this. You will need to use WebServiceHost instaead of the regular ServiceHost (which expects messages in SOAP format)
marc_s
A: 

Hey! Is there any chance I coild take a look at your code David?

Im am also getting 404 or 405 no matter what I do it seems...

Ted