Hello, I've done additional research on this topic, and it seems that the problem is in the size of the response XML envelope. When I am trying to print out the resulted OMElement:
result.serializeAndConsume(System.out); Only first 4000 characters are printed and then following exception is thrown: java.lang.RuntimeException: [was class java.io.IOException] Attempted read on closed stream Stange is that when the operation returns XML which length is less than 4000 characters everything works fine. Also when I use this operation in async mode, everything is also fine, response size irrespectively. Do you know about this limitation? Thanks in advance, Vadim -----Original Message----- From: Lositski Vadim Sent: Wednesday, December 12, 2007 5:19 PM To: axis-user@ws.apache.org Subject: [Axis2] Unable to deserialize OMElement Hi everybody, I am sending a request to the service which combines its response from various sources, then creates an OMElement and sends it back. The databinding and deserialization is made with Castor and Stax APIs basically as it is described in the "databinding" example from Axis2 distribution. When I am trying to create an object from an OMElement received from the service StAXSource staxSource = new StAXSource(result.getXMLStreamReader()); Unmarshaller unmarshaller = new Unmarshaller(TargetClass.class); UnmarshalHandler unmarshalHandler = unmarshaller.createHandler(); try { ContentHandler contentHandler = (ContentHandler) Unmarshaller.getContentHandler(unmarshalHandler); TransformerFactory.newInstance().newTransformer().transform(staxSource, new SAXResult(contentHandler)); } catch (Exception ex) { ex.printStackTrace(); } TargetClass response = (TargetClass) unmarshalHandler.getObject(); I receive a NullPointerException exception: java.lang.NullPointerException at javanet.staxutils.StAXSource$1.parse(StAXSource.java:196) at javanet.staxutils.StAXSource$1.parse(StAXSource.java:181) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484) at com.profitsoftware.webservices.central.CentralWebServiceTester.main(CentralWebServiceTester.java:85) The object is serialized, but partially some data fields are null I have also tried to just print out the OMElement, but received: Exception in thread "main" java.lang.StackOverflowError at org.apache.axiom.om.impl.llom.OMNodeImpl.setComplete(OMNodeImpl.java:174) at org.apache.axiom.om.impl.llom.OMNodeImpl.setComplete(OMNodeImpl.java:174) at org.apache.axiom.om.impl.llom.OMNodeImpl.setComplete(OMNodeImpl.java:174) When I use OMElement.toStringWithConsume() I have the following exception: java.lang.RuntimeException: [was class java.io.IOException] Attempted read on closed stream. at com.ctc.wstx.util.ExceptionUtil.throwRuntimeException(ExceptionUtil.java:18) at com.ctc.wstx.sr.StreamScanner.throwLazyError(StreamScanner.java:706) at com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:3655) at com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:809) at org.apache.axiom.om.impl.llom.OMStAXWrapper.getText(OMStAXWrapper.java:364) at org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serializeText(StreamingOMSerializer.java:339) at org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serializeNode(StreamingOMSerializer.java:79) at org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serialize(StreamingOMSerializer.java:57) at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeByPullStream(OMSerializerUtil.java:525) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:795) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:814) at org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:358) at org.apache.axiom.om.impl.llom.OMElementImpl.toStringWithConsume(OMElementImpl.java:904) at com.profitsoftware.webservices.central.CentralWebServiceTester.main(CentralWebServiceTester.java:79) Caused by: java.io.IOException: Attempted read on closed stream. at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:165) at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:106) at java.io.FilterInputStream.read(FilterInputStream.java:111) at java.io.PushbackInputStream.read(PushbackInputStream.java:161) at java.io.FilterInputStream.read(FilterInputStream.java:90) at com.ctc.wstx.io.UTF8Reader.loadMore(UTF8Reader.java:362) at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:110) at com.ctc.wstx.io.MergedReader.read(MergedReader.java:101) at com.ctc.wstx.io.ReaderSource.readInto(ReaderSource.java:84) at com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:57) at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:967) at com.ctc.wstx.sr.BasicStreamReader.readTextSecondary(BasicStreamReader.java:4626) at com.ctc.wstx.sr.BasicStreamReader.readCoalescedText(BasicStreamReader.java:4124) at com.ctc.wstx.sr.BasicStreamReader.finishToken(BasicStreamReader.java:3699) at com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:3647) What I have noticed is that when the size of response is 3980 bytes everything is just fine, no exceptions, deserialization is also correct. But when the response is 4606 bytes, it fails. Perhaps some buffer or cache issue? Another interesting thing is that when I copy the response (which fails) from SOAP monitor to the file, and the create an OMElement and print it out everything is also fine: StAXOMBuilder sab = new StAXOMBuilder("c:\\test.xml"); OMElement result = sab.getDocument().getOMDocumentElement(); System.out.println(result); Please give me a hint how to solve this problem. I am using latest stable Axis2 version which is currently 1.3 Best regards, Vadim --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]