我有一个REST服务,有几个客户端在使用它。据我所知,该服务只在进行POST/PUT时接受JSON(并且在所有调用中仅返回JSON)。问题是,在服务的/help页面上,它显示了JSON和XML的示例。是否有一种方法可以删除所有额外的XML垃圾,以免混淆用户(因为服务仅接受JSON),并仅在/help页面上显示JSON示例?以下是我的Web.config:
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" />
</webHttpEndpoint>
</standardEndpoints>
我的每个GetGets/WebInvokes都定义了JSON格式,例如:
[WebInvoke(UriTemplate = "/sample", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
那么,我能做些什么让服务只接受JSON,并清除干扰/help页面的自动生成XML垃圾吗?