我正在编写一个有很多方法的网络服务。它们的设置都类似于以下内容:
[OperationContract]
[WebInvoke(
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "x/y/z")]
void someMethod(int x, int y, int z);
我要做的只是在 web.config 文件中设置默认值BodyStyle
// all RequestFormat
。ResponseFormat
现在,我知道我可以做到这一点:
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
但似乎没有 RequestFormat 的属性。如何将默认设置RequestFormat
为 JSON?