POX return data from WCF Data Services
I am using WCF Data Services (netfx4) to provide data sourced from SQL via EF, the standard OData mechanism is fine and JSON works as well but I need a third option for generic POX (plain old xml). I have yet to come across a simple strategy or switch that allows me to control this but I am sure one must exist or a workaround method might be available. Any ideas?
Ideally I would lik开发者_C百科e to be able to use something like the JSONP option wherein I append 'format=JSON' to the URL, in this case 'format=pox' or 'POX=true' or something of that nature.
This is doable, but rather hard. Using your own custom host you can do the $format=jsonp thing. The same way you can do any other format. See this blog here about that: http://blogs.msdn.com/b/pablo/archive/2009/02/25/adding-support-for-jsonp-and-url-controlled-format-to-ado-net-data-services.aspx
To make it POX, the only way right now is ask the service to return ATOM results and parse that, and transform it into POX. You can use XLinq/XSLT/your favorite XML library for this job. Obviously this is not a very performant solution, but it should work.
精彩评论