You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2008/07/15 02:24:35 UTC

svn commit: r676777 - in /ode/trunk: axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ axis2-war/src/test/resources/TestHttpBindingExt_GET/ axis2/src/main/java/org/apache/ode/axis2/httpbinding/

Author: midon
Date: Mon Jul 14 17:24:35 2008
New Revision: 676777

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

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

Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java?rev=676777&r1=676776&r2=676777&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java Mon Jul 14 17:24:35 2008
@@ -271,6 +271,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"));
@@ -279,6 +284,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/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel?rev=676777&r1=676776&r2=676777&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel Mon Jul 14 17:24:35 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/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java?rev=676777&r1=676776&r2=676777&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java Mon Jul 14 17:24:35 2008
@@ -362,6 +362,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());
         }
 
@@ -384,9 +385,13 @@
 
             // 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 {

Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java?rev=676777&r1=676776&r2=676777&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java Mon Jul 14 17:24:35 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 {@link HttpHelper#statusLineToElement(String)} .
      *
      * @param odeMessage
      * @param method