[英]Simple (standalone) Java SOAP web service client from WSDL using Maven
I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. 我希望生成一个简单的独立Java客户端,它将在给定wsdl的情况下调用SOAP Web服务。 When I say simple and standalone I mean that once I'm done I want to be able to do something like 当我说简单和独立时,我的意思是,一旦我完成,我希望能够做类似的事情
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. 我最近和Maven在其他一些项目上玩得很开心,我想继续这样做,所以我的目标就是在这里使用它。 I don't want the tool to generate anything expect the classes that allow me to do the above. 我不希望该工具生成任何期望允许我执行上述操作的类。
Anyone done this recently and can recommend a ws library and Maven plugin? 最近有人这么做了,可以推荐一个ws库和Maven插件吗? Thanks. 谢谢。
Have a look at CXF and its Maven plug in . 看看CXF及其Maven 插件 。 CXF would generate code similar to yours (of course web services could fail and you should add exception handling). CXF会生成与您类似的代码(当然,Web服务可能会失败,您应该添加异常处理)。 Have in mind though that SOAP web services is a complicated topic and simplicity in the generated code may not be always desirable. 请记住,SOAP Web服务是一个复杂的主题,生成的代码中的简单性可能并不总是令人满意。 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适用于简单/默认客户端和更复杂的客户端。
I would recommend SOAP UI for what you need to do. 我建议您使用SOAP UI来完成您需要做的事情。 You do not need to write any code - you can call the web service from the soap UI client. 您不需要编写任何代码 - 您可以从soap UI客户端调用Web服务。
If you need to automate making soap calls you can use the maven plugin as part of your build/deploy process. 如果您需要自动化肥皂调用,您可以使用maven插件作为构建/部署过程的一部分。 More info about the maven plugin here: http://www.soapui.org/Test-Automation/maven-2x.html 有关maven插件的更多信息,请访问: http : //www.soapui.org/Test-Automation/maven-2x.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.