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 se...@apache.org on 2008/03/20 07:47:35 UTC

svn commit: r639178 - in /webservices/axis2/trunk/c: samples/user_guide/clients/echo_rest.c src/core/clientapi/op_client.c src/core/clientapi/svc_client.c

Author: senaka
Date: Wed Mar 19 23:47:34 2008
New Revision: 639178

URL: http://svn.apache.org/viewvc?rev=639178&view=rev
Log:
Improving Client Side Handling of status codes

Modified:
    webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c
    webservices/axis2/trunk/c/src/core/clientapi/op_client.c
    webservices/axis2/trunk/c/src/core/clientapi/svc_client.c

Modified: webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c?rev=639178&r1=639177&r2=639178&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c (original)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c Wed Mar 19 23:47:34 2008
@@ -167,7 +167,19 @@
     /* Send request */
     ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
 
-    if (ret_node)
+    if (ret_node && 
+        axis2_svc_client_get_last_response_has_fault(svc_client, env))
+    {
+        axis2_char_t *om_str = NULL;
+        om_str = axiom_node_to_string(ret_node, env);
+        if (om_str)
+        {
+            printf("\nReceived OM : %s\n", om_str);
+            AXIS2_FREE(env->allocator, om_str);
+        }
+        printf("\necho client invoke FAILED!\n");
+    }
+    else if (ret_node)
     {
         axis2_char_t *om_str = NULL;
         om_str = axiom_node_to_string(ret_node, env);
@@ -177,6 +189,14 @@
             AXIS2_FREE(env->allocator, om_str);
         }
         printf("\necho client invoke SUCCESSFUL!\n");
+    }
+    else if (method_head &&
+        axis2_svc_client_get_last_response_has_fault(svc_client, env))
+    {
+        /* HEAD request should probably be removed from this file,
+         * and be relocated to transport unit tests.
+         */
+        printf("\necho client invoke FAILED!\n");
     }
     else if (method_head)
     {

Modified: webservices/axis2/trunk/c/src/core/clientapi/op_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/clientapi/op_client.c?rev=639178&r1=639177&r2=639178&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/clientapi/op_client.c (original)
+++ webservices/axis2/trunk/c/src/core/clientapi/op_client.c Wed Mar 19 23:47:34 2008
@@ -1311,8 +1311,18 @@
     }
     if (!(axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_OUT_ONLY)) && response)
     {
+        if (axis2_msg_ctx_get_doing_rest(response, env) &&
+            axis2_msg_ctx_get_status_code (response, env) >= 400)
+        {
+            /* All HTTP 4xx and 5xx status codes are treated as errors */
+            AXIS2_ERROR_SET(env->error,
+                            AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,
+                            AXIS2_FAILURE);
+            return NULL;
+        }
         switch(axis2_msg_ctx_get_status_code (response, env))
         {
+            /* In a SOAP request HTTP status code 500 is used for errors */
             case 500:
                 AXIS2_ERROR_SET(env->error,
                                 AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,

Modified: webservices/axis2/trunk/c/src/core/clientapi/svc_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/clientapi/svc_client.c?rev=639178&r1=639177&r2=639178&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/clientapi/svc_client.c (original)
+++ webservices/axis2/trunk/c/src/core/clientapi/svc_client.c Wed Mar 19 23:47:34 2008
@@ -907,8 +907,9 @@
 
     if (axis2_msg_ctx_get_doing_rest (res_msg_ctx, env))
     {
-        if (axis2_msg_ctx_get_status_code (res_msg_ctx, env) ==
-            AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL)
+        /* All HTTP 4xx and 5xx status codes are treated as errors */
+        if (axis2_msg_ctx_get_status_code (res_msg_ctx, env) >=
+            400)
         {
             svc_client->last_response_has_fault = AXIS2_TRUE;
         }



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