PushbackInputStream pis = BuilderUtil.getPushbackInputStream(inputStream);
String actualCharSetEncoding = BuilderUtil.getCharSetEncoding(pis, charSetEncoding);
// Get the XMLStreamReader for this input stream
streamReader = StAXUtils.createXMLStreamReader(StAXParserConfiguration.SOAP, pis, actualCharSetEncoding);
StAXBuilder builder = new MTOMStAXSOAPModelBuilder(streamReader,
attachments);
SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
BuilderUtil
.validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
.getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
//Overriding the earlier setting by MIMEBuilder
messageContext.setDoingSwA(false);
messageContext.setDoingMTOM(true);
return envelope;