Object contentType = null;
OperationContext opContext = msgContext.getOperationContext();
if (opContext != null) {
contentType = opContext.getProperty(HTTPConstants.MTOM_RECIVED_CONTENT_TYPE);
}else{
throw new AxisFault("Operation Context can not be Null");
}
StAXBuilder builder = null;
SOAPEnvelope envelope = null;
if (contentType != null) {
msgContext.setDoingMTOM(true);
builder = HTTPTransportUtils.selectBuilderForMIME(msgContext, inStream, (String)contentType);
envelope = (SOAPEnvelope) builder.getDocumentElement();
}else if (msgContext.isDoingREST()) {
Reader reader = new InputStreamReader(inStream);
XMLStreamReader xmlreader =
XMLInputFactory.newInstance().createXMLStreamReader(reader);
SOAPFactory soapFactory = new SOAP11Factory();
builder = new StAXOMBuilder(xmlreader);
builder.setOmbuilderFactory(soapFactory);
envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(builder.getDocumentElement());
} else {
Reader reader = new InputStreamReader(inStream);
XMLStreamReader xmlreader =
XMLInputFactory.newInstance().createXMLStreamReader(reader);
builder = new StAXSOAPModelBuilder(xmlreader);
envelope = (SOAPEnvelope) builder.getDocumentElement();
}
return envelope;
} catch (Exception e) {
throw new AxisFault(e);
}
}