简体   繁体   English

如何在Java Eclipse中调用Web服务客户端

[英]How to call web service client in java eclipse

I am developing a android app which invoke cloud service. 我正在开发一个调用云服务的android应用。 I add the web reference client by calling wsdl file cloudservice.wsdl in the server site. 我通过在服务器站点中调用wsdl文件cloudservice.wsdl来添加Web参考客户端。 it will generate files called 它将生成名为

(i)CloudServiceLocator(java file) (i)CloudServiceLocator(java文件)

(ii)cloudservicesoap(interface) (ii)cloudservicesoap(接口)

(iii)CloudServiceSoapProxy(java file) (iii)CloudServiceSoapProxy(java文件)

(iv)CloudServiceSoapStub(java file) (iv)CloudServiceSoapStub(java文件)

(iV)CloudService(interface) (iV)CloudService(接口)

how can i call the methods inside CloudServiceSoapStub class into my application. 如何将CloudServiceSoapStub类中的方法调用到我的应用程序中。

Try following code after calling the wsdl file 调用wsdl文件后尝试以下代码

Note:The methods may be changed as per your wsdl service 注意:方法可能会根据您的wsdl服务进行更改

    CloudServiceSoapStub stub=null;
    CloudServiceLocator locator=new CloudServiceLocator();
    String endPointAddress = locator.getServiceSoapAddress();

    try {
        stub=(CloudServiceSoapStub) locator.getServiceSoap(new URL(endPointAddress));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (ServiceException e) {
        e.printStackTrace();
    }

After generating the stub,you can get your required methods 生成存根后,您可以获取所需的方法

Eg: stub.getValues(); 例如:stub.getValues();

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

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