You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by se...@apache.org on 2008/03/14 22:28:28 UTC

svn commit: r637272 - in /webservices/axis2/trunk/c: include/axis2_msg_ctx.h src/core/context/msg_ctx.c src/core/engine/rest_disp.c

Author: senaka
Date: Fri Mar 14 14:28:27 2008
New Revision: 637272

URL: http://svn.apache.org/viewvc?rev=637272&view=rev
Log:
Adding support for 405 status messages

Modified:
    webservices/axis2/trunk/c/include/axis2_msg_ctx.h
    webservices/axis2/trunk/c/src/core/context/msg_ctx.c
    webservices/axis2/trunk/c/src/core/engine/rest_disp.c

Modified: webservices/axis2/trunk/c/include/axis2_msg_ctx.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_msg_ctx.h?rev=637272&r1=637271&r2=637272&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_msg_ctx.h (original)
+++ webservices/axis2/trunk/c/include/axis2_msg_ctx.h Fri Mar 14 14:28:27 2008
@@ -1447,12 +1447,41 @@
         const axutil_env_t * env);
 
     /**
+     * Sets the list of supported REST HTTP Methods
+     * @param msg_ctx message context
+     * @param env pointer to environment struct
+     * @param supported_rest_http_methods pointer array list containing
+     * the list of HTTP Methods supported. Message context does
+     * assumes the ownership of the array list. Anything added to this
+     * arrary list will be freed by the msg_ctx
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
+    axis2_status_t AXIS2_CALL
+    axis2_msg_ctx_set_supported_rest_http_methods(
+        axis2_msg_ctx_t * msg_ctx,
+        const axutil_env_t * env,
+        axutil_array_list_t * supported_rest_http_methods);
+
+    /**
+     * Gets the list of supported REST HTTP Methods 
+     * @param msg_ctx message context
+     * @param env pointer to environment struct
+     * @return pointer array list containing
+     * the list of HTTP Methods supported. Message context does
+     * assumes the ownership of the array list
+     */
+    axutil_array_list_t *AXIS2_CALL
+    axis2_msg_ctx_get_supported_rest_http_methods(
+        const axis2_msg_ctx_t * msg_ctx,
+        const axutil_env_t * env);
+
+    /**
      * Sets the execution chain to be invoked. The execution chain is a 
      * list of phases containing the handlers to be invoked.
      * @param msg_ctx message context
      * @param env pointer to environment struct
      * @param execution_chain pointer array list containing the list of 
-     * handlers that constitute the execution chain. message context does
+     * handlers that constitute the execution chain. Message context does
      * not assume the ownership of the array list
      * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
      */
@@ -1468,7 +1497,7 @@
      * @param msg_ctx message context
      * @param env pointer to environment struct
      * @return pointer array list containing the list of handlers that 
-     * constitute the execution chain. message context does not assume 
+     * constitute the execution chain. Message context does not assume 
      * the ownership of the array list
      */
     AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL

Modified: webservices/axis2/trunk/c/src/core/context/msg_ctx.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/context/msg_ctx.c?rev=637272&r1=637271&r2=637272&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/context/msg_ctx.c (original)
+++ webservices/axis2/trunk/c/src/core/context/msg_ctx.c Fri Mar 14 14:28:27 2008
@@ -110,6 +110,12 @@
     /** REST HTTP Method */
     axis2_char_t *rest_http_method;
 
+    /** 
+     * Supported REST HTTP Methods
+     * Made use of in a 405 Error Scenario
+     */
+    axutil_array_list_t *supported_rest_http_methods;
+
     /** are we doing MTOM now? */
     axis2_bool_t doing_mtom;
 
@@ -245,6 +251,7 @@
     msg_ctx->paused_handler_name = NULL;
     msg_ctx->soap_action = NULL;
     msg_ctx->rest_http_method = NULL;
+    msg_ctx->supported_rest_http_methods = NULL;
     msg_ctx->doing_mtom = AXIS2_FALSE;
     msg_ctx->doing_rest = AXIS2_FALSE;
     msg_ctx->do_rest_through_post = AXIS2_FALSE;
@@ -422,6 +429,24 @@
         AXIS2_FREE(env->allocator, msg_ctx->auth_type);
     }
 
