开发者

JSON and XML output formats to Webservices

开发者 https://www.devze.com 2023-03-20 22:48 出处:网络
One requirement of a brand new webservice feature is to have multiple output types (JSON and XML). Would it be better in the long-term to enable webser开发者_JS百科vice clients to request an output fo

One requirement of a brand new webservice feature is to have multiple output types (JSON and XML). Would it be better in the long-term to enable webser开发者_JS百科vice clients to request an output format by including an attribute in the SOAP request or would it be better to have a particular URL path to XML or JSON output format?


I view the format of the response as a "modifier" of the request, hence including it as part of the request feels right to me. If this was a REST service then the requester could specify a particular mime-type such as application/json and this seems to be common practice.

My experience is that "there is no such number as two", in other words, we should count zero, one, many. If we can have XML and JSON, then why not something else? If you 20 different XML services, and then provide 20 more JSON services maybe you can cope. But then another 20 and another.

Another argument in the Java REST world with JAX/RS and JAX/B the same service implementation can produce either format with little or not extra coding, it's much less work to use a single URL.

I don't what happens in the WS-* world. Could be that your web service framework will steer you in a particular direction.

0

精彩评论

暂无评论...
验证码 换一张
取 消