Consume SOAP webservice in java, only WSDL in hand

43,350

Solution 1

WSDL is just the conract for the web service. You need to generate client code using it, later you can implement your code to call the web service. Like @maerics pointed out, you should use wsdl2java to generate your client code for AXIS2 and use your client to consume the web service.

You can check this link for an example of client stub generation for AXIS2.

Solution 2

There are a number of tools capable of doing this included in various frameworks and app servers (CXF, JBoss/Wildfly, etc.), but the JDK itself includes a tool called wsimport which can consume a WSDL file and produce the JAX-WS stubs you need to remotely-invoke the service endpoints via a Java client.

Here's one quick description: http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/; here is the Oracle documentation for the tool in JDK 7: http://docs.oracle.com/javase/7/docs/technotes/tools/share/wsimport.html.

Share:
43,350
Riju Mahna
Author by

Riju Mahna

Working as a Technical Lead in LnT Infotech. Learning Java for almost 9 years now....and will continue to do so...as there is no end in sight, yet !!!

Updated on July 09, 2022

Comments

  • Riju Mahna
    Riju Mahna almost 2 years

    I need to consume a web service in java/jsp code. Only the WSDL is available for me to start.

    I understand I need to convert the WSDL into java client JAR file using AXIS2 / CXF but I cannot build the whole application on this.

    Can someone provide a simple example or basic steps for me to start on this?

    I am not able to join the dots here. WSDL, java client JAR, AXIS2.... All online tutorials point on 'creating' a web service.