developers.de
daenet's .NET Community

ServiceHost Error

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

Problem Description

Operation "xxx" of contract 'yyyy' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra body parameters or set the BodyStyle property on the WebGetAttribute/WebInvokeAttribute to Wrapped.

 

Solution

This error occurs while starting of the web service host:

1)  explicitly in the custom host:
    WebServiceHost xmlHost = new WebServiceHost(. . .) or

2)  implicitly by using of SVC-file in IIS host:

     <%@ ServiceHost Language="C#" Debug="true" Service=". . ."
                Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

The problem is caused by using of the usual service contract, which is styled for standard SOAP-Host (ServiceHost) and not as expected for the WebServiceHost.

This is an example of the contract which cause this error:

[OperationContract]
Airport[] GetCoordinates(string area, int numOfRecords);

To fix it, use REST-specific styling of the operation as shown below, or use ServiceHost instead of WebServiceHost.

[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
Airport[] GetCoordinates(string area, int numOfRecords);

or

<%@ ServiceHost Language="C#" Debug="true" Service=". . ." %>


Posted Dec 26 2008, 11:31 PM by Damir Dobric
Filed under:

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH