xmlbeans cant consistently parse from an inputstream

Fri, Dec 8, 2006

Since upgrading to XMLBeans 2.2.0 I’ve been getting this error frequently. It occurs every 2 or 3 times an InputStream is parsed:

org.apache.xmlbeans.XmlException: error: Unexpected end of file after null

from the code:

soapEnvelopeDoc = EnvelopeDocument.Factory.parse(aaConnection.getInputStream());

Seems XMLBeans 2.2.0 has problems parsing an InputStream. I got some advice from the user list to convert to a String and parse that instead. So I knocked up a quick fix:

InputStream in = aaConnection.getInputStream(); BufferedReader buffer = new BufferedReader(new InputStreamReader(in)); StringBuffer stringBuffer = new StringBuffer(); String line = null; while ((line = buffer.readLine()) != null) { stringBuffer.append(line); } in.close(); soapEnvelopeDoc = EnvelopeDocument.Factory.parse(stringBuffer.toString());

and it seems to sort the error. So I’ll have to update the Guanxi IdP and SP releases.

comments powered by Disqus