Tuesday, February 21, 2012 2:13 PM
I have a service (WCF 4.0, selfhosted on a Windows 2003 server) with a soap (basicHttp) and rest (webHttp) binding. It's working fine, but I have a problem with the help page where it just say that the format is unknown and "Cannot infer schema. The Request body is wrapped" (says the same with the response body) when I access it.
I will include some configurations, let me know if you need more:
<endpointbehaviors> <behavior name="restBehavior"> <webhttp automaticFormatSelectionEnabled="true" defaultBodyStyle="Wrapped" helpEnabled="true"></webhttp> </behavior> </endpointbehaviors> <webhttpbinding> <binding name="webHttp"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Basic"></transport> </security> </binding> </webhttpbinding>
Even a simple operation like:
[OperationContract] [FaultContract(typeof(MyException))] void DeleteGame(UInt64 gameId);
will give this result, so I am guessing it is not because the datacontracts are to complicated?
Any idea as to what is wrong?
Wednesday, February 22, 2012 3:13 AMModerator
Hello, this seems to be a limitation of help page. It requires the request body not to be wrapped. Do you have to require the request body to be wrapped? In most cases this is not desired. For example, with void DeleteGame(UInt64 gameId); if the request body must be wrapped, the client has to send an xml document instead of a simple uint64 value.
Also if you truely want to write a RESTful service, please do not use the same contract for both SOAP and REST. SOAP is operation centric, while REST is resource centric. You need to treat the game as a resource. ASP.NET Web API is the new way to build RESTful service on .NET: http://www.asp.net/web-api.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact email@example.com. But please do not ask technical questions in the email.
- Marked As Answer by dblank Wednesday, February 22, 2012 7:12 AM
Wednesday, February 22, 2012 7:16 AM
Hi Yi-Lun Luo
I have two operations that takes more than 1 parameter, so I had to use a wrapped bodystyle. I rewrote them to take a single parameter and changed the bodystyle to "Bare", and now the help-page is working fine.
I will have a look at ASP.NET Web API.
Thank you for your help :-)
- Edited by dblank Wednesday, February 22, 2012 7:23 AM