SerializationException with WCF services
I have a WCF service set up as following:
[ServiceContract]
public interface IObjectPresentationService
{
[OperationContract(Name="GetFooter")]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json)]
string GetFooter();
}
When I use Add Service Reference on the client side, the following code is generated:
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IObjectPresentationService/GetFooter", ReplyAction="http://tempuri.org/IObjectPresentationService/GetFooterResponse")]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat=WebMessageFormat.Json)]
string GetFooter();
However, when I try to execute GetFooter(), I get the following exception:
SerializationException was unhandled OperationFormatter encountered an invalid Message body. Expected to find an attribute with name 'type' and value 'object'. Found value 'string'.
Using Fiddler I can see that the service indeed returns a plain string, complete with quotemarks at the begining and end (wh开发者_StackOverflow社区ich should make it valid json?).
Could this be an configuration issue?
精彩评论