}
}
}
if (builder == null) {
SOAPFactory soapFactory = new SOAP11Factory();
try {
XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader
(in, MessageContext.DEFAULT_CHAR_SET_ENCODING);
// Set the encoding scheme in the message context
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
MessageContext.DEFAULT_CHAR_SET_ENCODING);
builder = new StAXOMBuilder(xmlreader);
builder.setOMBuilderFactory(soapFactory);
String ns = builder.getDocumentElement().getNamespace().getNamespaceURI();
if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
envelope = getEnvelope(in, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
} else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
envelope = getEnvelope(in, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
} else {
// this is POX ... mark MC as REST
msgContext.setDoingREST(true);
envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(builder.getDocumentElement());
}
} catch (Exception e) {
log.debug("Non SOAP/XML JMS message received");
Parameter operationParam = msgContext.getAxisService().
getParameter(JMSConstants.OPERATION_PARAM);
QName operationQName = (operationParam != null ?
getQName(operationParam.getValue()) : JMSConstants.DEFAULT_OPERATION);
AxisOperation operation = msgContext.getAxisService().getOperation(operationQName);
if (operation != null) {
msgContext.setAxisOperation(operation);
} else {
handleException("Cannot find operation : " + operationQName + " on the service "
+ msgContext.getAxisService());
}
Parameter wrapperParam = msgContext.getAxisService().
getParameter(JMSConstants.WRAPPER_PARAM);
QName wrapperQName = (wrapperParam != null ?
getQName(wrapperParam.getValue()) : JMSConstants.DEFAULT_WRAPPER);
OMElement wrapper = soapFactory.createOMElement(wrapperQName, null);
try {
if (message instanceof TextMessage) {
OMTextImpl textData = (OMTextImpl) soapFactory.createOMText(
((TextMessage) message).getText());
wrapper.addChild(textData);
} else if (message instanceof BytesMessage) {
BytesMessage bm = (BytesMessage) message;
byte[] msgBytes = new byte[(int) bm.getBodyLength()];
bm.reset();
bm.readBytes(msgBytes);
DataHandler dataHandler = new DataHandler(
new ByteArrayDataSource(msgBytes));
OMText textData = soapFactory.createOMText(dataHandler, true);
wrapper.addChild(textData);
msgContext.setDoingMTOM(true);
} else {
handleException("Unsupported JMS Message format : " + message.getJMSType());
}
envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(wrapper);
} catch (JMSException j) {
handleException("Error wrapping JMS message into a SOAP envelope ", j);
}