Consume SOAP webservice in java, only WSDL in hand

南楼画角 提交于 2019-12-24 02:57:30

问题


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.


回答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.




回答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.



来源:https://stackoverflow.com/questions/25920799/consume-soap-webservice-in-java-only-wsdl-in-hand

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!