Monday, April 22, 2013

WebInvoke(BodyStyle=WebMessageBodyStyle.Bare, ResponseFormat=WebMessageFormat.Json)



1. http://blog.clauskonrad.net/2010/11/how-to-expose-json-endpoint-from-wcf.html


[OperationContract]
        [WebInvoke(BodyStyle=WebMessageBodyStyle.Bare, ResponseFormat=WebMessageFormat.Json)]
        Employee[] GetAll_POST();


2. http://stackoverflow.com/questions/9235743/return-json-array-with-name-from-wcf-with-service


The easy way is change BodyStyle = WebMessageBodyStyle.Bare to BodyStyle = WebMessageBodyStyle.Wrapped.
The Wrapped enum member does it for you.

No comments:

Post a Comment