Return JSON from WCF
my WCF service is in .net framework 3.5,t开发者_如何学Chis WCF service will be used by PHP, so i have used basicHttpBinding (please suggest if any other better one).
i am using below code/attribut on function to return JSON.
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
but its not returning JSON (its returning object). Please help me.
NOTE: i found a solution but its for .NET Framework 4.0. but i need solution for 3.5. WCF 4.0 : WebMessageFormat.Json not working with WCF REST Template Thanks
Have you added the AspNetCompatability attribute to your service implementation class?
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ServiceImpl{
}
Also, change you might need to change your binding to webHttpBinding
as basicHttpBinding
is for SOAP rather than Json
精彩评论