Can a RESTFul service's request and response be serverd dynamically based on the "Accept" property of the client
i.e. If the client can "Accept" application/xml then my service should automatically understand that the request and response should be of type xml and process the request accordingly.
Hence, I would not create another service for client who want request/response in json and the same service should be able to handle it.
Yes, in fact WCF can be configured to do this for you: WCF Web HTTP Formatting
When enabled, automatic formatting chooses the best format in which to return the response. It determines the best format by checking the following, in order:
- The media types in the request message’s Accept header.
- The content-type of the request message.
- The default format setting in the operation.
- The default format setting in the WebHttpBehavior.
Also, see the documentation for <webHttpEndpoint>
, specifically the automaticFormatSelectionEnabled
attribute.