简体   繁体   English

命令行Java客户端以使用SOAP-WSLD

[英]a command line java client to consume SOAP - WSLD

I have to write a command line java program to consume a SOAP (wsdl) web service. 我必须编写一个命令行Java程序来使用SOAP(wsdl)Web服务。 I do not have a luxury to installed any java libraries I want. 我没有奢侈地安装我想要的任何Java库。 So I am going to have to write most of it myself. 因此,我将不得不自己编写大部分内容。 What can use? 有什么用? or where can I start? 或从哪里开始? Thank you in Advance. 先感谢您。

Even if you can't install some additional libs, you have to take a look at wsimport tool, to generate web-service client stubs. 即使您无法安装一些其他的库,也必须查看wsimport工具,以生成Web服务客户端存根。 This tool is provided with JDK, so, I suppose, it could be available for you. 该工具随JDK一起提供,所以,我想,它可能对您可用。

You can find a number of examples, how to ise it on internet, here is one of them , take a look at the chapter 2, called "Java Web Service Client via wsimport tool" 您可以找到许多示例,如何在Internet上进行加密, 这是其中之一,请看第二章,名为“通过wsimport工具的Java Web Service客户端”。

The executable code for the client should be generated from WSDL file of the web service: 客户端的可执行代码应从Web服务的WSDL文件生成:

wsimport http://localhost:8080/someservice/YourService?WSDL

Then you'll get the client classes to access to the web service. 然后,您将获得客户端类以访问Web服务。 Then you need to write a simple client. 然后,您需要编写一个简单的客户端。

public class YourServiceClient {
   @WebServiceRef(wsdlLocation="http://localhost:8080/someservice/YourService?WSDL")
   private static YourService yourService;

   public void doSomething() {
      // get service port and perform some logic      
   }

   public static void main() {
      new YourServiceClient().doSomething();
   }
}

To provide the resources for work with the standalone client (not deployed on the application server) you can use: 要提供与独立客户端(未部署在应用程序服务器上)一起使用的资源,可以使用:

appclient -client yourserviceclient.jar

See Also: 也可以看看:

GlassFish Server Tools GlassFish服务器工具

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

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