[ 
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:[EMAIL PROTECTED]" 
> 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.

Reply via email to