[ 
https://issues.apache.org/jira/browse/AXIS2-4508?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lyall Pearce closed AXIS2-4508.
-------------------------------

    Resolution: Fixed

Problem was between the chair and the keyboard.

I needed to place

            _returnEnv.build();

in the modified stub code, as the Envelope was never intended to leave the 
modified stub method.

Upon exit from the stub method, objects on which the Envelope had relied had 
been cleaned up.


> Conversion of SOAP Envelope to String results in Exception
> ----------------------------------------------------------
>
>                 Key: AXIS2-4508
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4508
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: 1.5
>         Environment: Windows XP/2003 Intel, 32 bit, JRE 1.5.0_16
>            Reporter: Lyall Pearce
>
> I have created an AXIS2 1.5 client using a WSDL as a starting point.
> My client wants to access the entire SOAP message, not the body, so I hacked 
> the Stub.java code
> as shown further down...
> What I am trying to do is simply convert the SOAP Envelope into a string so I 
> can look at it
> (and do other stuff with it)
> My Client is invoking a service facade in Oracle Web Services Manager, 10g.
> I receive the message but fail to convert to a string, if the reply spans 2 
> (or more chunks) and the second chunk is longer than 16 characters.
> The difference between a reply that works, and a reply that does not, is ONE 
> character.
> Sample Code is shown further down.
> WORKING REPLY (WireShark 1.2.2 "Follow TCP Stream" output)
> =-=-=-=-=-BEGIN=-=-=-=-=-
> POST /gateway/services/Hello_World_Signed_Response HTTP/1.1
> Content-Type: text/xml; charset=UTF-8
> SOAPAction: "process"
> User-Agent: Axis2
> Host: soa.tactical-001:8888
> Transfer-Encoding: chunked
> 1f2
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
> xmlns:hel="http://xmlns.oracle.com/Hello_World_HTTP";>
>    <soapenv:Header />
>    <soapenv:Body>
>       <hel:Hello_World_HTTPProcessRequest>
>          <hel:input>
>       <m:processRequest xmlns:m="http://xmlns.oracle.com/OIM/provisioning";>
> Hello World some more
> Hello
>       </m:processRequest>
> </hel:input>
>       </hel:Hello_World_HTTPProcessRequest>
>    </soapenv:Body>
> </soapenv:Envelope>
> 0
> HTTP/1.1 200 OK
> Date: Thu, 24 Sep 2009 04:14:39 GMT
> Server: Oracle-Application-Server-10g/10.1.3.4.0 Oracle-HTTP-Server
> Transfer-Encoding: chunked
> Content-Type: text/xml; charset=utf-8
> f3b
> <?xml version="1.0" encoding="UTF-8"?>
> <env:Envelope 
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";><env:Header><wsse:Security
>  soapenv:mustUnderstand="0" 
> xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
>  
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
>  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><dsig:Signature 
> xmlns="http://www.w3.org/2000/09/xmldsig#"; 
> xmlns:dsig="http://www.w3.org/2000/09/xmldsig#";><dsig:SignedInfo><dsig:CanonicalizationMethod
>  Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><dsig:SignatureMethod 
> Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><dsig:Reference 
> URI="#_rqXiXeM5X0qEwhqwf91C3A22"><dsig:Transforms><dsig:Transform 
> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></dsig:Transforms><dsig:DigestMethod
>  
> Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>ubW48CoJ0q78gWlYmYlkFjgB22w=</dsig:DigestValue></dsig:Reference><dsig:Reference
>  URI="#_pDFOEYfn42rBrnbslNKwFg22"><dsig:Transforms><dsig:Transform 
> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></dsig:Transforms><dsig:DigestMethod
>  
> Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>G61k192Qw7PGe63e7FFIyJ3RIVk=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>fyhGrPF2fFyGk+hYSCm5H+EjDL2JNZYfAxxr0nFVm8w7jbwO3Rx8zoEGqv2v8mO2OLcF2FQ4+u9JYmqdKcL2toYZ2vAG5SgdIHMqw7ggIDoMwulD2LZa5e7N1VpVd9xgzmF9Oo5h6WX6Txo6qD7L7h/rinaapRWevLglkj8hrKI=</dsig:SignatureValue><dsig:KeyInfo><wsse:SecurityTokenReference
>  
> xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";><wsse:Reference
>  URI="#BST-bXj11l2lIBL10WnxqEgcAQ22" 
> ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference></dsig:KeyInfo></dsig:Signature><wsse:BinarySecurityToken
>  
> ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
>  
> EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary";
>  wsu:Id="BST-bXj11l2lIBL10WnxqEgcAQ22" 
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";>MIICUjCCAbsCBEqFEmEwDQYJKoZIhvcNAQEEBQAwcDELMAkGA1UEBhMCQVUxGDAWBgNVBAgTD1NvdXRoIEF1c3RyYWxpYTERMA8GA1UEBxMIQWRlbGFpZGUxDDAKBgNVBAoTA0VEUzEPMA0GA1UECwwGRURTX0FVMRUwEwYDVQQDEwxMeWFsbCBQZWFyY2UwHhcNMDkwODE0MDcyOTM3WhcNMDkxMTEyMDcyOTM3WjBwMQswCQYDVQQGEwJBVTEYMBYGA1UECBMPU291dGggQXVzdHJhbGlhMREwDwYDVQQHEwhBZGVsYWlkZTEMMAoGA1UEChMDRURTMQ8wDQYDVQQLDAZFRFNfQVUxFTATBgNVBAMTDEx5YWxsIFBlYXJjZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAlcxGgpNLslocN7VlQdLFgDnUw35eezZ/xcZ+qOLMZpLQYamdkjJ4BCTPno3NApRAaCxC2xH83jQi2P0R1PtnK+wxc2PWXw3IdIhPKum0050P5sOxdPjy7Kp5NmVFkiDIhu9IBuomevfLEZiTcaHosca3hb80M7TDgYRCXEXD4ccCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCJK1GI+cyybcWPpYyNovQjP2m5uTHRfmrdqq7RfLZjUyoHrj4VOmbz0f2BH2xZGrygGng+o6R39Lyzn+7zXEbJFxYGXE1x/q8IusE5vVD4jnAJ5fLJlV792Vgn0PakFlnH8zmenObkEe+5eOyDbSOgjWTnlwDsIDfYDyrn7KHK6w==</wsse:BinarySecurityToken><wsu:Timestamp
>  wsu:Id="_pDFOEYfn42rBrnbslNKwFg22" 
> xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
>  
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";><wsu:Created>2009-09-24T04:14:39Z</wsu:Created></wsu:Timestamp></wsse:Security></env:Header><env:Body
>  wsu:Id="_rqXiXeM5X0qEwhqwf91C3A22" 
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";><Hello_World_HTTPProcessResponse
>  xmlns="http://xmlns.oracle.com/Hello_World_HTTP";><result>Hello <hel:input 
> xmlns:hel="http://xmlns.oracle.com/Hello_World_HTTP";>
>       <m:processRequest xmlns:m="http://xmlns.oracle.com/OIM/provisioning";>
> Hello World some more
> Hello
>       </m:processRequest>
> </hel:input></result></Hello_World_HTTPProcessResponse></env:Body>
> f  
> </env:Envelope>
> 0
> =-=-=-=-=-END=-=-=-=-=-
> FAILING REPLY  (WireShark 1.2.2 "Follow TCP Stream" output)
> =-=-=-=-=-BEGIN=-=-=-=-=-
> POST /gateway/services/Hello_World_Signed_Response HTTP/1.1
> Content-Type: text/xml; charset=UTF-8
> SOAPAction: "process"
> User-Agent: Axis2
> Host: soa.tactical-001:8888
> Transfer-Encoding: chunked
> 1f2
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
> xmlns:hel="http://xmlns.oracle.com/Hello_World_HTTP";>
>    <soapenv:Header />
>    <soapenv:Body>
>       <hel:Hello_World_HTTPProcessRequest>
>          <hel:input>
>       <m:processRequest xmlns:m="http://xmlns.oracle.com/OIM/provisioning";>
> Hello World some more
> Hello
>       </m:processRequest>
> </hel:input>
>       </hel:Hello_World_HTTPProcessRequest>
>    </soapenv:Body>
> </soapenv:Envelope>
> 0
> HTTP/1.1 200 OK
> Date: Thu, 24 Sep 2009 04:14:39 GMT
> Server: Oracle-Application-Server-10g/10.1.3.4.0 Oracle-HTTP-Server
> Transfer-Encoding: chunked
> Content-Type: text/xml; charset=utf-8
> f3b
> <?xml version="1.0" encoding="UTF-8"?>
> <env:Envelope 
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";><env:Header><wsse:Security
>  soapenv:mustUnderstand="0" 
> xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
>  
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
>  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><dsig:Signature 
> xmlns="http://www.w3.org/2000/09/xmldsig#"; 
> xmlns:dsig="http://www.w3.org/2000/09/xmldsig#";><dsig:SignedInfo><dsig:CanonicalizationMethod
>  Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><dsig:SignatureMethod 
> Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><dsig:Reference 
> URI="#_rqXiXeM5X0qEwhqwf91C3A22"><dsig:Transforms><dsig:Transform 
> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></dsig:Transforms><dsig:DigestMethod
>  
> Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>ubW48CoJ0q78gWlYmYlkFjgB22w=</dsig:DigestValue></dsig:Reference><dsig:Reference
>  URI="#_pDFOEYfn42rBrnbslNKwFg22"><dsig:Transforms><dsig:Transform 
> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></dsig:Transforms><dsig:DigestMethod
>  
> Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>G61k192Qw7PGe63e7FFIyJ3RIVk=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>fyhGrPF2fFyGk+hYSCm5H+EjDL2JNZYfAxxr0nFVm8w7jbwO3Rx8zoEGqv2v8mO2OLcF2FQ4+u9JYmqdKcL2toYZ2vAG5SgdIHMqw7ggIDoMwulD2LZa5e7N1VpVd9xgzmF9Oo5h6WX6Txo6qD7L7h/rinaapRWevLglkj8hrKI=</dsig:SignatureValue><dsig:KeyInfo><wsse:SecurityTokenReference
>  
> xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";><wsse:Reference
>  URI="#BST-bXj11l2lIBL10WnxqEgcAQ22" 
> ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference></dsig:KeyInfo></dsig:Signature><wsse:BinarySecurityToken
>  
> ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
>  
> EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary";
>  wsu:Id="BST-bXj11l2lIBL10WnxqEgcAQ22" 
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";>MIICUjCCAbsCBEqFEmEwDQYJKoZIhvcNAQEEBQAwcDELMAkGA1UEBhMCQVUxGDAWBgNVBAgTD1NvdXRoIEF1c3RyYWxpYTERMA8GA1UEBxMIQWRlbGFpZGUxDDAKBgNVBAoTA0VEUzEPMA0GA1UECwwGRURTX0FVMRUwEwYDVQQDEwxMeWFsbCBQZWFyY2UwHhcNMDkwODE0MDcyOTM3WhcNMDkxMTEyMDcyOTM3WjBwMQswCQYDVQQGEwJBVTEYMBYGA1UECBMPU291dGggQXVzdHJhbGlhMREwDwYDVQQHEwhBZGVsYWlkZTEMMAoGA1UEChMDRURTMQ8wDQYDVQQLDAZFRFNfQVUxFTATBgNVBAMTDEx5YWxsIFBlYXJjZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAlcxGgpNLslocN7VlQdLFgDnUw35eezZ/xcZ+qOLMZpLQYamdkjJ4BCTPno3NApRAaCxC2xH83jQi2P0R1PtnK+wxc2PWXw3IdIhPKum0050P5sOxdPjy7Kp5NmVFkiDIhu9IBuomevfLEZiTcaHosca3hb80M7TDgYRCXEXD4ccCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCJK1GI+cyybcWPpYyNovQjP2m5uTHRfmrdqq7RfLZjUyoHrj4VOmbz0f2BH2xZGrygGng+o6R39Lyzn+7zXEbJFxYGXE1x/q8IusE5vVD4jnAJ5fLJlV792Vgn0PakFlnH8zmenObkEe+5eOyDbSOgjWTnlwDsIDfYDyrn7KHK6w==</wsse:BinarySecurityToken><wsu:Timestamp
>  wsu:Id="_pDFOEYfn42rBrnbslNKwFg22" 
> xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
>  
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";><wsu:Created>2009-09-24T04:14:39Z</wsu:Created></wsu:Timestamp></wsse:Security></env:Header><env:Body
>  wsu:Id="_rqXiXeM5X0qEwhqwf91C3A22" 
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";><Hello_World_HTTPProcessResponse
>  xmlns="http://xmlns.oracle.com/Hello_World_HTTP";><result>Hello <hel:input 
> xmlns:hel="http://xmlns.oracle.com/Hello_World_HTTP";>
>       <m:processRequest xmlns:m="http://xmlns.oracle.com/OIM/provisioning";>
> Hello World some more
> Hello
>       </m:processRequest>
> </hel:input></result></Hello_World_HTTPProcessResponse></env:Body>
> f  
> </env:Envelope>
> 0
> =-=-=-=-=-END=-=-=-=-=-
> I receive the following exception...
> [ERROR] MyProgram:run:Exception: com.ctc.wstx.exc.WstxIOException: Attempted 
> read on closed stream.com.ctc.wstx.exc.WstxIOException: Attempted read on 
> closed stream.
>         at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:683)
>         at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1086)
>         at 
> javax.xml.stream.util.StreamReaderDelegate.next(StreamReaderDelegate.java:60)
>         at 
> org.apache.axiom.om.impl.builder.SafeXMLStreamReader.next(SafeXMLStreamReader.java:183)
>         at 
> org.apache.axiom.om.impl.llom.OMStAXWrapper.next(OMStAXWrapper.java:1005)
>         at 
> org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serializeNode(StreamingOMSerializer.java:125)
>         at 
> org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serialize(StreamingOMSerializer.java:93)
>         at 
> org.apache.axiom.om.impl.serialize.StreamingOMSerializer.serialize(StreamingOMSerializer.java:76)
>         at 
> org.apache.axiom.om.impl.util.OMSerializerUtil.serializeByPullStream(OMSerializerUtil.java:579)
>         at 
> org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:246)
>         at 
> org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:995)
>         at 
> org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:403)
>         at 
> org.apache.axiom.om.impl.llom.OMElementImpl.toStringWithConsume(OMElementImpl.java:1093)
>         at com.bogus.MyProgram.run(MyProgram.java:190)
>         at com.bogus.MyProgram.main(MyProgram.java:55)
> Caused by: java.io.IOException: Attempted read on closed stream.
>         at 
> org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
>         at 
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107)
>         at java.io.FilterInputStream.read(FilterInputStream.java:116)
>         at 
> org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:147)
>         at java.io.FilterInputStream.read(FilterInputStream.java:116)
>         at java.io.PushbackInputStream.read(PushbackInputStream.java:169)
>         at java.io.FilterInputStream.read(FilterInputStream.java:90)
>         at com.ctc.wstx.io.UTF8Reader.loadMore(UTF8Reader.java:365)
>         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.loadMoreFromCurrent(StreamScanner.java:1021)
>         at 
> com.ctc.wstx.sr.StreamScanner.loadMoreFromCurrent(StreamScanner.java:1028)
>         at 
> com.ctc.wstx.sr.StreamScanner.getNextCharFromCurrent(StreamScanner.java:786)
>         at 
> com.ctc.wstx.sr.BasicStreamReader.readEndElem(BasicStreamReader.java:3204)
>         at 
> com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2830)
>         at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019)
>         ... 13 more
> [DEBUG] MyProgram:run:Waiting for messages.
> *** My Client code...
> ...snip...
>  MyProgramStub webServiceStub;
>  webServiceStub = new MyProgramStubStub(targetServiceEndPoint); // url
>  org.apache.axiom.soap.SOAPEnvelope response;
>  response = webServiceStub.process(request);
>  String responseString = response.toStringWithConsume(); // exception happens 
> here...
> // more attempts...
> // String responseString = response.toString(); // exception happens here 
> too...
> // StringWriter writer = new StringWriter();
> // 
> response.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
> // writer.flush();
> // String responseString = writer.toString(); // exception happens here too...
> ...snip...
> *** Stub.java code
> ...snip...
> public  org.apache.axiom.soap.SOAPEnvelope  process(
>        org.apache.axiom.soap.SOAPEnvelope  theEnvelope)
>         throws java.rmi.RemoteException
>     {
>         org.apache.axis2.context.MessageContext _messageContext = null;
>         try {
>             org.apache.axis2.client.OperationClient _operationClient =
>                 _serviceClient.createClient(_operations[0].getName());
>             _operationClient.getOptions().setAction("process");
>             
> _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
>             addPropertyToOperationClient(_operationClient,
>                                          
> org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
>                                          "&");
>             // create a message context
>             _messageContext = new org.apache.axis2.context.MessageContext();
>             //adding SOAP soap_headers
>             _serviceClient.addHeadersToEnvelope(theEnvelope);
>             // set the message context with that soap envelope
>             _messageContext.setEnvelope(theEnvelope);
>             // add the message contxt to the operation client
>             _operationClient.addMessageContext(_messageContext);
>             //execute the operation client
>             _operationClient.execute(true);
>             org.apache.axis2.context.MessageContext _returnMessageContext =
>                 
> _operationClient.getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>             org.apache.axiom.soap.SOAPEnvelope _returnEnv = 
> _returnMessageContext.getEnvelope();
>             return _returnEnv;
>         } catch (org.apache.axis2.AxisFault f) {
> ...snip...
> } 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to