I'm writing a web service that has a lot of methods. They are all set up similar to the following:
[OperationContract]
[WebInvoke(
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "x/y/z")]
void someMethod(int x, int y, int z);
What I want to do is just set the default BodyStyle
/ RequestFormat
/ ResponseFormat
all in the web.config file. Now, I know I can do this:
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
But there doesn't seem to be an attribute for the RequestFormat. How can I set the default RequestFormat
to JSON?