Reputation: 51
i am doing some ksoap requests. Everything is working fine. But now I reached the point, where I have to pass a custom object which i created. Its called "Auftrag". It's just a simple POJO.
Try to pass it with "request.addProperty" ends in an error
02-26 14:47:32.995: W/System.err(14095): java.lang.RuntimeException: Cannot serialize: kochtokrax.de.pojo.Auftrag@41a444d8
After spending a lot of time I found the "Marshalling solution". http://seesharpgears.blogspot.de/2010/11/implementing-ksoap-marshal-interface.html This example is for the types "doubel" and "Date". Sadly this isn't working for my object. Can someone help me how I have to deal in this case?
Here is the way I am calling the service:
PropertyInfo nos =new PropertyInfo();
nos.setName("Auftrag");
nos.setType(AuftragMarshall.class);
// Use this to add parameters
request.addProperty("Auftrag", auftrag);
request.addProperty("DruckerBar", druckerBar);
request.addProperty("DruckerKueche", druckerKueche);
// Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoaperializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);
AuftragMarshall marshall = new AuftragMarshall();
marshall.register(envelope);
Upvotes: 2
Views: 2553
Reputation: 3057
I recommend you to see Adding an array of complex objects to the request.
Upvotes: 0
Reputation: 1952
Class Auftrag
must implements KvmSerializable
.
You haven't correctly set value for nos
, so:
PropertyInfo nos = new PropertyInfo();
nos.setName("Auftrag");
nos.setType(AuftragMarshall.class);
nos.setValue(auftragObj);
Because you've set type of PropertyInfo
to Auftrag
. But later you add DruckerBar
and DruckerKueche
. I suppose it is different classes. And it isn't correct.
I solve similar problem like you and marshalling doesn't work also for me. I solved it with custom mappers. I firstly map desired object to object of class with implementation KvmSerializable
and then send it through web service.
Upvotes: 1