i create web application accepts single post method update db, using restful structure.
my problem when post json object url (using fiddler) receive error 404.
the method trying call exposed using attributes below:
[webinvoke(method="post", uritemplate="projectors", requestformat=webmessageformat.json,bodystyle=webmessagebodystyle.wrapped )] [operationcontract] void recordbreakdown(string sn, int modelcode); the web config file has service binds exposed method, below abstraction:
<system.servicemodel> <bindings/> <services> <service name="viservicetoolservicelibrary.projectorservice" behaviorconfiguration="restbehaviour"> <endpoint address="" binding="webhttpbinding" contract="viservicetoolservicelibrary.iprojectorservice" behaviorconfiguration="restendpointbehaviour" /> <host> <baseaddresses> <add baseaddress="http://localhost:8080/projectorservice/" /> </baseaddresses> </host> </service> </services> <behaviors> <servicebehaviors> <behavior name="restbehaviour"> <servicemetadata httpgetenabled="true"/> <servicedebug includeexceptiondetailinfaults="true"/> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="restendpointbehaviour"> <webhttp/> </behavior> </endpointbehaviors> </behaviors> if run web app in vs or iis can see svc file okay:
http://localhost:5970/service.svc http://localhost/vi/service.svc but when post request receive error 404 message
post http://localhost/vi/projectors http/1.1 user-agent: fiddler host: localhost content-length: 27 {sn:"23434", modelcode:34 } thanks
the error 404 happening 2 reasons.
1st: base address incorrect. using naming convention earlier version had been superceeded
2nd: url in post method incorrect. should have included name of service file in url, localhost/vi/service.svc/projectors
i found folloiwng article helpful http://msdn.microsoft.com/en-us/library/dd203052.aspx solve problem
Comments
Post a Comment