Ste*_*her 5 .net c# rest wcf json
我有一个REST服务,有几个客户端使用它,据我所知,只有在执行POST/PUT时才接受JSON(并且只在所有调用中返回JSON).问题是在服务/帮助页面上,它显示了JSON和XML的示例.有没有办法删除所有额外的XML垃圾,以免混淆用户(因为,再次,服务只接受JSON),只在/帮助页面上显示JSON示例?这是我的Web.config:
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" />
</webHttpEndpoint>
</standardEndpoints>
Run Code Online (Sandbox Code Playgroud)
我的每个GetGets/WebInvokes都以JSON作为格式定义,例如:
[WebInvoke(UriTemplate = "/sample", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Run Code Online (Sandbox Code Playgroud)
那么,有没有什么我可以做让服务知道它是JSON 只和删除自动根XML垃圾塞满了我的/帮助页?
您可以通过将以下内容添加到 web.config 来禁用帮助页面:
<webServices>
<protocols>
<remove name="Documentation" />
</protocols>
</webServices>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1292 次 |
最近记录: |