zeycc / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Bug in SoapSerializationEnvelope.writeObjectBody(XmlSerializer, KvmSerializable) #117

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create nested SoapObjects with soapObject1.addSoapObject(anotherOne).
2. Put those in an envelope  
3. Invoke androidHttpTransport.call(action, envelope)

What is the expected output? What do you see instead?

This throws a ClassCastException in SoapObject.java:

 public void getPropertyInfo(int index, PropertyInfo propertyInfo) {
        PropertyInfo p = (PropertyInfo) properties.elementAt(index);
        propertyInfo.name = p.name;
        propertyInfo.namespace = p.namespace;
        propertyInfo.flags = p.flags;
        propertyInfo.type = p.type;
        propertyInfo.elementType = p.elementType;
        propertyInfo.value = p.value;
        propertyInfo.multiRef = p.multiRef;
    }

on the first line of the method.

This is because the properties list has SoapObjects within.

To me this looks like a logic error in 

SoapSerializationEnvelope.writeObjectBody(XmlSerializer, KvmSerializable)

where the getPropertyInfo method is called in an odd place. On line 594:

https://github.com/mosabua/ksoap2-android/blob/master/ksoap2-base/src/main/java/
org/ksoap2/serialization/SoapSerializationEnvelope.java

I guess the call should be done in within the condition:

if(!(prop instanceof SoapObject)) {

?

What version of the product are you using? On what operating system?

Latest from github (at 25th Apr 2012).

Please provide any additional information below.

Original issue reported on code.google.com by juha.ker...@gmail.com on 25 Apr 2012 at 11:28

GoogleCodeExporter commented 8 years ago
Sounds good. Wanna send a pull request?

Original comment by mosa...@gmail.com on 25 Apr 2012 at 10:08

GoogleCodeExporter commented 8 years ago
Pull request sent, though I fixed the issue slightly differently, I made 
getPropertyInfo() work on SoapObjects instead. I feel this approach is safer.

Original comment by sergey....@gmail.com on 28 Apr 2012 at 8:45

GoogleCodeExporter commented 8 years ago
Pull request accepted. Will go out with the 2.6.4 release.

Original comment by mosa...@gmail.com on 30 Apr 2012 at 6:15