我正在构建一个应该输出JSON的WCF REST Web服务,但我正在获取XML。WCF JSON返回XML数据!
我使用ResponseFormat = WebMessageFormat.Json
请帮我搜索无处不在,我无法找到解决方案。
注:我甚至尝试从here
配置文件
<services>
<service name="TestService">
<endpoint address=""
behaviorConfiguration="TestServiceAspNetAjaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webBinding"
contract="TestService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
我在web.config文件中尝试了并且没有工作! –
Hardcode
我可以确认您使用的是WebServiceHost还是WebHttpBinding? –
我正在使用WebHttpBinding。 <服务名称= “TestService的”> <端点地址= “” behaviorConfiguration = “TestServiceAspNetAjaxBehavior” 结合= “的WebHttpBinding” bindingConfiguration = “webBinding” 合同= “TestService的”/> <的WebHttpBinding> <绑定名称= “webBinding”> <安全模式= “运输”> 的WebHttpBinding> –
Hardcode