Author: midon
Date: Mon Jul 14 17:15:51 2008
New Revision: 676775

URL: http://svn.apache.org/viewvc?rev=676775&view=rev
Log:
202/204 should not fail even if a part is mapped to the response body

Modified:
    
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
    
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
    
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
    
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java

Modified: 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java?rev=676775&r1=676774&r2=676775&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
 Mon Jul 14 17:15:51 2008
@@ -64,7 +64,7 @@
         handlerColl = new ContextHandlerCollection();
         Handler[] handlers = {arithmeticsContext, blogContext};
         handlerColl.setHandlers(handlers);
-        
+
         server.addHandler(handlerColl);
     }
 
@@ -206,14 +206,14 @@
                                 int left = 
Integer.valueOf(DOMUtils.getTextContent(firstOperand));
                                 int right = 
Integer.valueOf(DOMUtils.getTextContent(secondOperand));
 
-                                int min = Math.min(left,right);
-                                int max = Math.max(left,right);
+                                int min = Math.min(left, right);
+                                int max = Math.max(left, right);
 //                                Element arrayElt = 
bodyDoc.createElement("sumOfInteger");
                                 Element anElt = 
bodyDoc.createElementNS("http://ode/bpel/test/arithmetics";, "sumOfInteger");
                                 Element msg = 
bodyDoc.createElement("theresult");
                                 Element resultIs = 
