I had a closer look at this method an found two bugs:
- sourceIndex is newer incremented. This has to be
changed at the end of the outer loop.
- the condition for leaving the inner loop was wrong.
When the property has no name, it should be entered at
the same position as in the soap-message. When the
property has a name, the name and the namespace must be
equal.
I changed the method acording this. The changed lines
are marked with //!!!:
protected void readSerializable(XmlPullParser parser,
KvmSerializable obj)
throws IOException, XmlPullParserException {
int testIndex = -1; // inc at beg. of loop for
perf. reasons
int sourceIndex = 0;
int cnt = obj.getPropertyCount();
PropertyInfo info = new PropertyInfo();
while (true) {
if (parser.nextTag() == XmlPullParser.END_TAG)
break;
String name = parser.getName();
int countdown = cnt;
while (true) {
if (countdown-- == 0)
throw new RuntimeException("Unknwon
Property: " + name);
if (++testIndex >= cnt)
testIndex = 0;
obj.getPropertyInfo(testIndex, properties, info);
// !!!
if (info.name == null ?
testIndex == sourceIndex :
(info.name.equals(name) &&
info.namespace.equals(parser.getNamespace())))
break;
}
obj
.setProperty(testIndex,
read(parser, obj, testIndex, null, null,
info));
sourceIndex++; //!!!
}
parser.require(XmlPullParser.END_TAG, null, null);
}
Logged In: YES
user_id=1282699
Hi,
Great observation. I was wondering if you had a unit test
or example soap message that shows what this fixes? That
would help me in adding some tests to this area and
including your patch/fix. Thanks. As well...feel free to
add this to the new ksoap2.sf.net page.
Logged In: YES
user_id=1282699
Hello. I found this bug again completely by accident when writing some tests. It
is fixed in the CVS version of the code. I will take a look at your proposed fix
and see how it compares to what I did.
Cheers
James.
http://ksoap2.sourceforge.net/