axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r387144 - in /webservices/axis2/trunk/c/samples/server/echo: echo.c echo.h echo_skeleton.c
Date Mon, 20 Mar 2006 06:03:01 GMT
Author: samisa
Date: Sun Mar 19 22:02:59 2006
New Revision: 387144

URL: http://svn.apache.org/viewcvs?rev=387144&view=rev
Log:
Added comments to explain the flow for user guide and removed code that has been commented
out

Modified:
    webservices/axis2/trunk/c/samples/server/echo/echo.c
    webservices/axis2/trunk/c/samples/server/echo/echo.h
    webservices/axis2/trunk/c/samples/server/echo/echo_skeleton.c

Modified: webservices/axis2/trunk/c/samples/server/echo/echo.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/server/echo/echo.c?rev=387144&r1=387143&r2=387144&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/echo/echo.c (original)
+++ webservices/axis2/trunk/c/samples/server/echo/echo.c Sun Mar 19 22:02:59 2006
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 #include "echo.h"
-#include <axis2_om_element.h>
 #include <stdio.h>
 
 axis2_om_node_t *
@@ -28,8 +27,13 @@
     axis2_om_node_t *ret_node = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
-    
-    if (!node)
+   
+    /* Expected request format is :-
+     * <ns1:echoString xmlns:ns1="http://localhost:9090/axis2/services/echo">
+     *      <text>echo5</text>
+     * </ns1:echoString>
+     */
+    if (!node) /* 'echoString' node */
     {
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, AXIS2_FAILURE);
         printf("Echo client ERROR: input parameter NULL\n");
@@ -37,7 +41,7 @@
     }
 
     text_parent_node = AXIS2_OM_NODE_GET_FIRST_CHILD(node, env);
-    if (!text_parent_node)
+    if (!text_parent_node) /* 'text' node */
     {
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
         printf("Echo client ERROR: invalid XML in request\n");
@@ -45,7 +49,7 @@
     }
     
     text_node = AXIS2_OM_NODE_GET_FIRST_CHILD(text_parent_node, env);
-    if (!text_node)
+    if (!text_node) /* actual text to echo */
     {
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
         printf("Echo client ERROR: invalid XML in request\n");
@@ -72,6 +76,7 @@
     return ret_node;
 }
 
+/* Builds the response content */
 axis2_om_node_t *
 build_om_programatically(axis2_env_t **env, axis2_char_t *text)
 {
@@ -81,11 +86,6 @@
     axis2_om_element_t * text_om_ele = NULL;
     axis2_om_namespace_t *ns1 = NULL;
     
-    /*
-    axis2_xml_writer_t *xml_writer = NULL;
-    axis2_om_output_t *om_output = NULL;
-    axis2_char_t *buffer = NULL;
-    */
     ns1 = axis2_om_namespace_create (env, "http://localhost:9090/axis2/services/echo", "ns1");
 
     echo_om_ele = axis2_om_element_create(env, NULL, "echoString", ns1, &echo_om_node);
@@ -94,17 +94,6 @@
 
     AXIS2_OM_ELEMENT_SET_TEXT(text_om_ele, env, text, text_om_node);
     
-    /*
-    xml_writer = axis2_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE);
-    om_output = axis2_om_output_create( env, xml_writer);
-    
-    AXIS2_OM_NODE_SERIALIZE(echo_om_node, env, om_output);
-    buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);         
-    printf("\nSending OM node in XML : %s \n",  buffer); 
-
-    AXIS2_OM_OUTPUT_FREE(om_output, env);
-    AXIS2_FREE((*env)->allocator, buffer);
-    */
     return echo_om_node;
 }
 

Modified: webservices/axis2/trunk/c/samples/server/echo/echo.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/server/echo/echo.h?rev=387144&r1=387143&r2=387144&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/echo/echo.h (original)
+++ webservices/axis2/trunk/c/samples/server/echo/echo.h Sun Mar 19 22:02:59 2006
@@ -22,6 +22,7 @@
 #include <axis2_error_default.h>
 #include <axis2_om_text.h>
 #include <axis2_om_node.h>
+#include <axis2_om_element.h>
 
 axis2_om_node_t *axis2_echo_echo(axis2_env_t **env, axis2_om_node_t *node);
 

Modified: webservices/axis2/trunk/c/samples/server/echo/echo_skeleton.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/server/echo/echo_skeleton.c?rev=387144&r1=387143&r2=387144&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/echo/echo_skeleton.c (original)
+++ webservices/axis2/trunk/c/samples/server/echo/echo_skeleton.c Sun Mar 19 22:02:59 2006
@@ -38,89 +38,118 @@
 echo_init(axis2_svc_skeleton_t *svc_skeleton,
           axis2_env_t **env);
 
