kSOAP2 issue?
"McCune, Michael" <[email protected]> Mon, 1 Mar 2004 18:23:07 -0500
| Newsgroups | gmane.comp.java.enhydra.ksoap |
|---|---|
| Message-ID | <1972F96CB40DD647B2E0B38BE7960E74054095B5@tayexc17.americas.cpqcorp.net> |
I've been working with the kSOAP2 release, and I've encountered a
problem related to the SoapServlet class. SoapServlet.java declares the
SoapSerializationEnvelope member variable, as below:
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapSerializationEnvelope.VER12);
The servlet uses this class repeatedly every time that the doPost(...)
method is called. However, it seems like some member variables of
SoapSerializationEnvelope need to be reset between requests.
Mainly, I'm concerned about the call: envelope.parse(parser);
Eventually, this calls parseBody(XmlPullParser parser) within
SoapSerializationEnvelope.java. This method calls:
protected Object read(
XmlPullParser parser,
Object owner,
int index,
String namespace,
String name,
PropertyInfo expected)
throws IOException, XmlPullParserException
Within read(...), a Hashtable called idMap (which is a member variable
of the class) is populated, etc.
When 2 SOAP requests are made (of the exact same type,etc.) in
succession, then an exception is thrown because an object is found in
the idMap which is not an instance of FwdRef ( the code is: else if (hlp
!= null) throw new RuntimeException("double ID"); ).
It seems like this mapping may need to be cleared between requests, and
some synchronization might be required on the method calls, or a
synchronized block could be used.
Right now, my workaround is (probably not the best) to create a new
instance of SoapSerializationEnvelope under the doPost(...) method,
every time doPost(...) is called:
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapSerializationEnvelope.VER12);
envelope.qNameToClass = this.envelope.qNameToClass;
envelope.classToQName = this.envelope.classToQName;
I changed qNameToClass and classToQName to have a public accessor.
Thanks,
Mike