Last post Dec 04, 2012 03:07 AM by Haixia Xie - MSFT
Dec 01, 2012 12:21 AM|dotnetterAMG123|LINK
Hello - If I send a JSON request to a WCF REST method then doesn't WCF return JSON content based on the "application/json" Content-Type set in the request header? Or is this just the default return type for WCF REST methods?
I'd like my WCF REST method to return XML content if the client submits a request with a Content-Type of XML. How easy is this to do? It seems like WCF should be smart enough to handle this out of the box but based on some experimenting and googling it appears
that some additional configuration may required to get a REST WCF service to support this.
So what's the easiest way to get my WCF REST service to support XML communication and why doesn't WCF REST support this inference by default (unless I'm missing something)?
Dec 04, 2012 03:07 AM|Haixia Xie - MSFT|LINK
We can specify the format of the response message at WebGetAttribute and WebInvokeAttribute, if you do not set the format explicitly in this way, we can also set a default messege format at WebHttpBehavior.
In addition to
this explicitly setting, wcf also provide an automatic format selection mechanism, when automatic format selection(AutomaticFormatSelectionEnabled ) is enabled, the WCF infrastructure parses the
Accept header of the request message and determines the most appropriate response format. This mechanism is disabled by default.