返回soap或json的Java web服务。

时间:2021-02-22 15:22:27

I need to create web service in Java with method which will be returning some object in SOAP or JSON format. The format depends on how the method is invoked.

我需要用Java创建web服务,方法是返回SOAP或JSON格式的对象。格式取决于如何调用方法。

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? If it is, how to do that?

我知道,这种效果在。net中使用WCF是可能的,但是在Java中有可能实现吗?如果是的话,怎么做呢?

1 个解决方案

#1


0  

Based on the answers to the previous question I found / linked, I'd say that your best bet would be to create a set of MyService classes that contain the "meat" of your service code, and separate SOAP/XML and REST/JSON glue that calls your MyService APIs.

根据我找到/链接的前一个问题的答案,我认为您最好的选择是创建一组MyService类,其中包含服务代码的“肉”,以及分别调用MyService api的SOAP/XML和REST/JSON胶水。

#1


0  

Based on the answers to the previous question I found / linked, I'd say that your best bet would be to create a set of MyService classes that contain the "meat" of your service code, and separate SOAP/XML and REST/JSON glue that calls your MyService APIs.

根据我找到/链接的前一个问题的答案,我认为您最好的选择是创建一组MyService类,其中包含服务代码的“肉”,以及分别调用MyService api的SOAP/XML和REST/JSON胶水。