简体   繁体   中英

How to call web service client in java eclipse

I am developing a android app which invoke cloud service. I add the web reference client by calling wsdl file cloudservice.wsdl in the server site. it will generate files called

(i)CloudServiceLocator(java file)

(ii)cloudservicesoap(interface)

(iii)CloudServiceSoapProxy(java file)

(iv)CloudServiceSoapStub(java file)

(iV)CloudService(interface)

how can i call the methods inside CloudServiceSoapStub class into my application.

Try following code after calling the wsdl file

Note:The methods may be changed as per your wsdl service

    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();

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