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 sa...@apache.org on 2007/04/09 09:12:54 UTC

svn commit: r526663 - in /webservices/axis2/trunk/c: include/ modules/core/clientapi/ modules/core/transport/http/common/ modules/core/transport/http/sender/ modules/core/transport/http/sender/libcurl/ modules/core/transport/http/util/ samples/client/y...

Author: samisa
Date: Mon Apr  9 00:12:53 2007
New Revision: 526663

URL: http://svn.apache.org/viewvc?view=rev&rev=526663
Log:
Improved client API to make it more user friendly in case of using REST

Modified:
    webservices/axis2/trunk/c/include/axis2_http_transport.h
    webservices/axis2/trunk/c/include/axis2_options.h
    webservices/axis2/trunk/c/modules/core/clientapi/options.c
    webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c
    webservices/axis2/trunk/c/modules/core/transport/http/util/http_transport_utils.c
    webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c
    webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c

Modified: webservices/axis2/trunk/c/include/axis2_http_transport.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_transport.h?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport.h Mon Apr  9 00:12:53 2007
@@ -110,12 +110,12 @@
 /**
  * HEADER_POST
  */
-#define AXIS2_HTTP_HEADER_POST  "POST"
+#define AXIS2_HTTP_POST  "POST"
 
 /**
  * HEADER_GET
  */
-#define AXIS2_HTTP_HEADER_GET "GET"
+#define AXIS2_HTTP_GET "GET"
 
 /**
  * HEADER_HOST

Modified: webservices/axis2/trunk/c/include/axis2_options.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_options.h?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_options.h (original)
+++ webservices/axis2/trunk/c/include/axis2_options.h Mon Apr  9 00:12:53 2007
@@ -657,6 +657,32 @@
         const axutil_env_t *env);
 
     /**
+     * Sets the bool value indicating whether to enable REST or not.
+     * @param options pointer to options struct
+     * @param env pointer to environment struct
+     * @param enable_rest bool value indicating whether to enable REST 
+     * or not, AXIS2_TRUE to enable, AXIS2_FALSE to disable
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_options_set_enable_rest(axis2_options_t *options,
+        const axutil_env_t *env,
+        const axis2_bool_t enable_rest);
+
+    /**
+     * Sets the HTTP method to be used
+     * @param options pointer to options struct
+     * @param env pointer to environment struct
+     * @param http_method string representing HTTP method to use, 
+     * can be either AXIS2_HTTP_GET or AXIS2_HTTP_POST
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_options_set_http_method(axis2_options_t *options,
+        const axutil_env_t *env,
+        const axis2_char_t *http_method);
+
+    /**
      * Creates the options struct.
      * @param env pointer to environment struct
      * @return a pointer to newly created options struct, or NULL on error 

Modified: webservices/axis2/trunk/c/modules/core/clientapi/options.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/clientapi/options.c?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/modules/core/clientapi/options.c (original)
+++ webservices/axis2/trunk/c/modules/core/clientapi/options.c Mon Apr  9 00:12:53 2007
@@ -22,6 +22,7 @@
 #include <axiom_soap_const.h>
 #include <axis2_msg_info_headers.h>
 #include <axutil_array_list.h>
+#include <axis2_http_transport.h>
 
 struct axis2_options
 {
@@ -792,8 +793,6 @@
 axis2_options_get_soap_action(const axis2_options_t *options,
     const axutil_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-
     return options->soap_action;
 }
 
@@ -834,7 +833,43 @@
     return AXIS2_SUCCESS;
 }
 
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_options_set_enable_rest(axis2_options_t *options,
+    const axutil_env_t *env,
+    const axis2_bool_t enable_rest)
+{
+    axutil_property_t *rest_property = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+    if (enable_rest)
+    {
+        rest_property = axutil_property_create(env);
+        axutil_property_set_value(rest_property, env, axutil_strdup (env, AXIS2_VALUE_TRUE));
+        axis2_options_set_property(options, env, AXIS2_ENABLE_REST,
+            rest_property);
+    }
+    else
+    {
+        rest_property = axutil_property_create(env);
+        axutil_property_set_value(rest_property, env, axutil_strdup (env, AXIS2_VALUE_FALSE));
+        axis2_options_set_property(options, env, AXIS2_ENABLE_REST,
+            rest_property);
+    }
+    return AXIS2_SUCCESS;
+}
 
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_options_set_http_method(axis2_options_t *options,
+    const axutil_env_t *env,
+    const axis2_char_t *http_method)
+{
+    axutil_property_t *method_property = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
 
-
+    method_property = axutil_property_create(env);
+    axutil_property_set_value(method_property, env, axutil_strdup(env, http_method));
+    axis2_options_set_property(options, env, AXIS2_HTTP_METHOD,
+            method_property);
+    return AXIS2_SUCCESS;
+}
 

Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c Mon Apr  9 00:12:53 2007
@@ -169,7 +169,7 @@
     {
         if (0 == axutil_strcasecmp(axis2_http_request_line_get_method(
                     axis2_http_simple_request_get_request_line(
-                        simple_request, env), env), AXIS2_HTTP_HEADER_POST))
+                        simple_request, env), env), AXIS2_HTTP_POST))
         {
             axis2_http_simple_response_set_status_line(response, env,
                     http_version, 411, "Length Required");
@@ -246,7 +246,7 @@
     }
     if (0 == axutil_strcasecmp(axis2_http_request_line_get_method(
                 axis2_http_simple_request_get_request_line(
-                    simple_request, env), env), AXIS2_HTTP_HEADER_GET))
+                    simple_request, env), env), AXIS2_HTTP_GET))
     {
         processed = axis2_http_transport_utils_process_http_get_request
                 (env, msg_ctx, request_body, out_stream,
@@ -294,7 +294,7 @@
     }
     else if (0 == axutil_strcasecmp(axis2_http_request_line_get_method(
                 axis2_http_simple_request_get_request_line(
-                    simple_request, env), env), AXIS2_HTTP_HEADER_POST))
+                    simple_request, env), env), AXIS2_HTTP_POST))
     {
         status = axis2_http_transport_utils_process_http_post_request
                 (env, msg_ctx, request_body, out_stream,

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_sender.c?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_sender.c Mon Apr  9 00:12:53 2007
@@ -210,7 +210,7 @@
 			method_value = (axis2_char_t *) axutil_property_get_value (method, env);
 
 		/* The default is POST */
