Last few days I searched all over the internet to solve this problem but I couldn’t solve this yet. The problem is this.I have a simple web service implemented in Eclipse Indigo as follow
package com.testvtfour.ws;
public class Customer {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
Web service part is perfect. I used Axis2 as soap engine & Tomcat 7 as the server. Problem occurs when I’m trying to consume this web service. I created web service client in eclipse & Axis2 Automatically generats “CusstomerCallBackHandler” & “CustomerStub”. Following is the implemented client
package com.testvtfour.ws;
import java.rmi.RemoteException;
import com.testvtfour.ws.CustomerStub.SetName;
import com.testvtfour.ws.CustomerStub.GetNameResponse;
public class TestClient {
public static void main(String[] args)throws RemoteException{
CustomerStub stub = new CustomerStub();
com.testvtfour.ws.CustomerStub.SetName obj = new
com.testvtfour.ws.CustomerStub.SetName();
obj.setName("Grant");
stub.setName(obj);
com.testvtfour.ws.CustomerStub.GetNameResponse res = stub.getName();
System.out.println(res.get_return());
}
}
But always this prints “null”. Why is that? How can I solve this? & I want to know that the updated value by this kind of client can be showed in an Android application. Because It is second part of my project. Please help me.
Thank you.
An Axis2 web service is typically stateless. This means that the
getName()is called on a different instance than thesetName()was called on, hencenameis null when you try to retrieve it.