c# - WCF Json Service giving 404 error message -


background

i have wcf xml web service , need convert use json instead. hosted inside windows service (if matters @ all).

problem

i keep getting 404 status response.

interface:

[operationcontract] [webinvoke(bodystyle = webmessagebodystyle.wrapped, method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json, uritemplate = "/search")] searchresponse search(requestinfo requestinfo); 

console app:

using (var client = new webclient()) {     client.headers["content-type"] = "application/json";      var request = new requestinfo     {         //etc     };      using (var upstream = new memorystream())     {         var serializer = new datacontractjsonserializer(typeof(requestinfo));         serializer.writeobject(upstream, request);          byte[] responsebytes = client.uploaddata("http://localhost:8000/theservice.svc/search", "post", upstream.toarray());          using (var downstream = new memorystream(responsebytes))         {             var deserializer = new datacontractjsonserializer(typeof(response));             var result = deserializer.readobject(downstream) response;             return result.searchresult.queryid;         }     } } 

other

i have tried using fiddler 2.0 , directly passing in json request so:

post http://localhost:8000/theservice.svc/search http/1.1 user-agent: fiddler content-length: 209 content-type: application/json; charset=utf-8 expect: 100-continue host: localhost:8000  {my json here} 

however, confirms 404. missing here?

update:

just note, can browse http://localhost:8000/theservice.svc , works fine. displays standard web service page created wcf.

as turns out, in web.config causing problem (<system.servicemodel> section). decided remove in section , start bare bones config , build there... works.. did not take time try each , every option had before, don't know option causing problem. if gets same problem, advise starting basic config , building there.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -