dhirajhimani / ksoap2-android

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

SoapObject newInstance() doesn't work #99

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Following code does'n work:

System.out.println("Tresc envelope przedOUT: " + envelope.bodyOut);

token = "666";

SoapObject reconnect = ((SoapObject) envelope.bodyOut).newInstance();
reconnect.setProperty(0, token);                                            

transportSe.call("after-relog-try-again", envelope);

System.out.println("Tresc envelope poOUT: " + envelope.bodyOut);

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

Tresc envelope przedOUT: getFavouriteFilters{token=123123; }
Tresc envelope poOUT: getFavouriteFilters{token=123123; }

And i get

Tresc envelope przedOUT: getFavouriteFilters{token=123123; }
Tresc envelope poOUT: getFavouriteFilters{token=666; }

It's working bad becouse i create new object.

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

2.6.0

Please provide any additional information below.

Problems with Strings?

Original issue reported on code.google.com by drozddaw...@gmail.com on 6 Jan 2012 at 8:58

GoogleCodeExporter commented 8 years ago
You should not be using bodyIn and bodyOut like that as far as I know.  What 
are you trying to do anyway? bodyOut should just be assembled and you should 
work with getResponse instead of bodyIn.

Somehow the new instance seem to associated to the envelope. Might be bug in 
newInstance. Feel free to investigate and provide a patch with unit test.

Original comment by mosa...@gmail.com on 6 Jan 2012 at 9:10

GoogleCodeExporter commented 8 years ago
I want to copy a SoapObject :) in this way but i do it in other way but i write 
about this becaouse this is a bug i think.

Original comment by drozddaw...@gmail.com on 6 Jan 2012 at 9:54

GoogleCodeExporter commented 8 years ago
Fair enough. 

Original comment by mosa...@gmail.com on 6 Jan 2012 at 10:05

GoogleCodeExporter commented 8 years ago
Feel free to investigate and provide a fix.. 

Original comment by mosa...@gmail.com on 10 Apr 2012 at 6:16

GoogleCodeExporter commented 8 years ago
Looks like the problem is in the method newInstance() on the class SoapObject 
as the reference to PropertyInfo object is being copied to the new instance 
instead of clonning their attributes too.

Object prop = properties.elementAt(propIndex);
if(prop instanceof PropertyInfo) {
PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(propIndex);
                o.addProperty(propertyInfo);
            } else if(prop instanceof SoapObject) {
                o.addSoapObject(((SoapObject)prop).newInstance());
            }

I can work on fix this

Original comment by jose.cas...@gmail.com on 11 May 2012 at 3:13

GoogleCodeExporter commented 8 years ago
That would be great. If you fix it and send a pull request with the changes on 
github we can take it from there and pull it in for the next release.

Original comment by mosa...@gmail.com on 11 May 2012 at 7:53

GoogleCodeExporter commented 8 years ago
Fix is now in master and will be released with 2.6.5

Original comment by mosa...@gmail.com on 24 May 2012 at 4:09