Riju Mahna
Riju Mahna

Reputation: 6926

Consume SOAP webservice in java, only WSDL in hand

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.

Upvotes: 2

Views: 44962

Answers (2)

oardic
oardic

Reputation: 212

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.

Upvotes: 2

sumitsu
sumitsu

Reputation: 1511

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.

Upvotes: 4

Related Questions