You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Tim Mitchell (JIRA)" <ji...@apache.org> on 2008/04/17 17:35:22 UTC

[jira] Created: (WSCOMMONS-324) MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()

MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()
----------------------------------------------------------------------------------------------------------------------

                 Key: WSCOMMONS-324
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-324
             Project: WS-Commons
          Issue Type: Bug
          Components: AXIOM
            Reporter: Tim Mitchell


We're running a test to serialise a SOAPEnvelope that contains MTOM Attachments to a ByteArrayOutputStream using the SOAPEnvelope.serializeAndConsume(). Depending on whether we have touched the XOP Element in the SOAPEnvelope before we do the serializeAndConsume() we get different output. In the untouched case, the MTOM XOP Element isn't substituted with the binary attachment data, and still contains the reference to the Mime Attachment, whereas, once the element has been looked at, it has the binary attachment data inlined.

The following is a snippet of the code we're running:

ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
ByteArrayOutputStream bos2 = new ByteArrayOutputStream();

// fis is the Request Msg InputStream, and contentType has the MultiPart MTOM references.

Attachments attachments = new Attachments(fis, contentType);
PushbackInputStream pis = BuilderUtil.getPushbackInputStream(attachments.getSOAPPartInputStream());
String origEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
String encoding = BuilderUtil.getCharSetEncoding(pis, origEncoding);
XMLStreamReader streamReader = StAXUtils.createXMLStreamReader(pis, encoding);

StAXBuilder builder1 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
StAXBuilder builder2 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);

SOAPEnvelope envelope1 = (SOAPEnvelope)builder1.getDocumentElement();
SOAPEnvelope envelope2 = (SOAPEnvelope)builder2.getDocumentElement();
 	    
envelope1.serializeAndConsume(bos1);
    	    
SOAPBody body = envelope2.getBody();
for (Iterator iter = body.getChildrenWithName(new QName(body.getNamespace().getNamespaceURI(), "MTOMAttachment")); iter.hasNext();)  {
    iter.next();
}
	    	
envelope2.serializeAndConsume(bos2);

The following output from the test shows the untouched envelope with the MTOM reference still in an XOP element, and the touched Envelope with the XOP element replaced with the binary attachment data:

bos1 (The untouched Envelope)

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment><xop:Include href="cid:1.urn:uuid:93AF3E38B272DCAB881208359796917@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>

bos2 (The touched Envelope)

serialized envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment>0M8R4KGxGuEAAAAAAAAAAAAAAAA/..... [Rest of Binary Data]...</soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>




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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Commented: (WSCOMMONS-324) MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()

Posted by "Rich Scheuerle (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WSCOMMONS-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12591721#action_12591721 ] 

Rich Scheuerle commented on WSCOMMONS-324:
------------------------------------------

I am in the "design stage" right now for this problem and don't have working code.

Here are my thoughts:

  1) The StreamingOMSerializer should be upgraded to query whether the inbound reader has attachments.

  2) The StreamingOMSerializer should be upgraded to query whether the oubound writer accepts MTOM and wants optimized/inlined attachments.

  3) Using the information in (1) and (2), the StreamingOMSerializer.serializerNode(..) method should be able to 
         a) detect that the inbound message has optimized attachments and the outbound message wants inlined attachments.
         b) recognize if the element is an xop include
         c) get the attachment from the cid
         d) write out the attachment as text if it satisfies the outbound mtom threshold



> MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WSCOMMONS-324
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-324
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Tim Mitchell
>            Assignee: Rich Scheuerle
>
> We're running a test to serialise a SOAPEnvelope that contains MTOM Attachments to a ByteArrayOutputStream using the SOAPEnvelope.serializeAndConsume(). Depending on whether we have touched the XOP Element in the SOAPEnvelope before we do the serializeAndConsume() we get different output. In the untouched case, the MTOM XOP Element isn't substituted with the binary attachment data, and still contains the reference to the Mime Attachment, whereas, once the element has been looked at, it has the binary attachment data inlined.
> The following is a snippet of the code we're running:
> ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
> ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
> // fis is the Request Msg InputStream, and contentType has the MultiPart MTOM references.
> Attachments attachments = new Attachments(fis, contentType);
> PushbackInputStream pis = BuilderUtil.getPushbackInputStream(attachments.getSOAPPartInputStream());
> String origEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
> String encoding = BuilderUtil.getCharSetEncoding(pis, origEncoding);
> XMLStreamReader streamReader = StAXUtils.createXMLStreamReader(pis, encoding);
> StAXBuilder builder1 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> StAXBuilder builder2 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> SOAPEnvelope envelope1 = (SOAPEnvelope)builder1.getDocumentElement();
> SOAPEnvelope envelope2 = (SOAPEnvelope)builder2.getDocumentElement();
>  	    
> envelope1.serializeAndConsume(bos1);
>     	    
> SOAPBody body = envelope2.getBody();
> for (Iterator iter = body.getChildrenWithName(new QName(body.getNamespace().getNamespaceURI(), "MTOMAttachment")); iter.hasNext();)  {
>     iter.next();
> }
> 	    	
> envelope2.serializeAndConsume(bos2);
> The following output from the test shows the untouched envelope with the MTOM reference still in an XOP element, and the touched Envelope with the XOP element replaced with the binary attachment data:
> bos1 (The untouched Envelope)
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment><xop:Include href="cid:1.urn:uuid:93AF3E38B272DCAB881208359796917@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>
> bos2 (The touched Envelope)
> serialized envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment>0M8R4KGxGuEAAAAAAAAAAAAAAAA/..... [Rest of Binary Data]...</soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>

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


[jira] Assigned: (WSCOMMONS-324) MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()

Posted by "Rich Scheuerle (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WSCOMMONS-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rich Scheuerle reassigned WSCOMMONS-324:
----------------------------------------

    Assignee: Rich Scheuerle

> MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WSCOMMONS-324
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-324
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Tim Mitchell
>            Assignee: Rich Scheuerle
>
> We're running a test to serialise a SOAPEnvelope that contains MTOM Attachments to a ByteArrayOutputStream using the SOAPEnvelope.serializeAndConsume(). Depending on whether we have touched the XOP Element in the SOAPEnvelope before we do the serializeAndConsume() we get different output. In the untouched case, the MTOM XOP Element isn't substituted with the binary attachment data, and still contains the reference to the Mime Attachment, whereas, once the element has been looked at, it has the binary attachment data inlined.
> The following is a snippet of the code we're running:
> ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
> ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
> // fis is the Request Msg InputStream, and contentType has the MultiPart MTOM references.
> Attachments attachments = new Attachments(fis, contentType);
> PushbackInputStream pis = BuilderUtil.getPushbackInputStream(attachments.getSOAPPartInputStream());
> String origEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
> String encoding = BuilderUtil.getCharSetEncoding(pis, origEncoding);
> XMLStreamReader streamReader = StAXUtils.createXMLStreamReader(pis, encoding);
> StAXBuilder builder1 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> StAXBuilder builder2 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> SOAPEnvelope envelope1 = (SOAPEnvelope)builder1.getDocumentElement();
> SOAPEnvelope envelope2 = (SOAPEnvelope)builder2.getDocumentElement();
>  	    
> envelope1.serializeAndConsume(bos1);
>     	    
> SOAPBody body = envelope2.getBody();
> for (Iterator iter = body.getChildrenWithName(new QName(body.getNamespace().getNamespaceURI(), "MTOMAttachment")); iter.hasNext();)  {
>     iter.next();
> }
> 	    	
> envelope2.serializeAndConsume(bos2);
> The following output from the test shows the untouched envelope with the MTOM reference still in an XOP element, and the touched Envelope with the XOP element replaced with the binary attachment data:
> bos1 (The untouched Envelope)
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment><xop:Include href="cid:1.urn:uuid:93AF3E38B272DCAB881208359796917@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>
> bos2 (The touched Envelope)
> serialized envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment>0M8R4KGxGuEAAAAAAAAAAAAAAAA/..... [Rest of Binary Data]...</soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Commented: (WSCOMMONS-324) MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()

Posted by "Tim Mitchell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WSCOMMONS-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595184#action_12595184 ] 

Tim Mitchell commented on WSCOMMONS-324:
----------------------------------------

