synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r608436 - in /webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp: ClientHandler.java ClientWorker.java
Date Thu, 03 Jan 2008 10:49:33 GMT
Author: asankha
Date: Thu Jan  3 02:49:32 2008
New Revision: 608436

URL: http://svn.apache.org/viewvc?rev=608436&view=rev
Log:
fix SYNAPSE-168 and SYNAPSE-188

Modified:
    webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java
    webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientWorker.java

Modified: webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java?rev=608436&r1=608435&r2=608436&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java
(original)
+++ webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java
Thu Jan  3 02:49:32 2008
@@ -352,6 +352,37 @@
             }
             case HttpStatus.SC_OK : {
                 processResponse(conn, context, response);
+                return;
+            }
+            default : {
+                log.warn("Unexpected HTTP status code received : " +
+                    response.getStatusLine().getStatusCode() + " :: " +
+                    response.getStatusLine().getReasonPhrase());
+
+                Header contentType = response.getFirstHeader(CONTENT_TYPE);
+                if (contentType != null) {
+                    if ((contentType.getValue().indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE)
>= 0) ||
+                     contentType.getValue().indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
>=0) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Received an unexpected response with a SOAP payload");
+                        }
+                    } else if (contentType.getValue().indexOf("html") == -1) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Received an unexpected response with a POX/REST payload");
+                        }
+                    } else {
+                        log.error("Received an unexpected response - of content type : "
+
+                            contentType.getValue() + " and status code : " +
+                            response.getStatusLine().getStatusCode() + " with reason : "
+
+                            response.getStatusLine().getReasonPhrase());
+                    }
+                } else {
+                    log.error("Received an unexpected response - of unknown content type
" +
+                        " with status code : " +
+                        response.getStatusLine().getStatusCode() + " and reason : " +
+                        response.getStatusLine().getReasonPhrase());
+                }
+                processResponse(conn, context, response);
             }
         }
     }

Modified: webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientWorker.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientWorker.java?rev=608436&r1=608435&r2=608436&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientWorker.java
(original)
+++ webservices/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientWorker.java
Thu Jan  3 02:49:32 2008
@@ -27,7 +27,9 @@
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.transport.TransportUtils;
-import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.*;
+import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axiom.om.OMException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpResponse;
@@ -154,10 +156,26 @@
             // question is still under debate and due to the timelines, I am commiting this
             // workaround as Axis2 1.2 is about to be released and Synapse 1.0
             responseMsgCtx.setServerSide(false);
-            envelope = TransportUtils.createSOAPMessage(
+            try {
+                envelope = TransportUtils.createSOAPMessage(
                 responseMsgCtx,
                 in,
                 contentType);
+            } catch (OMException e) {
+                // handle non SOAP and POX/REST payloads (probably text/html)
+                log.error("Unexpected response received", e);
+                SOAPFactory factory = new SOAP11Factory();
+                envelope = factory.getDefaultFaultEnvelope();
+                SOAPFaultDetail detail = factory.createSOAPFaultDetail();
+                detail.setText("Unexpected response received : " + e.getMessage());
+                envelope.getBody().getFault().setDetail(detail);
+                SOAPFaultReason reason = factory.createSOAPFaultReason();
+                reason.setText(this.response.getStatusLine().getReasonPhrase());
+                envelope.getBody().getFault().setReason(reason);
+                SOAPFaultCode code = factory.createSOAPFaultCode();
+                code.setText(Integer.toString(this.response.getStatusLine().getStatusCode()));
+                envelope.getBody().getFault().setCode(code);
+            }
             responseMsgCtx.setServerSide(true);
             responseMsgCtx.setEnvelope(envelope);
 



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org


Mime
View raw message