Problem: I have the f开发者_Python百科ollowing 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.
It's possible. You need to do it using WCF Rest framework. You can set up following pathes
- /resource1/resource2/format/xml url that will return xml
- /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
精彩评论