简体   繁体   中英

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. 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. 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? Thanks.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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