I've tested the changes, and everything seems to work OK. Thanks for the help.

> MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WSCOMMONS-324
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-324
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Tim Mitchell
>            Assignee: Rich Scheuerle
>
> We're running a test to serialise a SOAPEnvelope that contains MTOM Attachments to a ByteArrayOutputStream using the SOAPEnvelope.serializeAndConsume(). Depending on whether we have touched the XOP Element in the SOAPEnvelope before we do the serializeAndConsume() we get different output. In the untouched case, the MTOM XOP Element isn't substituted with the binary attachment data, and still contains the reference to the Mime Attachment, whereas, once the element has been looked at, it has the binary attachment data inlined.
> The following is a snippet of the code we're running:
> ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
> ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
> // fis is the Request Msg InputStream, and contentType has the MultiPart MTOM references.
> Attachments attachments = new Attachments(fis, contentType);
> PushbackInputStream pis = BuilderUtil.getPushbackInputStream(attachments.getSOAPPartInputStream());
> String origEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
> String encoding = BuilderUtil.getCharSetEncoding(pis, origEncoding);
> XMLStreamReader streamReader = StAXUtils.createXMLStreamReader(pis, encoding);
> StAXBuilder builder1 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> StAXBuilder builder2 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> SOAPEnvelope envelope1 = (SOAPEnvelope)builder1.getDocumentElement();
> SOAPEnvelope envelope2 = (SOAPEnvelope)builder2.getDocumentElement();
>  	    
> envelope1.serializeAndConsume(bos1);
>     	    
> SOAPBody body = envelope2.getBody();
> for (Iterator iter = body.getChildrenWithName(new QName(body.getNamespace().getNamespaceURI(), "MTOMAttachment")); iter.hasNext();)  {
>     iter.next();
> }
> 	    	
> envelope2.serializeAndConsume(bos2);
> The following output from the test shows the untouched envelope with the MTOM reference still in an XOP element, and the touched Envelope with the XOP element replaced with the binary attachment data:
> bos1 (The untouched Envelope)
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment><xop:Include href="cid:1.urn:uuid:93AF3E38B272DCAB881208359796917@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>
> bos2 (The touched Envelope)
> serialized envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment>0M8R4KGxGuEAAAAAAAAAAAAAAAA/..... [Rest of Binary Data]...</soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>

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


[jira] Resolved: (WSCOMMONS-324) MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()

Posted by "Rich Scheuerle (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WSCOMMONS-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rich Scheuerle resolved WSCOMMONS-324.
--------------------------------------

    Resolution: Fixed

Tim,

Please let me know if this new code fixes your performance problem.

Thanks,
Rich

> MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WSCOMMONS-324
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-324
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Tim Mitchell
>            Assignee: Rich Scheuerle
>
> We're running a test to serialise a SOAPEnvelope that contains MTOM Attachments to a ByteArrayOutputStream using the SOAPEnvelope.serializeAndConsume(). Depending on whether we have touched the XOP Element in the SOAPEnvelope before we do the serializeAndConsume() we get different output. In the untouched case, the MTOM XOP Element isn't substituted with the binary attachment data, and still contains the reference to the Mime Attachment, whereas, once the element has been looked at, it has the binary attachment data inlined.
> The following is a snippet of the code we're running:
> ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
> ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
> // fis is the Request Msg InputStream, and contentType has the MultiPart MTOM references.
> Attachments attachments = new Attachments(fis, contentType);
> PushbackInputStream pis = BuilderUtil.getPushbackInputStream(attachments.getSOAPPartInputStream());
> String origEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
> String encoding = BuilderUtil.getCharSetEncoding(pis, origEncoding);
> XMLStreamReader streamReader = StAXUtils.createXMLStreamReader(pis, encoding);
> StAXBuilder builder1 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> StAXBuilder builder2 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> SOAPEnvelope envelope1 = (SOAPEnvelope)builder1.getDocumentElement();
> SOAPEnvelope envelope2 = (SOAPEnvelope)builder2.getDocumentElement();
>  	    
> envelope1.serializeAndConsume(bos1);
>     	    
> SOAPBody body = envelope2.getBody();
> for (Iterator iter = body.getChildrenWithName(new QName(body.getNamespace().getNamespaceURI(), "MTOMAttachment")); iter.hasNext();)  {
>     iter.next();
> }
> 	    	
> envelope2.serializeAndConsume(bos2);
> The following output from the test shows the untouched envelope with the MTOM reference still in an XOP element, and the touched Envelope with the XOP element replaced with the binary attachment data:
> bos1 (The untouched Envelope)
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment><xop:Include href="cid:1.urn:uuid:93AF3E38B272DCAB881208359796917@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>
> bos2 (The touched Envelope)
> serialized envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment>0M8R4KGxGuEAAAAAAAAAAAAAAAA/..... [Rest of Binary Data]...</soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>

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


