简体   繁体   English

Java Web服务返回soap或json

[英]Java web service returning soap or json

I need to create web service in Java with method which will be returning some object in SOAP or JSON format. 我需要使用方法将以SOAP或JSON格式返回一些对象的Java创建Web服务。 The format depends on how the method is invoked. 格式取决于方法的调用方式。

For example: 例如:

http://localhost:8080/webservice/soap
http://localhost:8080/webservice/json

It must be the same method but with different format of returning object. 它必须是相同的方法,但返回对象的格式不同。

I know, that this effect is possible in .NET using WCF, but is it possible to do in Java? 我知道,使用WCF在.NET中可以实现这种效果,但是在Java中可以实现吗? If it is, how to do that? 如果是,该怎么做?

根据我找到/链接的上一个问题的答案,我想最好的选择是创建一组MyService类,其中包含服务代码的“内容”,并分别使用SOAP / XML和REST / JSON调用MyService API的胶水。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM