passing an object using webservice giving exception?

Hi All,

I have just started working in webservices using Axis 2. I have created a simple application that has two classes (as shown below) and i want the webservice client to pass ShippingAddress object to UserProfile class and then return and print the result. But i am getting this exception:

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.]]>

I am using RPC/literal, i tried other options but they are also giving exceptions.

how can I pass an object ?

-


public class UserProfile {

public void setShippingAddress(ShippingAddress value){
shippingAddress = value;
}

public ShippingAddress getShippingAddress(){
return shippingAddress;
}

private ShippingAddress shippingAddress;

}

public class ShippingAddress {

public void setName(String value){
name = value;
}

public String getName(){
return name;
}

private String name;
}
----




WebService Client

public class HelloWorldClient {
public static void main(String[] argv) {
try {

UserProfileServiceLocator locator = new UserProfileServiceLocator();
UserProfile_PortType service = locator.getUserProfile();

// invoke business method
ShippingAddress s = new ShippingAddress();
s.setName("Hello World");

service.setShippingAddress(s);

System.out.println(service.getShippingAddress().getName());

} catch (javax.xml.rpc.ServiceException ex) {
ex.printStackTrace();
}
catch (java.rmi.RemoteException ex) {
ex.printStackTrace();
}
}
}

Please sign in to leave a comment.