InputStream inStream) throws AxisFault, XMLStreamException {
OMElement documentElement = null;
String type = null;
if (contentType != null) {
type = getContentType(contentType, msgContext);
Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
if (builder != null) {
if (log.isDebugEnabled()) {
log.debug("createSOAPEnvelope using Builder (" +
builder.getClass() + ") selected from type (" + type +")");
}
documentElement = builder.processDocument(inStream, contentType, msgContext);
}
}
if (documentElement == null) {
if (msgContext.isDoingREST()) {
if (log.isDebugEnabled()) {
log.debug("Could not find a Builder for type (" + type + "). Using REST.");
}
StAXBuilder builder = BuilderUtil.getPOXBuilder(inStream, null);
documentElement = builder.getDocumentElement();
} else {
// FIXME making soap defualt for the moment..might effect the
// performance
if (log.isDebugEnabled()) {
log.debug("Could not find a Builder for type (" + type + "). Using SOAP.");
}
String charSetEnc = (String) msgContext
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
StAXBuilder builder = BuilderUtil.getSOAPBuilder(inStream, charSetEnc);
documentElement = builder.getDocumentElement();
}
}
return documentElement;
}