Passing Costum Class as Parameter to a WebService with KSOAP

Put your problem here if it does not fit any of the other categories.

Passing Costum Class as Parameter to a WebService with KSOAP

Postby lichtbringer » Mon Feb 11, 2008 1:11 pm

Hi,
I've got a problem with calling a webservice from Android with KSOAP.
I've got a webmethod with following signature:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @WebMethod(operationName = "doSomething")
  3.  
  4.     public boolean doSomething(@WebParam(name = "objMyClass")
  5.  
  6.     MyClass objMyClass)
  7.  
  8.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

The class MyClass implementation looks that way:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @XmlRootElement(name = "myClass")
  3.  
  4. public class MyClass {
  5.  
  6. private String myData;
  7.  
  8.  @XmlAttribute
  9.  
  10.         public String getMyData() {
  11.  
  12.                 return myData;
  13.  
  14.         }
  15.  
  16.         public void setMyData(String myData) {
  17.  
  18.             this.myData = myData;
  19.  
  20.         }
  21.  
  22.  
  23.  
  24. }
  25.  
  26.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

In my Androidapplication I'm calling the webmethod that way:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public boolean callDoData(MyClass myClass) throws IOException,
  3.  
  4. XmlPullParserException
  5.  
  6.     {
  7.  
  8.         SoapObject request = new SoapObject(WSConstants.NAMESPACE,
  9.  
  10. WSConstants.DOSOMETHINGMETHOD);
  11.  
  12.                 SoapObject createMProfile = new SoapObject(WSConstants.NAMESPACE,
  13.  
  14. WSConstants.DOSOMETHINGSOAP);
  15.  
  16.                 createMProfile.addProperty("objMyClass", myClass);
  17.  
  18.                 request.addProperty(WSConstants.DOSOMETHINGMETHOD, createMProfile);
  19.  
  20.                 SoapSerializationEnvelope envelope = new
  21.  
  22. SoapSerializationEnvelope(SoapEnvelope.VER11);
  23.  
  24.         envelope.setOutputSoapObject(request);
  25.  
  26.         AndroidHttpTransport androidHttpTransport = new
  27.  
  28. AndroidHttpTransport(WSConstants.URL);
  29.  
  30.         androidHttpTransport.call(WSConstants.DOSOMETHINGSOAP,
  31.  
  32. envelope);
  33.  
  34.         Object result = envelope.getResponse();
  35.  
  36.         return Boolean.valueOf(result.toString());
  37.  
  38.     }
  39.  
  40.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

If I call that function i've got an exception which say "Cannot
serialize MyClass".
What have I make wrong? Any hints?

Thanks

Markus
lichtbringer
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Feb 11, 2008 1:06 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests