简体   繁体   English

使用Java中的SOAP Web服务,仅使用WSDL

[英]Consume SOAP webservice in java, only WSDL in hand

I need to consume a web service in java/jsp code. 我需要使用java / jsp代码使用Web服务。 Only the WSDL is available for me to start. 我只可以使用WSDL。

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. 我知道我需要使用AXIS2 / CXF将WSDL转换为Java客户端JAR文件,但是无法在此基础上构建整个应用程序。

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. WSDL,Java客户端JAR,AXIS2。...所有在线教程都指向“创建” Web服务。

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. 各种框架和应用程序服务器(CXF,JBoss / Wildfly等)中包含许多能够执行此操作的工具,但是JDK本身包含一个名为wsimport的工具,该工具可以使用WSDL文件并生成JAX-WS存根。您需要通过Java客户端远程调用服务端点。

Here's one quick description: http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/ ; 这是一个简短的说明: 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 . 这是JDK 7中该工具的Oracle文档: http : //docs.oracle.com/javase/7/docs/technotes/tools/share/wsimport.html

WSDL is just the conract for the web service. WSDL只是Web服务的障碍。 You need to generate client code using it, later you can implement your code to call the web service. 您需要使用它生成客户端代码,稍后您可以实现代码以调用Web服务。 Like @maerics pointed out, you should use wsdl2java to generate your client code for AXIS2 and use your client to consume the web service. 就像@maerics指出的那样,您应该使用wsdl2java来为AXIS2生成客户端代码,并使用客户端来使用Web服务。

You can check this link for an example of client stub generation for AXIS2. 您可以检查此链接以获取AXIS2客户端存根生成的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM