简体   繁体   中英

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.

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 .

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.

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