.net 从WCF返回JSON

.net 从WCF返回JSON,.net,wcf,json,.net-3.5,basichttpbinding,.net,Wcf,Json,.net 3.5,Basichttpbinding,我的WCF服务在.NETFramework3.5中,PHP将使用此WCF服务,因此我使用了basicHttpBinding(请建议是否有其他更好的服务) 我在函数中使用下面的代码/属性返回JSON [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] 但是它没有返回JSON(它的返回对象)。 请帮帮我 注意:我找到了一个解决方案,

我的WCF服务在.NETFramework3.5中,PHP将使用此WCF服务,因此我使用了basicHttpBinding(请建议是否有其他更好的服务)

我在函数中使用下面的代码/属性返回JSON

[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
但是它没有返回JSON(它的返回对象)。 请帮帮我

注意:我找到了一个解决方案,但它适用于.NETFramework 4.0。但我需要3.5的解决方案。
谢谢

您是否已将aspnetcompatibility属性添加到服务实现类中

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ServiceImpl{
}

另外,更改您可能需要将绑定更改为
webHttpBinding
,因为
basicHttpBinding
是用于SOAP而不是Json的,请不要建议我手动创建Json。。这是我的最后一个选项。@Jaimal:yes,但没有JSON结果您还需要在端点的行为中添加行为添加后,我收到此错误:“”处的端点没有与None MessageVersion的绑定System.ServiceModel.Description.WebHttpBehavior'仅适用于WebHttpBinding或类似绑定。您需要将绑定更改为WebHttpBindings是的,可以使用PHP访问它。