+    if (msg_ctx->supported_rest_http_methods)
+    {
+        int i = 0;
+        int size = 0;
+
+        size = axutil_array_list_size(msg_ctx->supported_rest_http_methods, env);
+        for (i = 0; i < size; i++)
+        {
+            axis2_char_t *rest_http_method = NULL;
+            rest_http_method = axutil_array_list_get(msg_ctx->supported_rest_http_methods, env, i);
+            if (rest_http_method)
+            {
+                AXIS2_FREE(env->allocator, rest_http_method);
+            }
+        }
+        axutil_array_list_free(msg_ctx->supported_rest_http_methods, env);
+    }
+
     AXIS2_FREE(env->allocator, msg_ctx);
 
     return;
@@ -1838,6 +1863,27 @@
 {
     AXIS2_PARAM_CHECK (env->error, msg_ctx, NULL);
     return msg_ctx->execution_chain;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_supported_rest_http_methods(
+    axis2_msg_ctx_t * msg_ctx,
+    const axutil_env_t * env,
+    axutil_array_list_t * supported_rest_http_methods)
+{
+    AXIS2_PARAM_CHECK (env->error, msg_ctx, AXIS2_FAILURE);
+    msg_ctx->supported_rest_http_methods = supported_rest_http_methods;
+
+    return AXIS2_SUCCESS;
+}
+
+axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_supported_rest_http_methods(
+    const axis2_msg_ctx_t * msg_ctx,
+    const axutil_env_t * env)
+{
+    AXIS2_PARAM_CHECK (env->error, msg_ctx, NULL);
+    return msg_ctx->supported_rest_http_methods;
 }
 
 axis2_status_t AXIS2_CALL

Modified: webservices/axis2/trunk/c/src/core/engine/rest_disp.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/engine/rest_disp.c?rev=637272&r1=637271&r2=637272&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/engine/rest_disp.c (original)
+++ webservices/axis2/trunk/c/src/core/engine/rest_disp.c Fri Mar 14 14:28:27 2008
@@ -27,6 +27,7 @@
 #include <axiom_soap_builder.h>
 #include <axiom_soap_body.h>
 #include <axiom_soap_const.h>
+#include <axis2_http_transport.h>
 
 
 const axis2_char_t *AXIS2_REST_DISP_NAME = "rest_dispatcher";
@@ -209,8 +210,43 @@
                                  axis2_msg_ctx_get_rest_http_method(msg_ctx, env), location,
                                  &param_count, &params);
                         if (op)
+                        {
                             AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                             "Operation found using target endpoint uri fragment");
+                        }
+                        else
+                        {
+                            int i = 0;
+                            int j = 0;
+                            axutil_array_list_t *supported_rest_methods = NULL;
+                            axis2_char_t *rest_methods[] = {AXIS2_HTTP_GET, AXIS2_HTTP_POST,
+                                AXIS2_HTTP_PUT, AXIS2_HTTP_DELETE, AXIS2_HTTP_HEAD};
+                            supported_rest_methods = axutil_array_list_create(env, 0);
+                            for (i = 0; i < 5; i++)
+                            {
+                                if (axutil_strcasecmp(rest_methods[i],
+                                    axis2_msg_ctx_get_rest_http_method(msg_ctx, env)))
+                                {
+                                    if (axis2_rest_disp_get_rest_op_with_method_and_location(svc, env,
+                                        rest_methods[i], location, &param_count, &params))
+                                    {
+                                        for (j = 0; j < param_count; j++)
+                                        {
+                                            AXIS2_FREE (env->allocator, params[j][0]);
+                                            AXIS2_FREE (env->allocator, params[j][1]);
+                                            AXIS2_FREE (env->allocator, params[j]);
+                                        }
+                                        if (params)
+                                        {
+                                            AXIS2_FREE (env->allocator, params);
+                                        }
+                                        axutil_array_list_add(supported_rest_methods, env,
+                                                              axutil_strdup(env, rest_methods[i]));
+                                    }
+                                }
+                            }
+                            axis2_msg_ctx_set_supported_rest_http_methods(msg_ctx, env, supported_rest_methods);
+                        }
                     }
                 }
                 if (url_tokens[0])



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