-		if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_HEADER_GET))
+		if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_GET))
 		{
 			send_via_get = AXIS2_TRUE;
 		}

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/libcurl/axis2_libcurl.c Mon Apr  9 00:12:53 2007
@@ -134,7 +134,7 @@
 			method_value = (axis2_char_t *) axutil_property_get_value (method, env);
         }
 		/* The default is POST */
-		if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_HEADER_GET))
+		if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_GET))
 		{
 			send_via_get = AXIS2_TRUE;
 		}

Modified: webservices/axis2/trunk/c/modules/core/transport/http/util/http_transport_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/util/http_transport_utils.c?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/util/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/util/http_transport_utils.c Mon Apr  9 00:12:53 2007
@@ -555,7 +555,7 @@
     op =  axis2_msg_ctx_get_op(msg_ctx, env);
 
     soap_envelope = axis2_http_transport_utils_handle_media_type_url_encoded(
-                env, msg_ctx, request_params, AXIS2_HTTP_HEADER_GET);
+                env, msg_ctx, request_params, AXIS2_HTTP_GET);
     if (! soap_envelope)
     {
         return AXIS2_FALSE;
@@ -1438,8 +1438,8 @@
         body_child = axiom_element_create_with_qname(env, NULL, bfc_qname,
                 &body_child_node);
         axiom_soap_body_add_child(soap_body, env, body_child_node);
-        if (0 == axutil_strcmp(method, AXIS2_HTTP_HEADER_GET) ||
-                0 == axutil_strcmp(method, AXIS2_HTTP_HEADER_POST))
+        if (0 == axutil_strcmp(method, AXIS2_HTTP_GET) ||
+                0 == axutil_strcmp(method, AXIS2_HTTP_POST))
         {
             xml_schema_type_t *schema_type = NULL;
             schema_type = XML_SCHEMA_ELEMENT_GET_SCHEMA_TYPE(schema_element,

Modified: webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c (original)
+++ webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c Mon Apr  9 00:12:53 2007
@@ -42,8 +42,6 @@
     axis2_svc_client_t* svc_client = NULL;
     axiom_node_t *payload = NULL;
     axiom_node_t *ret_node = NULL;
-    axutil_property_t *rest_property = NULL;
-	axutil_property_t *get_property = NULL;
 	axis2_char_t *search_string = NULL;
 
 	if (argc > 1)
@@ -67,13 +65,8 @@
     options = axis2_options_create(env);
     axis2_options_set_to(options, env, endpoint_ref);
 
-    rest_property = axutil_property_create(env);
-    axutil_property_set_value(rest_property, env, axutil_strdup (env, AXIS2_VALUE_TRUE));
-    axis2_options_set_property(options, env, AXIS2_ENABLE_REST,
-            rest_property);
-	get_property = axutil_property_create(env);
-	axutil_property_set_value(get_property, env, axutil_strdup(env, AXIS2_HTTP_HEADER_GET));
-	axis2_options_set_property(options, env, AXIS2_HTTP_METHOD, get_property);
+    axis2_options_set_enable_rest(options, env, AXIS2_TRUE);
+    axis2_options_set_http_method(options, env, AXIS2_HTTP_GET);
 
     client_home = AXIS2_GETENV("AXIS2C_HOME");
     if (!client_home || !strcmp (client_home, ""))

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?view=diff&rev=526663&r1=526662&r2=526663
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c (original)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/echo_rest.c Mon Apr  9 00:12:53 2007
@@ -32,8 +32,6 @@
     axiom_node_t *payload = NULL;
     axiom_node_t *ret_node = NULL;
     axis2_bool_t method_get = AXIS2_FALSE;
-    axutil_property_t *rest_property = NULL;
-	axutil_property_t *get_property = NULL;
 
     /* Set up the environment */
     env = axutil_env_create_all("echo_rest.log", AXIS2_LOG_LEVEL_TRACE);
@@ -80,16 +78,11 @@
     options = axis2_options_create(env);
     axis2_options_set_to(options, env, endpoint_ref);
     /* Enable REST at the client side */
-    rest_property = axutil_property_create(env);
-    axutil_property_set_value(rest_property, env, axutil_strdup (env, AXIS2_VALUE_TRUE));
-    axis2_options_set_property(options, env, AXIS2_ENABLE_REST,
-            rest_property);
+    axis2_options_set_enable_rest(options, env, AXIS2_TRUE);
+
     if (AXIS2_TRUE == method_get)
     {
-        get_property = axutil_property_create(env);
-        axutil_property_set_value(get_property, env, axutil_strdup(env, AXIS2_HTTP_HEADER_GET));
-         axis2_options_set_property(options, env, AXIS2_HTTP_METHOD,
-                get_property);
+        axis2_options_set_http_method(options, env, AXIS2_HTTP_GET);
     }
     /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
      * using the axis2.xml file.



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