You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2007/05/14 22:08:01 UTC
svn commit: r537967 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport:
TransportUtils.java http/HTTPTransportUtils.java
Author: dims
Date: Mon May 14 13:08:00 2007
New Revision: 537967
URL: http://svn.apache.org/viewvc?view=rev&rev=537967
Log:
break down the big method to smaller ones...i wonder why we were passing null in the second parameter to BuilderUtil.getPOXBuilder always! (so i made it explicit null in case someone runs into this issue. it will be easy to spot)
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?view=diff&rev=537967&r1=537966&r2=537967
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Mon May 14 13:08:00 2007
@@ -93,12 +93,34 @@
* @throws XMLStreamException
* @throws FactoryConfigurationError
*/
- public static SOAPEnvelope createSOAPMessage(MessageContext msgContext, InputStream inStream,
+ public static SOAPEnvelope createSOAPMessage(MessageContext msgContext,
+ InputStream inStream,
String contentType)
throws AxisFault, OMException, XMLStreamException,
FactoryConfigurationError {
+ OMElement documentElement = createDocumentElement(contentType, msgContext, inStream);
+ return createSOAPEnvelope(documentElement);
+ }
+
+ public static SOAPEnvelope createSOAPEnvelope(OMElement documentElement) {
+ SOAPEnvelope envelope;
+ // Check whether we have received a SOAPEnvelope or not
+ if (documentElement instanceof SOAPEnvelope) {
+ envelope = (SOAPEnvelope) documentElement;
+ } else {
+ // If it is not a SOAPEnvelope we wrap that with a fake
+ // SOAPEnvelope.
+ SOAPFactory soapFactory = new SOAP11Factory();
+ envelope = soapFactory.getDefaultEnvelope();
+ envelope.getBody().addChild(documentElement);
+ }
+ return envelope;
+ }
+
+ public static OMElement createDocumentElement(String contentType,
+ MessageContext msgContext,
+ InputStream inStream) throws AxisFault, XMLStreamException {
OMElement documentElement = null;
- String charsetEncoding = null;
if (contentType != null) {
String type;
int index = contentType.indexOf(';');
@@ -108,7 +130,7 @@
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.
+ // application/xml if its a REST response, if not it will try to use the SOAPMessageBuilder.
if (HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(type)) {
if (msgContext.isServerSide()) {
if (msgContext.getSoapAction() == null) {
@@ -126,7 +148,7 @@
}
if (documentElement == null) {
if (msgContext.isDoingREST()) {
- StAXBuilder builder = BuilderUtil.getPOXBuilder(inStream, charsetEncoding);
+ StAXBuilder builder = BuilderUtil.getPOXBuilder(inStream, null);
documentElement = builder.getDocumentElement();
} else {
// FIXME making soap defualt for the moment..might effect the
@@ -135,22 +157,9 @@
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
StAXBuilder builder = BuilderUtil.getSOAPBuilder(inStream, charSetEnc);
documentElement = builder.getDocumentElement();
- charsetEncoding = builder.getDocument().getCharsetEncoding();
}
}
-
- SOAPEnvelope envelope;
- // Check whether we have received a SOAPEnvelope or not
- if (documentElement instanceof SOAPEnvelope) {
- envelope = (SOAPEnvelope) documentElement;
- } else {
- // If it is not a SOAPEnvelope we wrap that with a fake
- // SOAPEnvelope.
- SOAPFactory soapFactory = new SOAP11Factory();
- envelope = soapFactory.getDefaultEnvelope();
- envelope.getBody().addChild(documentElement);
- }
- return envelope;
+ return documentElement;
}
/**
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?view=diff&rev=537967&r1=537966&r2=537967
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Mon May 14 13:08:00 2007
@@ -209,73 +209,24 @@
public static InvocationResponse processHTTPPostRequest(MessageContext msgContext,
InputStream in,
- OutputStream out, String contentType,
+ OutputStream out,
+ String contentType,
String soapActionHeader,
String requestURI)
throws AxisFault {
int soapVersion = VERSION_UNKNOWN;
- InvocationResponse pi;
-
try {
-
- in = handleGZip(msgContext, in);
-
- // remove the starting and trailing " from the SOAP Action
- if ((soapActionHeader != null) && soapActionHeader.charAt(0) == '\"'
- && soapActionHeader.endsWith("\"")) {
- soapActionHeader = soapActionHeader.substring(1, soapActionHeader.length() - 1);
- }
-
- // fill up the Message Contexts
- msgContext.setSoapAction(soapActionHeader);
- msgContext.setTo(new EndpointReference(requestURI));
+ soapVersion = initializeMessageContext(msgContext, soapActionHeader, requestURI, contentType);
msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
- msgContext.setServerSide(true);
-
- SOAPEnvelope envelope;
- // get the type of char encoding
- String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
- if (charSetEnc == null) {
- charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
- }
- msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
+ msgContext.setEnvelope(
+ TransportUtils.createSOAPMessage(
+ msgContext,
+ handleGZip(msgContext, in),
+ contentType));
- if (contentType != null) {
- if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
- soapVersion = VERSION_SOAP12;
- TransportUtils.processContentTypeForAction(contentType, msgContext);
- } else if (contentType
- .indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
- soapVersion = VERSION_SOAP11;
- } else if (isRESTRequest(contentType)) {
- // If REST, construct a SOAP11 envelope to hold the rest message and
- // indicate that this is a REST message.
- soapVersion = VERSION_SOAP11;
- msgContext.setDoingREST(true);
- }
- if (soapVersion == VERSION_SOAP11) {
- // TODO Keith : Do we need this anymore
- // Deployment configuration parameter
- Parameter enableREST = msgContext
- .getParameter(Constants.Configuration.ENABLE_REST);
- if ((soapActionHeader == null) && (enableREST != null)) {
- if (Constants.VALUE_TRUE.equals(enableREST.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);
- }
- }
- }
- }
- envelope = TransportUtils.createSOAPMessage(msgContext, in, contentType);
- msgContext.setEnvelope(envelope);
AxisEngine engine = new AxisEngine(msgContext.getConfigurationContext());
-
- pi = engine.receive(msgContext);
-
- return pi;
+ return engine.receive(msgContext);
} catch (SOAPProcessingException e) {
throw AxisFault.makeFault(e);
} catch (AxisFault e) {
@@ -293,6 +244,60 @@
msgContext.setEnvelope(new SOAP12Factory().getDefaultEnvelope());
}
}
+ }
+
+ public static int initializeMessageContext(MessageContext msgContext,
+ String soapActionHeader,
+ String requestURI,
+ String contentType) {
+ int soapVersion = VERSION_UNKNOWN;
+ // remove the starting and trailing " from the SOAP Action
+ if ((soapActionHeader != null) && soapActionHeader.charAt(0) == '\"'
+ && soapActionHeader.endsWith("\"")) {
+ soapActionHeader = soapActionHeader.substring(1, soapActionHeader.length() - 1);
+ }
+
+ // fill up the Message Contexts
+ msgContext.setSoapAction(soapActionHeader);
+ msgContext.setTo(new EndpointReference(requestURI));
+ msgContext.setServerSide(true);
+
+ // get the type of char encoding
+ String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
+ if (charSetEnc == null) {
+ charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+ }
+ msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
+
+ if (contentType != null) {
+ if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
+ soapVersion = VERSION_SOAP12;
+ TransportUtils.processContentTypeForAction(contentType, msgContext);
+ } else if (contentType
+ .indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
+ soapVersion = VERSION_SOAP11;
+ } else if (isRESTRequest(contentType)) {
+ // If REST, construct a SOAP11 envelope to hold the rest message and
+ // indicate that this is a REST message.
+ soapVersion = VERSION_SOAP11;
+ msgContext.setDoingREST(true);
+ }
+ if (soapVersion == VERSION_SOAP11) {
+ // TODO Keith : Do we need this anymore
+ // Deployment configuration parameter
+ Parameter enableREST = msgContext
+ .getParameter(Constants.Configuration.ENABLE_REST);
+ if ((soapActionHeader == null) && (enableREST != null)) {
+ if (Constants.VALUE_TRUE.equals(enableREST.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);
+ }
+ }
+ }
+ }
+ return soapVersion;
}
public static InputStream handleGZip(MessageContext msgContext, InputStream in)
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org