I want to send a complex object from my Ksoap Client to my webservice. It’s an object of my Class Category. The Code is based on the example of this tutorial:
http:/
Ok, I've trying somthing with your tips and now I'am very close to the solution:
I found out, that i need 2 namespaces (one to recieve and one to send)
So i do following changes:
private static final String NAMESPACE = "http://ws.chathura.com";
private static final String NAMESPACE2 = "http://ws.chathura.com/xsd";
and this:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
...
...
envelope.addMapping(NAMESPACE2, "Category",new Category().getClass());
Now my Webservice recieve my Object Category, but the first attribute from Category (CategoryID
) is not transmitted and LogCat shows following exception:
06-13 09:59:17.459: W/System.err(647): java.lang.RuntimeException: Unknown Property: categoryId
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.serialization.SoapSerializationEnvelope.readSerializable(SoapSerializationEnvelope.java:200)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:444)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:387)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:151)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
06-13 09:59:17.469: W/System.err(647): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:197)
06-13 09:59:17.479: W/System.err(647): at com.androidclient.ws.WSClientActivity$1$1.run(WSClientActivity.java:91)
06-13 09:59:17.479: W/System.err(647): at java.lang.Thread.run(Thread.java:1019)
I tested it a second time without CategoryID
, but then is Description
the unknown property :-(
What is wrong?
EDIT:
I think the exception is because the different Namespace in envelope.addMapping
. What could i do, to use only one Namespace?
Try using
private static final String NAMESPACE = "http://ws.chathura.com/xsd";
in your android activity and add the getters and setters to your Category
class in the client.