+axis2_om_node_t* AXIS2_CALL
+echo_on_fault(axis2_svc_skeleton_t *svc_skeli, 
+              axis2_env_t **env, axis2_om_node_t *node);
 
+/*Create function */
 axis2_svc_skeleton_t *
 axis2_echo_create(axis2_env_t **env)
 {
     axis2_svc_skeleton_t *svc_skeleton = NULL;
+    /* Allocate memory for the structs */
     svc_skeleton = AXIS2_MALLOC((*env)->allocator, 
         sizeof(axis2_svc_skeleton_t));
 
-    
     svc_skeleton->ops = AXIS2_MALLOC(
         (*env)->allocator, sizeof(axis2_svc_skeleton_ops_t));
 
+    /* Assign function pointers */
     svc_skeleton->ops->free = echo_free;
     svc_skeleton->ops->init = echo_init;
     svc_skeleton->ops->invoke = echo_invoke;
-    /*svc_skeleton->ops->on_fault = echo_on_fault;*/
+    svc_skeleton->ops->on_fault = echo_on_fault;
 
     return svc_skeleton;
 }
 
+/* Initialize the service */
 int AXIS2_CALL
 echo_init(axis2_svc_skeleton_t *svc_skeleton,
                         axis2_env_t **env)
 {
     svc_skeleton->func_array = axis2_array_list_create(env, 0);
+    /* Add the implemented operation names of the service to  
+     * the array list of functions 
+     */
     AXIS2_ARRAY_LIST_ADD(svc_skeleton->func_array, env, "echoString");
-
-    /* Any initialization stuff of echo goes here */
+    /* Any initialization stuff of echo service should go here */
     return AXIS2_SUCCESS;
 }
 
+/*
+ * This method invokes the right service method 
+ */
+axis2_om_node_t* AXIS2_CALL
+echo_invoke(axis2_svc_skeleton_t *svc_skeleton,
+            axis2_env_t **env,
+            axis2_om_node_t *node)
+{
+    /* Invoke the business logic.
+     * Depending on the function name invoke the correct impl method.
+     * We have only echo in this sample, hence invoke echo method.
+     * To see how to deal with multiple impl methods, have a look at the
+     * math sample.
+     */
+    return axis2_echo_echo(env, node);
+}
+
+/* On fault, handle the fault */
+axis2_om_node_t* AXIS2_CALL
+echo_on_fault(axis2_svc_skeleton_t *svc_skeli, 
+              axis2_env_t **env, axis2_om_node_t *node)
+{
+   /* Here we are just setting a simple error message inside an element 
+    * called 'EchoServiceError' 
+    */
+    axis2_om_node_t *error_node = NULL;
+    axis2_om_node_t* text_node = NULL;
+    axis2_om_element_t *error_ele = NULL;
+    error_ele = axis2_om_element_create(env, node, "EchoServiceError", NULL, 
+        &error_node);
+    AXIS2_OM_ELEMENT_SET_TEXT(error_ele, env, "Echo service failed ", 
+        text_node);
+    return error_node;
+}
+
+/* Free the resources used */
 int AXIS2_CALL
 echo_free(axis2_svc_skeleton_t *svc_skeleton,
             axis2_env_t **env)
 {
+    /* Free the function array */
     if(svc_skeleton->func_array)
     {
         AXIS2_ARRAY_LIST_FREE(svc_skeleton->func_array, env);
         svc_skeleton->func_array = NULL;
     }
     
+    /* Free the function array */
     if(svc_skeleton->ops)
     {
         AXIS2_FREE((*env)->allocator, svc_skeleton->ops);
         svc_skeleton->ops = NULL;
     }
     
+    /* Free the service skeleton */
     if(svc_skeleton)
     {
         AXIS2_FREE((*env)->allocator, svc_skeleton);
         svc_skeleton = NULL;
     }
+
     return AXIS2_SUCCESS; 
 }
 
-/*
- * This method invokes the right service method 
- */
-axis2_om_node_t* AXIS2_CALL
-echo_invoke(axis2_svc_skeleton_t *svc_skeleton,
-            axis2_env_t **env,
-            axis2_om_node_t *node)
-{
-    /* Depending on the function name invoke the
-     *  corresponding echo method
-     */
-        
-    return axis2_echo_echo(env, node);
-}
 
 /**
  * Following block distinguish the exposed part of the dll.
  */
-
 AXIS2_EXPORT int 
 axis2_get_instance(axis2_svc_skeleton_t **inst,
                    axis2_env_t **env)
 {
 	*inst = axis2_echo_create(env);
-    /*if(NULL != *inst)
-    {
-        status = *inst->init();
-    }*/
     if(!(*inst))
     {
         return AXIS2_FAILURE;



Mime
View raw message