问题
I am using Axis2 for creating SOAP client in Java. The web service is in Java as follows:
package com.example.axis2.JavaObject
public class ABCService
{
// private variables
public int changeObj(JavaObject obj)
{
// code
}
}
The JavaObject class goes like this:
package com.example.axis2.JavaObject
public class JavaObject
{
public String a;
public Date c;
public int d;
// All setters implemented here
// All getters implemented here
public String[] getAttributesNames()
{
String[] arr = {"a","c","d"};
return arr;
}
}
The web service client is coded as:
package com.example.axis2.JavaObject
public class ABCClient
{
public int callChangeObj(JavaObject obj)
{
ABCServiceStub stub = new ABCServiceStub();
ChangeObj changeobj = new ChangeObj();
**obj.setObj(obj);**
ABCServiceResponse resp = stub.changeObj(changeObj);
System.out.println(resp.get_return());
}
}
The bold Java line is giving error that setObj() expects com.example.axis2.JavaObject.ABCServiceStub.JavaObject not com.example.axis2.JavaObject
How do I resolve this error? Thanks!
来源:https://stackoverflow.com/questions/9699368/custom-java-object-as-parameter-to-a-web-service-method