axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r426466 - in /webservices/axis2/trunk/c/samples: ./ client/ server/ server/Calculator/
Date Fri, 28 Jul 2006 10:06:46 GMT
Author: damitha
Date: Fri Jul 28 03:06:45 2006
New Revision: 426466

URL: http://svn.apache.org/viewvc?rev=426466&view=rev
Log:
Added Calculator server sample which will be the
server side sample for dynamic client.

Added:
    webservices/axis2/trunk/c/samples/server/Calculator/
    webservices/axis2/trunk/c/samples/server/Calculator/Makefile.am
    webservices/axis2/trunk/c/samples/server/Calculator/calc.c
    webservices/axis2/trunk/c/samples/server/Calculator/calc.h
    webservices/axis2/trunk/c/samples/server/Calculator/calc_skeleton.c
    webservices/axis2/trunk/c/samples/server/Calculator/services.xml
Modified:
    webservices/axis2/trunk/c/samples/client/Makefile.am
    webservices/axis2/trunk/c/samples/configure.ac
    webservices/axis2/trunk/c/samples/server/Makefile.am

Modified: webservices/axis2/trunk/c/samples/client/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/Makefile.am?rev=426466&r1=426465&r2=426466&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/client/Makefile.am (original)
+++ webservices/axis2/trunk/c/samples/client/Makefile.am Fri Jul 28 03:06:45 2006
@@ -1,4 +1,4 @@
 clientdir=$(prefix)/samples/client
-SUBDIRS = echo math google notify mtom 
+SUBDIRS = echo math google notify mtom dynamic_client
 client_DATA = Makefile.am Makefile.in
 EXTRA_DIST= Makefile.am

Modified: webservices/axis2/trunk/c/samples/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/configure.ac?rev=426466&r1=426465&r2=426466&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/configure.ac (original)
+++ webservices/axis2/trunk/c/samples/configure.ac Fri Jul 28 03:06:45 2006
@@ -121,6 +121,7 @@
     server/Makefile \
     server/echo/Makefile \
     server/math/Makefile \
+    server/Calculator/Makefile \
     server/notify/Makefile \
     server/sg_math/Makefile \
     server/mtom/Makefile \

Added: webservices/axis2/trunk/c/samples/server/Calculator/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/Calculator/Makefile.am?rev=426466&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Calculator/Makefile.am (added)
+++ webservices/axis2/trunk/c/samples/server/Calculator/Makefile.am Fri Jul 28 03:06:45 2006
@@ -0,0 +1,13 @@
+prglibdir=$(prefix)/services/Calculator
+samplesdir=$(prefix)/samples/server/Calculator
+prglib_LTLIBRARIES = libCalculator.la
+samples_DATA=services.xml calc.h calc.c calc_skeleton.c Makefile.am Makefile.in
+prglib_DATA=services.xml
+EXTRA_DIST = services.xml
+noinst_HEADERS = calc.h
+SUBDIRS =
+libCalculator_la_SOURCES = calc.c calc_skeleton.c
+libCalculator_la_LIBADD  =
+INCLUDES = -I$(AXIS2C_HOME)/include \
+			@UTILINC@ \
+			@AXIOMINC@

