开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