Reputation: 15092
I have a project coming up that will require me to call a SOAP web service from my java application. I'm wondering what toolsets I should look at to do this? All advice appreciated.
I've looked at jax-ws and Axis2 but these appear to be mostly for creators of web services instead of consumers and I only wish to consume.
Thanks!
Upvotes: 3
Views: 1436
Reputation: 340933
First of all you need wsdl. Some service providers might distribute Java client classes, but WSDL is the safest approach.
Once you have it, run tool like wsdl2java
for apache-cxf or analogous in apache-axis against it. It will create a bunch of Java classes (you only need the client side). These tools are also capable of generating server-side code, hence the impression you had that they aim service developers.
This is all you need - the client classes will handle XML marshalling/unmarshalling and HTTP connectivity for you. Just use appropriate stub implementing WS endpoint interface.
You can also use WebServiceTemplate
from spring-ws portfolio.
Upvotes: 3
Reputation: 434
If you are using eclipse you may want to view this solution:
What is the easiest way to generate a Java client from an RPC encoded WSDL
Upvotes: 1
Reputation: 7243
If you want a rapid-functional client you can use JAX-WS tools to generate the code that you need to consume a Web Service. But sometimes this approach can generate non-portable code (like with Websphere tools) but you the productivity gain maybe worth it.
Spring Framework also offers tools to build and consume web services, but it requires some extra effort to develop the client and it may require some manual mapping of the input/output messages with technologies like JAXB or Castor. You can also directly read XML with Spring, it's a flexible framework that assures you portability between containers but it requires extra effort and time.
Every approach has it pros and cons. It's up to you to decide.
Upvotes: 0
Reputation: 12469
Jax-WS comes with a tool called wsimport
which you run against the .wsdl of the SOAP service. It generates a whole bunch of classes your client can use to interact with the service. After that it's just plain Java coding.
Upvotes: 2