简体   繁体   中英

Creating a client for java web service

I have created a simple java web service class like follows

public class Customer {
private String customerName;

public String getCustomerName() {
return customerName;
}

public void setCustomerName(String customerName) {
this.customerName = customerName;
}

I did this using Eclipse Indigo enterprise edition & I used Axis2 as soap engine. Every thing fine.I created web service successfully & deployed it on Tomcat 7 server(wsdl also ok). Now I want create a client program which can update the name variable. I created web service client using Eclipse & it generates CustomerCallbackHandler & CustomerStub java classes automatically. But I don't know how to develop a client using that classes to update variable. Please help me....

I implemented a client like this...

 import java.rmi.RemoteException;
 import com.spikes.ws.CustomerWSStub.SetName;
 import com.spikes.ws.CustomerWSStub.GetNameResponse;;
   public class TestClient {
public static void main(String[] args) throws RemoteException{
    CustomerWSStub.SetName obj = new CustomerWSStub.SetName();
    obj.setName("Kenth");

    CustomerWSStub.GetNameResponse res = new CustomerWSStub.GetNameResponse();
    System.out.println(res.get_return());
}

}

But when I'm running the code It gives "null" as result. What is wrong?? & how can I correct that ??? please help me.....

Please list your webservice method. You have listed, I'm assuming the class you pass up.

CustomerWSStub.SetName obj = new CustomerWSStub.SetName();    
obj.setName("Kenth");  

You need to call the web method on the class

CustomerWSStub.SetName obj = new CustomerWSStub.SetName();    
obj.setName("Kenth");  

CustomerWSStub stub = new CustomerWSStub();
CustomerWSStub.GetNameResponse res = stub.GetName(obj);

Please post your actual web service method and that will be helpful.

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