bodyDoc.createElement("resultIs");
                                 msg.setTextContent("A dummy message we don't 
care about. Only purpose is to have a complex type");
-                                
resultIs.setTextContent(String.valueOf((max*(max+1)-min*(min+1))/2));
+                                resultIs.setTextContent(String.valueOf((max * 
(max + 1) - min * (min + 1)) / 2));
 
                                 anElt.appendChild(msg);
                                 anElt.appendChild(resultIs);
@@ -280,6 +280,11 @@
 
                 
response.getOutputStream().print(DOMUtils.domToString(articleEl));
                 response.setStatus(200);
+            } else if ("200_missing_body".equals(faultType)) {
+                response.setHeader("TimestampHeader", 
request.getHeader("TimestampHeader"));
+                response.setHeader("From", request.getHeader("From"));
+
+                response.setStatus(200);
             } else if ("200_malformed_body".equals(faultType)) {
                 // parts to http headers, just send them back and let the 
caller check the received values
                 response.setHeader("TimestampHeader", 
request.getHeader("TimestampHeader"));
@@ -288,6 +293,11 @@
                 response.setContentType("text/xml");
                 response.getOutputStream().print("<book><abstract>Lorem ipsum 
dolor sit amet, consectetuer adipiscing elit.</abstract>");
                 response.setStatus(200);
+            } else if ("202_empty_body".equals(faultType) || 
"204_empty_body".equals(faultType)) {
+                response.setHeader("TimestampHeader", 
request.getHeader("TimestampHeader"));
+                response.setHeader("From", request.getHeader("From"));
+
+                response.setStatus(Integer.parseInt(faultType.substring(0, 
3)));
             } else {
                 // some parts are bound to http headers
                 //  just send them back and let the caller check the received 
values

Modified: 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel?rev=676775&r1=676774&r2=676775&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
 Mon Jul 14 17:15:51 2008
@@ -228,6 +228,80 @@
         </scope>
 
         <!-- ############################################### -->
+        <!-- 200_missing_body - failure expected  -->
+        <!-- ############################################### -->
+        <scope>
+            <ext:failureHandling>
+                <ext:faultOnFailure>true</ext:faultOnFailure>
+            </ext:failureHandling>
+            <faultHandlers>
+                <catch faultName="ext:activityFailure">
+                    <!-- expected result-->
+                    <!--
+                    Warning #1!! At this point what we know for sure is that a 
failure occured
+                    but we don't know which failure exactly.
+                    We would like to test if the the failure is really the one 
we triggered on purpose and not a TimeoutFailure for instance.
+                    -->
+                    <empty/>
+                </catch>
+            </faultHandlers>
+            <sequence>
+                <assign>
+                    <copy>
+                        <from>'200_missing_body'</from>
+                        <to variable="idMsg" header="Fault-Type"/>
+                    </copy>
+                </assign>
+                <invoke partnerLink="blogPartnerLink" 
portType="dummy:BlogPortType"
+                        operation="doGET" inputVariable="idMsg" 
outputVariable="articleMsg"/>
+                <assign>
+                    <copy>
+                        <from>'200_missing_body: A failure should have been 
thrown'</from>
+                        <to>$outputVar.TestPart</to>
+                    </copy>
+                </assign>
+                <reply name="end" partnerLink="helloPartnerLink" 
portType="test:HelloPortType"
+                       operation="hello" variable="outputVar"/>
+            </sequence>
+        </scope>
+
+        <!-- ############################################### -->
+        <!-- 202_empty_body - Should pass -->
+        <!-- ############################################### -->
+        <!-- 202/Accepted status code explicitly states that there is no body,
+                so we should not fail even if a part is bound to the body 
response -->
+        <scope>
+            <sequence>
+                <assign>
+                    <copy>
+                        <from>'202_empty_body'</from>
+                        <to variable="idMsg" header="Fault-Type"/>
+                    </copy>
+                </assign>
+                <invoke partnerLink="blogPartnerLink" 
portType="dummy:BlogPortType"
+                        operation="doGET" inputVariable="idMsg" 
outputVariable="articleMsg"/>
+            </sequence>
+        </scope>
+
+        <!-- ############################################### -->
+        <!-- 204_empty_body - Should pass -->
+        <!-- ############################################### -->
+        <!-- 204/No Content status code explicitly states that there is no 
body, 
+                so we should not fail even if a part is bound to the body 
response -->
+        <scope>
+            <sequence>
+                <assign>
+                    <copy>
+                        <from>'204_empty_body'</from>
+                        <to variable="idMsg" header="Fault-Type"/>
+                    </copy>
+                </assign>
+                <invoke partnerLink="blogPartnerLink" 
portType="dummy:BlogPortType"
+                        operation="doGET" inputVariable="idMsg" 
outputVariable="articleMsg"/>
+            </sequence>
+        </scope>
+
+        <!-- ############################################### -->
         <!-- 200_missing_part_in_header - failure expected  -->
         <!-- ############################################### -->
         <scope>

Modified: 
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java?rev=676775&r1=676774&r2=676775&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
 Mon Jul 14 17:15:51 2008
@@ -395,6 +395,7 @@
         }
 
         private void _3xx_redirection() throws IOException {
+            // redirections should be handled transparently by http-client
             replyWithFailure("Redirections disabled! HTTP Status-Line: " + 
method.getStatusLine() + " for " + method.getURI());
         }
 
@@ -419,9 +420,12 @@
 
             // assumption is made that a response may have at most one body. 
HttpBindingValidator checks this.
             MIMEContent outputContent = 
WsdlUtils.getMimeContent(opBinding.getBindingOutput().getExtensibilityElements());
+            int statusCode = method.getStatusCode();
+
             boolean xmlExpected = outputContent != null && 
HttpHelper.isXml(outputContent.getType());
+            // '202/Accepted' and '204/No Content' status codes explicitly 
state that there is no body, so we should not fail even if a part is bound to 
the body response 
             boolean isBodyExpected = outputContent != null;
-            boolean isBodyMandatory = isBodyExpected && xmlExpected;
+            boolean isBodyMandatory = isBodyExpected && statusCode!=204 && 
statusCode!=202;
             final String body;
             try {
                 body = method.getResponseBodyAsString();

Modified: 
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java?rev=676775&r1=676774&r2=676775&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
 Mon Jul 14 17:15:51 2008
@@ -364,6 +364,8 @@
      * For each of them, set the header value as the value of the message part.
      * <p/>
      * Then add all HTTP headers as header part in the message. The name of 
the header would be the part name.
+     * <p/>
+     * Finally, insert a header names 'Status-Line'. This header contains an 
element as returned by [EMAIL PROTECTED] 
HttpHelper#statusLineToElement(String)} .
      *
      * @param odeMessage
      * @param method


Reply via email to