使用Maven从WSDL获得的简单(独立)Java SOAP Web服务客户端

时间:2022-11-18 09:52:20

I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. When I say simple and standalone I mean that once I'm done I want to be able to do something like

我希望生成一个简单的独立Java客户端,它将在给定wsdl的情况下调用SOAP Web服务。当我说简单和独立时,我的意思是,一旦我完成,我希望能够做类似的事情

import my.generated.nonsense;

public static void main(String[] args) {
    Client client = new Client();
    client.getSomething();
}

I've had great time recently with Maven on some other projects and I want to keep that going, so would aim to use it here. I don't want the tool to generate anything expect the classes that allow me to do the above.

我最近和Maven在其他一些项目上度过了愉快的时光,我想继续这样做,所以我的目标是在这里使用它。我不希望该工具生成任何期望允许我执行上述操作的类。

Anyone done this recently and can recommend a ws library and Maven plugin? Thanks.

最近有人这么做了,可以推荐一个ws库和Maven插件吗?谢谢。

2 个解决方案

#1


9  

Have a look at CXF and its Maven plug in. CXF would generate code similar to yours (of course web services could fail and you should add exception handling). Have in mind though that SOAP web services is a complicated topic and simplicity in the generated code may not be always desirable. Generating a client with the default settings may not work for some clients. You would then need to tweak the configuration of the code generation and/or add code to handle it. CXF is good both for easy/default clients and more complicated ones.

看看CXF及其Maven插件.CXF会生成类似于你的代码(当然,Web服务可能会失败,你应该添加异常处理)。请记住,SOAP Web服务是一个复杂的主题,生成的代码中的简单性可能并不总是令人满意。使用默认设置生成客户端可能不适用于某些客户端。然后,您需要调整代码生成的配置和/或添加代码来处理它。 CXF对于简单/默认客户端和更复杂的客户端都很好。

#2


5  

I would recommend SOAP UI for what you need to do. You do not need to write any code - you can call the web service from the soap UI client.

我建议您使用SOAP UI来完成您需要做的事情。您不需要编写任何代码 - 您可以从soap UI客户端调用Web服务。

If you need to automate making soap calls you can use the maven plugin as part of your build/deploy process. More info about the maven plugin here: http://www.soapui.org/Test-Automation/maven-2x.html

如果您需要自动化肥皂调用,您可以使用maven插件作为构建/部署过程的一部分。有关maven插件的更多信息,请访问:http://www.soapui.org/Test-Automation/maven-2x.html

#1


9  

Have a look at CXF and its Maven plug in. CXF would generate code similar to yours (of course web services could fail and you should add exception handling). Have in mind though that SOAP web services is a complicated topic and simplicity in the generated code may not be always desirable. Generating a client with the default settings may not work for some clients. You would then need to tweak the configuration of the code generation and/or add code to handle it. CXF is good both for easy/default clients and more complicated ones.

看看CXF及其Maven插件.CXF会生成类似于你的代码(当然,Web服务可能会失败,你应该添加异常处理)。请记住,SOAP Web服务是一个复杂的主题,生成的代码中的简单性可能并不总是令人满意。使用默认设置生成客户端可能不适用于某些客户端。然后,您需要调整代码生成的配置和/或添加代码来处理它。 CXF对于简单/默认客户端和更复杂的客户端都很好。

#2


5  

I would recommend SOAP UI for what you need to do. You do not need to write any code - you can call the web service from the soap UI client.

我建议您使用SOAP UI来完成您需要做的事情。您不需要编写任何代码 - 您可以从soap UI客户端调用Web服务。

If you need to automate making soap calls you can use the maven plugin as part of your build/deploy process. More info about the maven plugin here: http://www.soapui.org/Test-Automation/maven-2x.html

如果您需要自动化肥皂调用,您可以使用maven插件作为构建/部署过程的一部分。有关maven插件的更多信息,请访问:http://www.soapui.org/Test-Automation/maven-2x.html