0
votes

Problem: I have the following requirement while developing in WCF 4: Data format to return should be requested in uri template at the end BEFORE any possible query string. Example: /resource1/resoursce2.xml This url should result in data returned in xml format. If ".xml" is omitted from the url (/resource1/resoursce2) then data should be returned in Json format. Futhermore, I need to do it with one operation contract (one uri template). Question: does WCF 4 have any support for this? Thank you.

1

1 Answers

0
votes

It's possible. You need to do it using WCF Rest framework. You can set up following pathes

  1. /resource1/resource2/format/xml url that will return xml
  2. /resource1/resource2/format/json url that will return json

My advice is to use route table for this

See this link how to implement it http://msdn.microsoft.com/en-us/library/cc668201.aspx