[
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:[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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]