Added: webservices/axis2/trunk/c/samples/server/Calculator/calc.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/Calculator/calc.c?rev=426466&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Calculator/calc.c (added)
+++ webservices/axis2/trunk/c/samples/server/Calculator/calc.c Fri Jul 28 03:06:45 2006
@@ -0,0 +1,481 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "calc.h"
+#include <stdio.h>
+
+axiom_node_t *
+axis2_calc_add (const axis2_env_t *env, axiom_node_t *node)
+{
+    axiom_node_t *complex_node = NULL;
+    axiom_node_t *seq_node = NULL;
+    axiom_node_t *param1_node = NULL;
+    axiom_node_t *param1_text_node = NULL;
+    axis2_char_t *param1_str = NULL;
+    long int param1 = 0;
+    axiom_node_t *param2_node = NULL;
+    axiom_node_t *param2_text_node = NULL;
+    axis2_char_t *param2_str = NULL;
+    long int param2 = 0;
+
+    if (!node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, AXIS2_FAILURE);
+        printf("Calculator client request ERROR: input parameter NULL\n");
+        return NULL;
+    }
+    complex_node = AXIOM_NODE_GET_FIRST_CHILD(node, env);
+    if (!complex_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    seq_node = AXIOM_NODE_GET_FIRST_CHILD(complex_node, env);
+    if (!seq_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param1_node = AXIOM_NODE_GET_FIRST_CHILD(seq_node, env);
+    if (!param1_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    param1_text_node = AXIOM_NODE_GET_FIRST_CHILD(param1_node, env);
+    if (!param1_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    if (AXIOM_NODE_GET_NODE_TYPE(param1_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param1_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param1_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    param2_node = AXIOM_NODE_GET_NEXT_SIBLING(param1_node, env);
+    if (!param2_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    param2_text_node = AXIOM_NODE_GET_FIRST_CHILD(param2_node, env);
+    if (!param2_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    if (AXIOM_NODE_GET_NODE_TYPE(param2_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param2_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param2_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    if (param1_str && param2_str)
+    {
+        long int result = 0;
+        axis2_char_t result_str[255];
+
+        axiom_element_t *ele1 = NULL;
+        axiom_node_t *node1 = NULL, *node2 = NULL;
+        axiom_namespace_t *ns1 = NULL;
+        axiom_text_t *text1 = NULL;
+        
+        param1 = strtol(param1_str, NULL, 10);
+        param2 = strtol(param2_str, NULL, 10);
+        result = param1 + param2;
+        sprintf(result_str, "%ld", result);
+
+        
+
+        ns1 = axiom_namespace_create (env,
+                                   "http://axis2/test/namespace1",
+                                   "ns1");
+        ele1 = axiom_element_create (env, NULL, "result", ns1, &node1);
+        text1 = axiom_text_create (env, node1, result_str, &node2);
+
+        return node1;
+    }
+    
+    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
AXIS2_FAILURE);
+    printf("Calculator service ERROR: invalid parameters\n");
+    return NULL;
+}
+
+axiom_node_t *
+axis2_calc_sub (const axis2_env_t *env, axiom_node_t *node)
+{
+    axiom_node_t *param1_node = NULL;
+    axiom_node_t *param1_text_node = NULL;
+    axis2_char_t *param1_str = NULL;
+    long int param1 = 0;
+    axiom_node_t *param2_node = NULL;
+    axiom_node_t *param2_text_node = NULL;
+    axis2_char_t *param2_str = NULL;
+    long int param2 = 0;
+
+    if (!node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, AXIS2_FAILURE);
+        printf("Calculator client request ERROR: input parameter NULL\n");
+        return NULL;
+    }
+
+    param1_node = AXIOM_NODE_GET_FIRST_CHILD(node, env);
+    if (!param1_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param1_text_node = AXIOM_NODE_GET_FIRST_CHILD(param1_node, env);
+    if (!param1_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(param1_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param1_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param1_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    param2_node = AXIOM_NODE_GET_NEXT_SIBLING(param1_node, env);
+    if (!param2_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param2_text_node = AXIOM_NODE_GET_FIRST_CHILD(param2_node, env);
+    if (!param2_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(param2_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param2_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param2_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    if (param1_str && param2_str)
+    {
+        long int result = 0;
+        axis2_char_t result_str[255];
+
+        axiom_element_t *ele1 = NULL;
+        axiom_node_t *node1 = NULL, *node2 = NULL;
+        axiom_namespace_t *ns1 = NULL;
+        axiom_text_t *text1 = NULL;
+        
+        param1 = strtol(param1_str, NULL, 10);
+        param2 = strtol(param2_str, NULL, 10);
+        result = param1 - param2;
+        sprintf(result_str, "%ld", result);
+
+        
+
+        ns1 = axiom_namespace_create (env,
+                                   "http://axis2/test/namespace1",
+                                   "ns1");
+        ele1 = axiom_element_create (env, NULL, "result", ns1, &node1);
+        text1 = axiom_text_create (env, node1, result_str, &node2);
+
+        return node1;
+    }
+    
+    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
AXIS2_FAILURE);
+    printf("Calculator service ERROR: invalid parameters\n");
+    return NULL;
+}
+
+
+axiom_node_t *
+axis2_calc_mul (const axis2_env_t *env, axiom_node_t *node)
+{
+    axiom_node_t *param1_node = NULL;
+    axiom_node_t *param1_text_node = NULL;
+    axis2_char_t *param1_str = NULL;
+    long int param1 = 0;
+    axiom_node_t *param2_node = NULL;
+    axiom_node_t *param2_text_node = NULL;
+    axis2_char_t *param2_str = NULL;
+    long int param2 = 0;
+
+    if (!node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, AXIS2_FAILURE);
+        printf("Calculator client request ERROR: input parameter NULL\n");
+        return NULL;
+    }
+
+    param1_node = AXIOM_NODE_GET_FIRST_CHILD(node, env);
+    if (!param1_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param1_text_node = AXIOM_NODE_GET_FIRST_CHILD(param1_node, env);
+    if (!param1_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(param1_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param1_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param1_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    param2_node = AXIOM_NODE_GET_NEXT_SIBLING(param1_node, env);
+    if (!param2_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param2_text_node = AXIOM_NODE_GET_FIRST_CHILD(param2_node, env);
+    if (!param2_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(param2_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param2_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param2_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    if (param1_str && param2_str)
+    {
+        long int result = 0;
+        axis2_char_t result_str[255];
+
+        axiom_element_t *ele1 = NULL;
+        axiom_node_t *node1 = NULL, *node2 = NULL;
+        axiom_namespace_t *ns1 = NULL;
+        axiom_text_t *text1 = NULL;
+        
+        param1 = strtol(param1_str, NULL, 10);
+        param2 = strtol(param2_str, NULL, 10);
+        result = param1 * param2;
+        sprintf(result_str, "%ld", result);
+
+        
+
+        ns1 = axiom_namespace_create (env,
+                                   "http://axis2/test/namespace1",
+                                   "ns1");
+        ele1 = axiom_element_create (env, NULL, "result", ns1, &node1);
+        text1 = axiom_text_create (env, node1, result_str, &node2);
+
+        return node1;
+    }
+    
+    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
AXIS2_FAILURE);
+    printf("Calculator service ERROR: invalid parameters\n");
+    return NULL;
+}
+
+
+axiom_node_t *
+axis2_calc_div (const axis2_env_t *env, axiom_node_t *node)
+{
+    axiom_node_t *param1_node = NULL;
+    axiom_node_t *param1_text_node = NULL;
+    axis2_char_t *param1_str = NULL;
+    long int param1 = 0;
+    axiom_node_t *param2_node = NULL;
+    axiom_node_t *param2_text_node = NULL;
+    axis2_char_t *param2_str = NULL;
+    long int param2 = 0;
+
+    if (!node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, AXIS2_FAILURE);
+        printf("Calculator client request ERROR: input parameter NULL\n");
+        return NULL;
+    }
+
+    param1_node = AXIOM_NODE_GET_FIRST_CHILD(node, env);
+    if (!param1_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param1_text_node = AXIOM_NODE_GET_FIRST_CHILD(param1_node, env);
+    if (!param1_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(param1_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param1_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param1_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    param2_node = AXIOM_NODE_GET_NEXT_SIBLING(param1_node, env);
+    if (!param2_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service  ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    param2_text_node = AXIOM_NODE_GET_FIRST_CHILD(param2_node, env);
+    if (!param2_text_node)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(param2_text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t *)AXIOM_NODE_GET_DATA_ELEMENT(param2_text_node,
env);
+        if( text && AXIOM_TEXT_GET_VALUE(text ,env))
+        {
+            param2_str = AXIOM_TEXT_GET_VALUE(text,env);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
AXIS2_FAILURE);
+        printf("Calculator service ERROR: invalid XML in request\n");
+        return NULL;
+    }
+   
+    if (param1_str && param2_str)
+    {
+        long int result = 0;
+        axis2_char_t result_str[255];
+
+        axiom_element_t *ele1 = NULL;
+        axiom_node_t *node1 = NULL, *node2 = NULL;
+        axiom_namespace_t *ns1 = NULL;
+        axiom_text_t *text1 = NULL;
+        
+        param1 = strtol(param1_str, NULL, 10);
+        param2 = strtol(param2_str, NULL, 10);
+        if (param2 == 0)
+            return NULL;
+        result = param1 / param2;
+        sprintf(result_str, "%ld", result);
+
+        
+
+        ns1 = axiom_namespace_create (env,
+                                   "http://axis2/test/namespace1",
+                                   "ns1");
+        ele1 = axiom_element_create (env, NULL, "result", ns1, &node1);
+        text1 = axiom_text_create (env, node1, result_str, &node2);
+
+        return node1;
+    }
+    
+    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
AXIS2_FAILURE);
+    printf("Calculator service ERROR: invalid parameters\n");
+    return NULL;
+}

Added: webservices/axis2/trunk/c/samples/server/Calculator/calc.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/Calculator/calc.h?rev=426466&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Calculator/calc.h (added)
+++ webservices/axis2/trunk/c/samples/server/Calculator/calc.h Fri Jul 28 03:06:45 2006
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef CALC_H
+#define CALC_H
+
+
+#include <axis2_svc_skeleton.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axiom_text.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+
+axiom_node_t *axis2_calc_add(const axis2_env_t *env, axiom_node_t *node);
+axiom_node_t *axis2_calc_sub(const axis2_env_t *env, axiom_node_t *node);
+axiom_node_t *axis2_calc_mul(const axis2_env_t *env, axiom_node_t *node);
+axiom_node_t *axis2_calc_div(const axis2_env_t *env, axiom_node_t *node);
+
+#endif /* CALC_H*/

Added: webservices/axis2/trunk/c/samples/server/Calculator/calc_skeleton.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/Calculator/calc_skeleton.c?rev=426466&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Calculator/calc_skeleton.c (added)
+++ webservices/axis2/trunk/c/samples/server/Calculator/calc_skeleton.c Fri Jul 28 03:06:45
2006
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "axis2_svc_skeleton.h"
+#include "calc.h"
+#include <axis2_array_list.h>
+#include <stdio.h>
+
+int AXIS2_CALL
+calc_free(axis2_svc_skeleton_t *svc_skeleton,
+          const axis2_env_t *env);
+
+/*
+ * This method invokes the right service method 
+ */
+axiom_node_t* AXIS2_CALL 
+calc_invoke(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env,
+            axiom_node_t *node,
+            axis2_msg_ctx_t *msg_ctx);
+
+int AXIS2_CALL calc_init(axis2_svc_skeleton_t *svc_skeleton,
+                        const axis2_env_t *env);
+
+
+AXIS2_EXTERN axis2_svc_skeleton_t * AXIS2_CALL
+axis2_calc_create(const axis2_env_t *env)
+{
+    axis2_svc_skeleton_t *svc_skeleton = NULL;
+    svc_skeleton = AXIS2_MALLOC(env->allocator, 
+        sizeof(axis2_svc_skeleton_t));
+
+    
+    svc_skeleton->ops = AXIS2_MALLOC(
+        env->allocator, sizeof(axis2_svc_skeleton_ops_t));
+
+    svc_skeleton->func_array = NULL;
+
+    svc_skeleton->ops->free = calc_free;
+    svc_skeleton->ops->init = calc_init;
+    svc_skeleton->ops->invoke = calc_invoke;
+    /*svc_skeleton->ops->on_fault = calc_on_fault;*/
+
+    return svc_skeleton;
+}
+
+int AXIS2_CALL
+calc_init(axis2_svc_skeleton_t *svc_skeleton,
+                        const axis2_env_t *env)
+{
+    svc_skeleton->func_array = axis2_array_list_create(env, 0);
+    AXIS2_ARRAY_LIST_ADD(svc_skeleton->func_array, env, "add");
+    AXIS2_ARRAY_LIST_ADD(svc_skeleton->func_array, env, "sub");
+    AXIS2_ARRAY_LIST_ADD(svc_skeleton->func_array, env, "mul");
+    AXIS2_ARRAY_LIST_ADD(svc_skeleton->func_array, env, "div");
+
+    /* Any initialization stuff of calc goes here */
+    return AXIS2_SUCCESS;
+}
+
+int AXIS2_CALL
+calc_free(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env)
+{
+    /*if(svc_skeleton->func_array)
+    {
+        AXIS2_ARRAY_LIST_FREE(svc_skeleton->func_array, env);
+        svc_skeleton->func_array = NULL;
+    }*/
+    
+    if(svc_skeleton->ops)
+    {
+        AXIS2_FREE(env->allocator, svc_skeleton->ops);
+        svc_skeleton->ops = NULL;
+    }
+    
+    if(svc_skeleton)
+    {
+        AXIS2_FREE(env->allocator, svc_skeleton);
+        svc_skeleton = NULL;
+    }
+    return AXIS2_SUCCESS; 
+}
+
+/*
+ * This method invokes the right service method 
+ */
+axiom_node_t* AXIS2_CALL
+calc_invoke(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env,
+            axiom_node_t *node,
+            axis2_msg_ctx_t *msg_ctx)
+{
+    /* Depending on the function name invoke the
+     *  corresponding calc method
+     */
+    if (node)
+    {
+        if (AXIOM_NODE_GET_NODE_TYPE(node, env) == AXIOM_ELEMENT)
+        {
+            axiom_element_t *element = NULL;
+            element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
+            if (element)
+            {
+                axis2_char_t *op_name = AXIOM_ELEMENT_GET_LOCALNAME(element, env);
+                if (op_name)
+                {
+                    if ( AXIS2_STRCMP(op_name, "add") == 0 )
+                        return axis2_calc_add(env, node);
+                    if ( AXIS2_STRCMP(op_name, "sub") == 0 )
+                        return axis2_calc_sub(env, node);
+                    if ( AXIS2_STRCMP(op_name, "mul") == 0 )
+                        return axis2_calc_mul(env, node);
+                    if ( AXIS2_STRCMP(op_name, "div") == 0 )
+                        return axis2_calc_div(env, node);
+                }
+            }
+        }
+    }
+    
+    printf("Calculator service ERROR: invalid OM parameters in request\n");
+    
+    /** TODO: return a SOAP fault here */
+    return node;
+}
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+AXIS2_EXPORT int axis2_get_instance(struct axis2_svc_skeleton **inst,
+                        const axis2_env_t *env)
+{
+   *inst = axis2_calc_create(env);
+    /*if(NULL != *inst)
+    {
+        status = *inst->init();
+    }*/
+    if(!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int axis2_remove_instance(axis2_svc_skeleton_t *inst,
+                            const axis2_env_t *env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+   if (inst)
+   {
+        status = AXIS2_SVC_SKELETON_FREE(inst, env);
+    }
+    return status;
+}
+

Added: webservices/axis2/trunk/c/samples/server/Calculator/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/Calculator/services.xml?rev=426466&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Calculator/services.xml (added)
+++ webservices/axis2/trunk/c/samples/server/Calculator/services.xml Fri Jul 28 03:06:45 2006
@@ -0,0 +1,28 @@
+<service name="Calculator">
+    <parameter name="ServiceClass" locked="xsd:false">Calculator</parameter>
+
+   <description>
+        This is a testing service, named 'Calculator' to test dynamic client
+   </description>
+
+    <operation name="add">
+            <!--messageReceiver class="axis2_receivers" /-->
+            <parameter name="wsamapping" >Calculator#add</parameter>
+    </operation>
+
+    <operation name="sub">
+            <!--messageReceiver class="axis2_receivers" /-->
+            <parameter name="wsamapping" >Calculator#sub</parameter>
+    </operation>
+
+    <operation name="mul">
+            <!--messageReceiver class="axis2_receivers" /-->
+            <parameter name="wsamapping" >Calculator#mul</parameter>
+    </operation>
+
+    <operation name="div">
+            <!--messageReceiver class="axis2_receivers" /-->
+            <parameter name="wsamapping" >Calculator#div</parameter>
+    </operation>
+
+</service>

Modified: webservices/axis2/trunk/c/samples/server/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/Makefile.am?rev=426466&r1=426465&r2=426466&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Makefile.am (original)
+++ webservices/axis2/trunk/c/samples/server/Makefile.am Fri Jul 28 03:06:45 2006
@@ -1,5 +1,5 @@
 samplesdir=$(prefix)/samples/server
-SUBDIRS = echo math notify sg_math mtom
+SUBDIRS = echo math notify sg_math mtom Calculator
 EXTRA_DIST = axis2.xml
 samples_DATA= axis2.log  axis2.xml  Makefile.am Makefile.in
 



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


Mime
View raw message