msgContext.setTo(new EndpointReference(requestURI));
msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
msgContext.setServerSide(true);
SOAPEnvelope envelope = null;
StAXBuilder builder = null;
if (contentType != null) {
if (contentType
.indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
> -1) {
//It is MTOM
builder = selectBuilderForMIME(msgContext, in, contentType);
envelope = (SOAPEnvelope) builder.getDocumentElement();
} else {
Reader reader = new InputStreamReader(in);
XMLStreamReader xmlreader;
//Figure out the char set encoding and create the reader
//If charset is not specified
if ( getCharSetEncoding(contentType) == null ) {
xmlreader =
XMLInputFactory
.newInstance()
.createXMLStreamReader(
in,
MessageContext.DEFAULT_CHAR_SET_ENCODING);
//Set the encoding scheme in the message context
msgContext.setProperty(
MessageContext.CHARACTER_SET_ENCODING,
MessageContext.DEFAULT_CHAR_SET_ENCODING);
} else {
//get the type of char encoding
String charSetEnc = getCharSetEncoding(contentType);
xmlreader =
XMLInputFactory
.newInstance()
.createXMLStreamReader(
in,
charSetEnc);
//Setting the value in msgCtx
msgContext.setProperty(
MessageContext.CHARACTER_SET_ENCODING,
charSetEnc);
}
if (contentType
.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
> -1) {
soap11 = false;
//it is SOAP 1.2
builder =
new StAXSOAPModelBuilder(
xmlreader,
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
envelope = (SOAPEnvelope) builder.getDocumentElement();
} else if (
contentType.indexOf(
SOAP11Constants.SOAP_11_CONTENT_TYPE)
> -1) {
soap11 = true;
//it is SOAP 1.1
// msgContext.getProperty(
// Constants.Configuration.ENABLE_REST);
/**
* Configuration via Deployment
*/
Parameter enable = msgContext.getParameter(Constants.Configuration.ENABLE_REST);
if ((soapActionHeader == null
|| soapActionHeader.length() == 0)
&& enable != null) {
if (Constants.VALUE_TRUE
.equals(enable.getValue())) {
//If the content Type is text/xml (BTW which is the SOAP 1.1 Content type ) and
//the SOAP Action is absent it is rest !!
msgContext.setDoingREST(true);
SOAPFactory soapFactory = new SOAP11Factory();
builder = new StAXOMBuilder(xmlreader);
builder.setOmbuilderFactory(soapFactory);
envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(
builder.getDocumentElement());
}
} else {
builder =
new StAXSOAPModelBuilder(
xmlreader,
SOAP11Constants
.SOAP_ENVELOPE_NAMESPACE_URI);
envelope =
(SOAPEnvelope) builder.getDocumentElement();
}
}
}
}
String charsetEncoding = builder.getDocument().getCharsetEncoding();
if(charsetEncoding != null && !"".equals(charsetEncoding) &&
!((String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING))
.equalsIgnoreCase(charsetEncoding)){
String faultCode;
if(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelope.getNamespace().getName())){