Author: amilas Date: Sat Apr 17 04:49:56 2010 New Revision: 935124 URL: http://svn.apache.org/viewvc?rev=935124&view=rev Log: set the message type for empty envelops
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/RESTUtil.java Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?rev=935124&r1=935123&r2=935124&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original) +++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Sat Apr 17 04:49:56 2010 @@ -169,27 +169,7 @@ public class TransportUtils { OMElement documentElement = null; String type = null; if (contentType != null) { - int index = contentType.indexOf(';'); - if (index > 0) { - type = contentType.substring(0, index); - } else { - type = contentType; - } - // Some services send REST responces as text/xml. We should convert it to - // application/xml if its a REST response, if not it will try to use the SOAPMessageBuilder. - // isDoingREST should already be properly set by HTTPTransportUtils.initializeMessageContext - if (msgContext.isDoingREST() && HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type)) { -// if (HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type)) { - if (msgContext.isServerSide()) { - if (msgContext.getSoapAction() == null) { - type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML; - } -// } else if (msgContext.isDoingREST() && -// !msgContext.isPropertyTrue(Constants.Configuration.SOAP_RESPONSE_MEP)) { - } else if (!msgContext.isPropertyTrue(Constants.Configuration.SOAP_RESPONSE_MEP)) { - type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML; - } - } + type = getContentType(contentType, msgContext); Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext); if (builder != null) { if (log.isDebugEnabled()) { @@ -221,6 +201,29 @@ public class TransportUtils { return documentElement; } + public static String getContentType(String contentType, MessageContext msgContext) { + String type; + int index = contentType.indexOf(';'); + if (index > 0) { + type = contentType.substring(0, index); + } else { + type = contentType; + } + // Some services send REST responces as text/xml. We should convert it to + // application/xml if its a REST response, if not it will try to use the SOAPMessageBuilder. + // isDoingREST should already be properly set by HTTPTransportUtils.initializeMessageContext + if (msgContext.isDoingREST() && HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type)) { + if (msgContext.isServerSide()) { + if (msgContext.getSoapAction() == null) { + type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML; + } + } else if (!msgContext.isPropertyTrue(Constants.Configuration.SOAP_RESPONSE_MEP)) { + type = HTTPConstants.MEDIA_TYPE_APPLICATION_XML; + } + } + return type; + } + /** * Extracts and returns the character set encoding from the * Content-type header Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/RESTUtil.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/RESTUtil.java?rev=935124&r1=935123&r2=935124&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/RESTUtil.java (original) +++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/util/RESTUtil.java Sat Apr 17 04:49:56 2010 @@ -110,6 +110,7 @@ public class RESTUtil { SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); + msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, TransportUtils.getContentType(contentType, msgContext)); } else { try { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, null, contentType);