[jira] Commented: (WSCOMMONS-324) MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()

Posted by "Rich Scheuerle (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WSCOMMONS-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590212#action_12590212 ] 

Rich Scheuerle commented on WSCOMMONS-324:
------------------------------------------

In the "working case", the OM tree is fully built and then serialized.
In the "not working case", the OM is partially built, and the "input to output" streaming algorithm is used.

It should be pretty easy to write a validating testcase.

> MTOM Attachment binary data not being inlined into ByteArrayOutputStream when using SOAPEnvelope.serializeAndConsume()
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WSCOMMONS-324
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-324
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: AXIOM
>            Reporter: Tim Mitchell
>            Assignee: Rich Scheuerle
>
> We're running a test to serialise a SOAPEnvelope that contains MTOM Attachments to a ByteArrayOutputStream using the SOAPEnvelope.serializeAndConsume(). Depending on whether we have touched the XOP Element in the SOAPEnvelope before we do the serializeAndConsume() we get different output. In the untouched case, the MTOM XOP Element isn't substituted with the binary attachment data, and still contains the reference to the Mime Attachment, whereas, once the element has been looked at, it has the binary attachment data inlined.
> The following is a snippet of the code we're running:
> ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
> ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
> // fis is the Request Msg InputStream, and contentType has the MultiPart MTOM references.
> Attachments attachments = new Attachments(fis, contentType);
> PushbackInputStream pis = BuilderUtil.getPushbackInputStream(attachments.getSOAPPartInputStream());
> String origEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
> String encoding = BuilderUtil.getCharSetEncoding(pis, origEncoding);
> XMLStreamReader streamReader = StAXUtils.createXMLStreamReader(pis, encoding);
> StAXBuilder builder1 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> StAXBuilder builder2 = new MTOMStAXSOAPModelBuilder(streamReader, attachments);
> SOAPEnvelope envelope1 = (SOAPEnvelope)builder1.getDocumentElement();
> SOAPEnvelope envelope2 = (SOAPEnvelope)builder2.getDocumentElement();
>  	    
> envelope1.serializeAndConsume(bos1);
>     	    
> SOAPBody body = envelope2.getBody();
> for (Iterator iter = body.getChildrenWithName(new QName(body.getNamespace().getNamespaceURI(), "MTOMAttachment")); iter.hasNext();)  {
>     iter.next();
> }
> 	    	
> envelope2.serializeAndConsume(bos2);
> The following output from the test shows the untouched envelope with the MTOM reference still in an XOP element, and the touched Envelope with the XOP element replaced with the binary attachment data:
> bos1 (The untouched Envelope)
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment><xop:Include href="cid:1.urn:uuid:93AF3E38B272DCAB881208359796917@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>
> bos2 (The touched Envelope)
> serialized envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:To>http://localhost:7082/axis2/services/MTOMService</wsa:To><wsa:MessageID>urn:uuid:93AF3E38B272DCAB881208359796616</wsa:MessageID><wsa:Action>sendString</wsa:Action></soapenv:Header><soapenv:Body><MTOMService:sendString xmlns:MTOMService="http://test"><MTOMService:Text>Client Test</MTOMService:Text></MTOMService:sendString><soapenv:MTOMAttachment>0M8R4KGxGuEAAAAAAAAAAAAAAAA/..... [Rest of Binary Data]...</soapenv:MTOMAttachment></soapenv:Body></soapenv:Envelope>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org