From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- samples/server/Calculator/Calculator.mk | 7 + samples/server/Calculator/Calculator.wsdl | 183 +++++++++ samples/server/Calculator/Makefile.am | 9 + samples/server/Calculator/calc.c | 553 ++++++++++++++++++++++++++ samples/server/Calculator/calc.h | 41 ++ samples/server/Calculator/calc_skeleton.c | 157 ++++++++ samples/server/Calculator/services.xml | 28 ++ samples/server/Makefile.am | 2 + samples/server/axis2.log | 1 + samples/server/axis2.xml | 129 ++++++ samples/server/echo/Makefile.am | 9 + samples/server/echo/echo.c | 116 ++++++ samples/server/echo/echo.h | 32 ++ samples/server/echo/echo.mk | 8 + samples/server/echo/echo_skeleton.c | 182 +++++++++ samples/server/echo/services.xml | 34 ++ samples/server/math/Makefile.am | 9 + samples/server/math/math.c | 537 +++++++++++++++++++++++++ samples/server/math/math.h | 41 ++ samples/server/math/math.mk | 7 + samples/server/math/math_skeleton.c | 157 ++++++++ samples/server/math/services.xml | 18 + samples/server/mtom/Makefile.am | 9 + samples/server/mtom/mtom.c | 261 ++++++++++++ samples/server/mtom/mtom.h | 33 ++ samples/server/mtom/mtom.mk | 8 + samples/server/mtom/mtom_skeleton.c | 166 ++++++++ samples/server/mtom/services.xml | 12 + samples/server/mtom_callback/Makefile.am | 9 + samples/server/mtom_callback/mtom_callback.c | 261 ++++++++++++ samples/server/mtom_callback/mtom_callback.h | 33 ++ samples/server/mtom_callback/mtom_callback.mk | 8 + samples/server/mtom_callback/mtom_skeleton.c | 166 ++++++++ samples/server/mtom_callback/services.xml | 16 + samples/server/notify/Makefile.am | 9 + samples/server/notify/notify.c | 77 ++++ samples/server/notify/notify.h | 32 ++ samples/server/notify/notify.mk | 8 + samples/server/notify/notify_skeleton.c | 167 ++++++++ samples/server/notify/services.xml | 13 + samples/server/sg_math/Makefile.am | 11 + samples/server/sg_math/add.c | 180 +++++++++ samples/server/sg_math/add.h | 33 ++ samples/server/sg_math/add_skeleton.c | 151 +++++++ samples/server/sg_math/div.c | 150 +++++++ samples/server/sg_math/div.h | 32 ++ samples/server/sg_math/div_skeleton.c | 151 +++++++ samples/server/sg_math/mul.c | 148 +++++++ samples/server/sg_math/mul.h | 32 ++ samples/server/sg_math/mul_skeleton.c | 151 +++++++ samples/server/sg_math/services.xml | 30 ++ samples/server/sg_math/sg_math.mk | 15 + samples/server/sg_math/sub.c | 148 +++++++ samples/server/sg_math/sub.h | 32 ++ samples/server/sg_math/sub_skeleton.c | 151 +++++++ samples/server/version/Makefile.am | 10 + samples/server/version/services.xml | 9 + samples/server/version/version.c | 59 +++ samples/server/version/version.h | 32 ++ samples/server/version/version_skel.c | 151 +++++++ 60 files changed, 5224 insertions(+) create mode 100644 samples/server/Calculator/Calculator.mk create mode 100644 samples/server/Calculator/Calculator.wsdl create mode 100644 samples/server/Calculator/Makefile.am create mode 100644 samples/server/Calculator/calc.c create mode 100644 samples/server/Calculator/calc.h create mode 100644 samples/server/Calculator/calc_skeleton.c create mode 100644 samples/server/Calculator/services.xml create mode 100644 samples/server/Makefile.am create mode 100644 samples/server/axis2.log create mode 100644 samples/server/axis2.xml create mode 100644 samples/server/echo/Makefile.am create mode 100644 samples/server/echo/echo.c create mode 100644 samples/server/echo/echo.h create mode 100644 samples/server/echo/echo.mk create mode 100644 samples/server/echo/echo_skeleton.c create mode 100644 samples/server/echo/services.xml create mode 100644 samples/server/math/Makefile.am create mode 100644 samples/server/math/math.c create mode 100644 samples/server/math/math.h create mode 100644 samples/server/math/math.mk create mode 100644 samples/server/math/math_skeleton.c create mode 100644 samples/server/math/services.xml create mode 100644 samples/server/mtom/Makefile.am create mode 100644 samples/server/mtom/mtom.c create mode 100644 samples/server/mtom/mtom.h create mode 100644 samples/server/mtom/mtom.mk create mode 100644 samples/server/mtom/mtom_skeleton.c create mode 100644 samples/server/mtom/services.xml create mode 100644 samples/server/mtom_callback/Makefile.am create mode 100644 samples/server/mtom_callback/mtom_callback.c create mode 100644 samples/server/mtom_callback/mtom_callback.h create mode 100644 samples/server/mtom_callback/mtom_callback.mk create mode 100644 samples/server/mtom_callback/mtom_skeleton.c create mode 100644 samples/server/mtom_callback/services.xml create mode 100644 samples/server/notify/Makefile.am create mode 100644 samples/server/notify/notify.c create mode 100644 samples/server/notify/notify.h create mode 100644 samples/server/notify/notify.mk create mode 100644 samples/server/notify/notify_skeleton.c create mode 100644 samples/server/notify/services.xml create mode 100644 samples/server/sg_math/Makefile.am create mode 100644 samples/server/sg_math/add.c create mode 100644 samples/server/sg_math/add.h create mode 100644 samples/server/sg_math/add_skeleton.c create mode 100644 samples/server/sg_math/div.c create mode 100644 samples/server/sg_math/div.h create mode 100644 samples/server/sg_math/div_skeleton.c create mode 100644 samples/server/sg_math/mul.c create mode 100644 samples/server/sg_math/mul.h create mode 100644 samples/server/sg_math/mul_skeleton.c create mode 100644 samples/server/sg_math/services.xml create mode 100644 samples/server/sg_math/sg_math.mk create mode 100644 samples/server/sg_math/sub.c create mode 100644 samples/server/sg_math/sub.h create mode 100644 samples/server/sg_math/sub_skeleton.c create mode 100644 samples/server/version/Makefile.am create mode 100644 samples/server/version/services.xml create mode 100644 samples/server/version/version.c create mode 100644 samples/server/version/version.h create mode 100644 samples/server/version/version_skel.c (limited to 'samples/server') diff --git a/samples/server/Calculator/Calculator.mk b/samples/server/Calculator/Calculator.mk new file mode 100644 index 0000000..8b4c683 --- /dev/null +++ b/samples/server/Calculator/Calculator.mk @@ -0,0 +1,7 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:Calculator.dll + + + + diff --git a/samples/server/Calculator/Calculator.wsdl b/samples/server/Calculator/Calculator.wsdl new file mode 100644 index 0000000..a37e390 --- /dev/null +++ b/samples/server/Calculator/Calculator.wsdl @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/server/Calculator/Makefile.am b/samples/server/Calculator/Makefile.am new file mode 100644 index 0000000..65f95ce --- /dev/null +++ b/samples/server/Calculator/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/Calculator +prglib_LTLIBRARIES = libCalculator.la +prglib_DATA=services.xml Calculator.wsdl +EXTRA_DIST = services.xml Calculator.wsdl Calculator.mk calc.h +noinst_HEADERS = calc.h +SUBDIRS = +libCalculator_la_SOURCES = calc.c calc_skeleton.c +libCalculator_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/Calculator/calc.c b/samples/server/Calculator/calc.c new file mode 100644 index 0000000..3e5eeba --- /dev/null +++ b/samples/server/Calculator/calc.c @@ -0,0 +1,553 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + +axiom_node_t * +axis2_calc_add( + const axutil_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 = (axis2_char_t *) 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 = (axis2_char_t *) 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 axutil_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 = (axis2_char_t *) 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 = (axis2_char_t *) 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 axutil_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 = (axis2_char_t *) 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 = (axis2_char_t *) 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 axutil_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 = (axis2_char_t *) 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 = (axis2_char_t *) 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; +} diff --git a/samples/server/Calculator/calc.h b/samples/server/Calculator/calc.h new file mode 100644 index 0000000..58ffde8 --- /dev/null +++ b/samples/server/Calculator/calc.h @@ -0,0 +1,41 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include +#include +#include +#include +#include + +axiom_node_t *axis2_calc_add( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_calc_sub( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_calc_mul( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_calc_div( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* CALC_H */ diff --git a/samples/server/Calculator/calc_skeleton.c b/samples/server/Calculator/calc_skeleton.c new file mode 100644 index 0000000..c153eee --- /dev/null +++ b/samples/server/Calculator/calc_skeleton.c @@ -0,0 +1,157 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include + +int AXIS2_CALL calc_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL calc_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_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 axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t calc_svc_skeleton_ops_var = { + calc_init, + calc_invoke, + NULL, + calc_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_calc_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &calc_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +calc_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of calc goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +calc_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 axutil_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 (axutil_strcmp(op_name, "add") == 0) + return axis2_calc_add(env, node); + if (axutil_strcmp(op_name, "sub") == 0) + return axis2_calc_sub(env, node); + if (axutil_strcmp(op_name, "mul") == 0) + return axis2_calc_mul(env, node); + if (axutil_strcmp(op_name, "div") == 0) + return axis2_calc_div(env, node); + } + } + } + } + + printf("Calculator service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = axis2_calc_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/Calculator/services.xml b/samples/server/Calculator/services.xml new file mode 100644 index 0000000..b449764 --- /dev/null +++ b/samples/server/Calculator/services.xml @@ -0,0 +1,28 @@ + + Calculator + + + This is a testing service, named 'Calculator' to test dynamic client + + + + + Calculator#add + + + + + Calculator#sub + + + + + Calculator#mul + + + + + Calculator#div + + + diff --git a/samples/server/Makefile.am b/samples/server/Makefile.am new file mode 100644 index 0000000..677aad9 --- /dev/null +++ b/samples/server/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = echo math notify sg_math mtom Calculator version mtom_callback +EXTRA_DIST = axis2.xml diff --git a/samples/server/axis2.log b/samples/server/axis2.log new file mode 100644 index 0000000..39cdd0d --- /dev/null +++ b/samples/server/axis2.log @@ -0,0 +1 @@ +- diff --git a/samples/server/axis2.xml b/samples/server/axis2.xml new file mode 100644 index 0000000..0851e3b --- /dev/null +++ b/samples/server/axis2.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + 6060 + false + + + + + + + + + + + + + HTTP/1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/server/echo/Makefile.am b/samples/server/echo/Makefile.am new file mode 100644 index 0000000..8413c5a --- /dev/null +++ b/samples/server/echo/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/echo +prglib_LTLIBRARIES = libecho.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml echo.mk echo.h +noinst_HEADERS = echo.h +SUBDIRS = +libecho_la_SOURCES = echo.c echo_skeleton.c +libecho_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/echo/echo.c b/samples/server/echo/echo.c new file mode 100644 index 0000000..2ce6a08 --- /dev/null +++ b/samples/server/echo/echo.c @@ -0,0 +1,116 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "echo.h" +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env, + axis2_char_t * text); + +void set_custom_error( + const axutil_env_t * env, + axis2_char_t * error_message); + +axiom_node_t * +axis2_echo_echo( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *text_parent_node = NULL; + axiom_node_t *text_node = NULL; + axiom_node_t *ret_node = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + /* Expected request format is :- + * + * echo5 + * + */ + if (!node) /* 'echoString' node */ + { + set_custom_error(env, "Invalid payload; echoString node is NULL"); + return NULL; + } + + text_parent_node = axiom_node_get_first_element(node, env); + if (!text_parent_node) + { + set_custom_error(env, "Invalid payload; text node is NULL"); + return NULL; + } + + text_node = axiom_node_get_first_child(text_parent_node, env); + if (!text_node) /* actual text to echo */ + { + set_custom_error(env, "Invalid payload; text to be echoed is NULL"); + return NULL; + } + + if (axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(text_node, env); + if (text && axiom_text_get_value(text, env)) + { + axis2_char_t *text_str = + (axis2_char_t *) axiom_text_get_value(text, env); + ret_node = build_om_programatically(env, text_str); + } + } + else + { + set_custom_error(env, "Invalid payload; invalid XML in request"); + return NULL; + } + + return ret_node; +} + +/* Builds the response content */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env, + axis2_char_t * text) +{ + axiom_node_t *echo_om_node = NULL; + axiom_element_t *echo_om_ele = NULL; + axiom_node_t *text_om_node = NULL; + axiom_element_t *text_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + echo_om_ele = + axiom_element_create(env, NULL, "echoString", ns1, &echo_om_node); + text_om_ele = + axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node); + axiom_element_set_text(text_om_ele, env, text, text_om_node); + return echo_om_node; +} + +void +set_custom_error( + const axutil_env_t * env, + axis2_char_t * error_message) +{ + axutil_error_set_error_message(env->error, error_message); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_LAST + 1, AXIS2_FAILURE); +} diff --git a/samples/server/echo/echo.h b/samples/server/echo/echo.h new file mode 100644 index 0000000..ecad867 --- /dev/null +++ b/samples/server/echo/echo.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include +#include +#include +#include +#include + +axiom_node_t *axis2_echo_echo( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* CALC_H */ diff --git a/samples/server/echo/echo.mk b/samples/server/echo/echo.mk new file mode 100644 index 0000000..ae0f769 --- /dev/null +++ b/samples/server/echo/echo.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:echo.dll + + + + + diff --git a/samples/server/echo/echo_skeleton.c b/samples/server/echo/echo_skeleton.c new file mode 100644 index 0000000..2f902ab --- /dev/null +++ b/samples/server/echo/echo_skeleton.c @@ -0,0 +1,182 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include "echo.h" +#include +#include +#include + +int AXIS2_CALL echo_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL echo_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL echo_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL echo_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t echo_svc_skeleton_ops_var = { + echo_init, + echo_invoke, + echo_on_fault, + echo_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_echo_create( + const axutil_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 = &echo_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +echo_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of echo service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +echo_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* 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. + */ + axis2_endpoint_ref_t* to_epr = NULL; + to_epr = axis2_msg_ctx_get_to(msg_ctx, env); + + if (to_epr) + { + axis2_char_t* to_address = NULL; + to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(to_epr, env); + + if (to_address && strstr(to_address, AXIS2_ANON_SERVICE)) + { + axis2_msg_ctx_set_wsa_action(msg_ctx, env, AXIS2_ANON_OUT_IN_OP); + } + } + + return axis2_echo_echo(env, node); +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +echo_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_element_t *error_ele = NULL; + + error_ele = + axiom_element_create(env, NULL, "EchoServiceError", NULL, &error_node); + axiom_element_set_text(error_ele, env, "Echo service failed ", error_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +echo_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_echo_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/echo/services.xml b/samples/server/echo/services.xml new file mode 100644 index 0000000..ea75640 --- /dev/null +++ b/samples/server/echo/services.xml @@ -0,0 +1,34 @@ + + echo + + + + + + + + + This is a testing service, to test whether the system is working or not + + + + + http://ws.apache.org/axis2/c/samples/echoString + + + POST + echoString + + + + + + + + + + diff --git a/samples/server/math/Makefile.am b/samples/server/math/Makefile.am new file mode 100644 index 0000000..d8e6f82 --- /dev/null +++ b/samples/server/math/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/math +prglib_LTLIBRARIES = libmath.la +prglib_DATA=services.xml +EXTRA_DIST = services.xml math.mk math.h +noinst_HEADERS = math.h +SUBDIRS = +libmath_la_SOURCES = math.c math_skeleton.c +libmath_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/math/math.c b/samples/server/math/math.c new file mode 100644 index 0000000..c3236a2 --- /dev/null +++ b/samples/server/math/math.c @@ -0,0 +1,537 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "math.h" +#include + +axiom_node_t * +axis2_math_add( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_math_sub( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_math_mul( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_math_div( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/math/math.h b/samples/server/math/math.h new file mode 100644 index 0000000..58abfc5 --- /dev/null +++ b/samples/server/math/math.h @@ -0,0 +1,41 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 MATH_H +#define MATH_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_math_add( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_math_sub( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_math_mul( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_math_div( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* MATH_H */ diff --git a/samples/server/math/math.mk b/samples/server/math/math.mk new file mode 100644 index 0000000..dee9b6d --- /dev/null +++ b/samples/server/math/math.mk @@ -0,0 +1,7 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:math.dll + + + + diff --git a/samples/server/math/math_skeleton.c b/samples/server/math/math_skeleton.c new file mode 100644 index 0000000..4aabce8 --- /dev/null +++ b/samples/server/math/math_skeleton.c @@ -0,0 +1,157 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "math.h" +#include +#include + +int AXIS2_CALL math_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL math_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL math_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t math_svc_skeleton_ops_var = { + math_init, + math_invoke, + NULL, + math_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +math_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &math_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +math_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of math goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +math_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 +math_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding math 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 (axutil_strcmp(op_name, "add") == 0) + return axis2_math_add(env, node); + if (axutil_strcmp(op_name, "sub") == 0) + return axis2_math_sub(env, node); + if (axutil_strcmp(op_name, "mul") == 0) + return axis2_math_mul(env, node); + if (axutil_strcmp(op_name, "div") == 0) + return axis2_math_div(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = math_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/math/services.xml b/samples/server/math/services.xml new file mode 100644 index 0000000..70ff77b --- /dev/null +++ b/samples/server/math/services.xml @@ -0,0 +1,18 @@ + + math + + This is a testing service, named 'math' to test multiple operations in the same service + + + + + + + + + + + + + + diff --git a/samples/server/mtom/Makefile.am b/samples/server/mtom/Makefile.am new file mode 100644 index 0000000..198cad3 --- /dev/null +++ b/samples/server/mtom/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/mtom +prglib_LTLIBRARIES = libmtom.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml mtom.mk mtom.h +noinst_HEADERS = mtom.h +SUBDIRS = +libmtom_la_SOURCES = mtom.c mtom_skeleton.c +libmtom_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/mtom/mtom.c b/samples/server/mtom/mtom.c new file mode 100644 index 0000000..f00b68b --- /dev/null +++ b/samples/server/mtom/mtom.c @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "mtom.h" +#include +#include + +axiom_node_t *build_response1( + const axutil_env_t * env, + axis2_char_t * text); + +axiom_node_t *build_response2( + const axutil_env_t *env, + axiom_data_handler_t *data_handler); + +axiom_node_t* +axis2_mtom_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx) +{ + axiom_node_t *file_name_node = NULL; + axiom_node_t *file_text_node = NULL; + axiom_node_t *ret_node = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + /* Expected request format is :- + * + test.jpg + + + + + */ + if (!node) /* 'mtomSample' node */ + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Echo client ERROR: input parameter NULL\n"); + return NULL; + } + + file_name_node = axiom_node_get_first_child(node, env); + if (!file_name_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"); + return NULL; + } + + file_text_node = axiom_node_get_first_child(file_name_node, env); + if (!file_text_node) /* actual text to mtom */ + { + 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"); + return NULL; + } + + if (axiom_node_get_node_type(file_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(file_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + axiom_node_t *image_node = NULL; + axis2_char_t *text_str = + (axis2_char_t *) axiom_text_get_value(text, env); + printf("File Name %s \n", text_str); + + image_node = axiom_node_get_next_sibling(file_name_node, env); + if (image_node) + { + /* axiom_node_t *inc_node = NULL; + inc_node = axiom_node_get_first_child(image_node, env); + if (inc_node) + { */ + axiom_node_t *binary_node = NULL; + binary_node = axiom_node_get_first_child(image_node, env); + if (binary_node) + { + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *bin_text = (axiom_text_t *) + axiom_node_get_data_element(binary_node, env); + data_handler = axiom_text_get_data_handler(bin_text, env); + if (data_handler && !axiom_data_handler_get_cached(data_handler, env)) + { + axiom_data_handler_t *data_handler_res = NULL; + axis2_byte_t *input_buff = NULL; + axis2_byte_t *buff = NULL; + size_t buff_len = 0; + + + axiom_data_handler_set_file_name(data_handler, env, + text_str); + axiom_data_handler_write_to(data_handler, env); + + input_buff = axiom_data_handler_get_input_stream(data_handler, env); + buff_len = axiom_data_handler_get_input_stream_len(data_handler, env); + + data_handler_res = axiom_data_handler_create(env, NULL, NULL); + + buff = AXIS2_MALLOC(env->allocator, sizeof(axis2_byte_t)*buff_len); + + if (!buff) + { + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "malloc failed, not enough memory"); + return NULL; + } + + memcpy(buff, input_buff, buff_len); + + axiom_data_handler_set_binary_data(data_handler_res, env, buff, buff_len); + + axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE); + ret_node = build_response2(env, data_handler_res); + } + else if(data_handler && axiom_data_handler_get_cached(data_handler, env)) + { + axiom_data_handler_t *data_handler_res = NULL; + axis2_char_t *file_name = NULL; + + file_name = axiom_data_handler_get_file_name(data_handler, env); + if(!file_name) + { + return NULL; + } + + data_handler_res = axiom_data_handler_create(env, file_name, NULL); + + axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE); + ret_node = build_response2(env, data_handler_res); + } + + else if (axiom_node_get_node_type(binary_node, env) == AXIOM_TEXT) /* attachment has come by value, as non-optimized binary */ + { + int plain_binary_len = 0; + int ret_len = 0; + axiom_text_t *bin_text = (axiom_text_t *) + axiom_node_get_data_element(binary_node, env); + axis2_byte_t *plain_binary = NULL; + axiom_data_handler_t *data_handler = NULL; + + axis2_char_t *base64text = + (axis2_char_t *) axiom_text_get_value(bin_text, + env); + printf("base64text = %s\n", base64text); + plain_binary_len = axutil_base64_decode_len(base64text); + plain_binary = AXIS2_MALLOC(env-> + allocator, + sizeof(unsigned char) * + plain_binary_len); + ret_len = + axutil_base64_decode_binary((unsigned char *) + plain_binary, + base64text); + data_handler = + axiom_data_handler_create(env, text_str, NULL); + axiom_data_handler_set_binary_data(data_handler, env, + plain_binary, + ret_len); + axiom_data_handler_write_to(data_handler, env); + ret_node = build_response1(env, base64text); + } + else /* nothing came */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_ATTACHMENT_MISSING, + AXIS2_FAILURE); + printf("Echo client ERROR: attachment is missing.\n"); + return NULL; + } + /* } */ + } + } + + } + } + else + { + 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"); + return NULL; + } + + return ret_node; +} + +/* Builds the response content */ +axiom_node_t * +build_response1( + const axutil_env_t * env, + axis2_char_t * text) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *om_node = NULL; + axiom_element_t *om_ele = NULL; + + + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + + mtom_om_ele = + axiom_element_create(env, NULL, "response", ns1, &mtom_om_node); + + om_ele = axiom_element_create(env, mtom_om_node, "string", NULL, &om_node); + + axiom_element_set_text(mtom_om_ele, env, text, om_node); + + + return mtom_om_node; +} + + +axiom_node_t *build_response2( + const axutil_env_t *env, + axiom_data_handler_t *data_handler) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *text_node = NULL; + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "response", ns1, &mtom_om_node); + + axiom_text_create_with_data_handler(env, mtom_om_node, data_handler, + &text_node); + + return mtom_om_node; +} + + + diff --git a/samples/server/mtom/mtom.h b/samples/server/mtom/mtom.h new file mode 100644 index 0000000..8ee6a39 --- /dev/null +++ b/samples/server/mtom/mtom.h @@ -0,0 +1,33 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include +#include +#include +#include +#include + +axiom_node_t *axis2_mtom_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx); + +#endif /* CALC_H */ diff --git a/samples/server/mtom/mtom.mk b/samples/server/mtom/mtom.mk new file mode 100644 index 0000000..a2d9b9b --- /dev/null +++ b/samples/server/mtom/mtom.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:mtom.dll + + + + + diff --git a/samples/server/mtom/mtom_skeleton.c b/samples/server/mtom/mtom_skeleton.c new file mode 100644 index 0000000..3ef10b6 --- /dev/null +++ b/samples/server/mtom/mtom_skeleton.c @@ -0,0 +1,166 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include "mtom.h" +#include + +int AXIS2_CALL mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { + mtom_init, + mtom_invoke, + mtom_on_fault, + mtom_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_mtom_create( + const axutil_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 = &mtom_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of mtom service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only mtom in this sample, hence invoke mtom method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + return axis2_mtom_mtom(env, node, msg_ctx); +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_node_t *text_node = NULL; + axiom_element_t *error_ele = NULL; + error_ele = axiom_element_create(env, node, "EchoServiceError", NULL, + &error_node); + axiom_element_set_text(error_ele, env, "Echo service failed ", text_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_mtom_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/mtom/services.xml b/samples/server/mtom/services.xml new file mode 100644 index 0000000..1a1b1b2 --- /dev/null +++ b/samples/server/mtom/services.xml @@ -0,0 +1,12 @@ + + mtom + + + This is a testing service , to test the system is working or not + + + + http://ws.apache.org/axis2/c/samples/mtom + + + diff --git a/samples/server/mtom_callback/Makefile.am b/samples/server/mtom_callback/Makefile.am new file mode 100644 index 0000000..11a107e --- /dev/null +++ b/samples/server/mtom_callback/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/mtom_callback +prglib_LTLIBRARIES = libmtom_callback.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml mtom_callback.mk mtom_callback.h +noinst_HEADERS = mtom_callback.h +SUBDIRS = +libmtom_callback_la_SOURCES = mtom_callback.c mtom_skeleton.c +libmtom_callback_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/mtom_callback/mtom_callback.c b/samples/server/mtom_callback/mtom_callback.c new file mode 100644 index 0000000..7029124 --- /dev/null +++ b/samples/server/mtom_callback/mtom_callback.c @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "mtom_callback.h" +#include +#include +#include +#include +#include +#include +#include + +axiom_node_t *build_response( + const axutil_env_t *env, + axiom_data_handler_t *data_handler); + +axis2_status_t process_attachments( + axis2_msg_ctx_t *msg_ctx, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name); + +axiom_node_t* +axis2_mtom_callback_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx) +{ + axiom_node_t *attachment_node = NULL; + axiom_node_t *binary_node = NULL; + axiom_node_t *ret_node = NULL; + axis2_status_t status = AXIS2_FAILURE; + void *user_param = NULL; + axutil_param_t *callback_name_param = NULL; + axis2_char_t *callback_name = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + /* Expected request format is :- + * + + + + + */ + if (!node) /* 'mtomSample' node */ + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Echo client ERROR: input parameter NULL\n"); + return NULL; + } + + attachment_node = axiom_node_get_first_child(node, env); + if (!attachment_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"); + return NULL; + } + + /* This is the paramter specified in the services.xml + * or in axis2.xml + */ + + callback_name_param = axis2_msg_ctx_get_parameter (msg_ctx, env, + AXIS2_MTOM_CACHING_CALLBACK); + + if(callback_name_param) + { + callback_name = (axis2_char_t *) axutil_param_get_value (callback_name_param, env); + } + + /* This will process the attachment data in the stream */ + + status = process_attachments(msg_ctx, env, user_param, callback_name); + if(status == AXIS2_FAILURE) + { + return NULL; + } + + binary_node = axiom_node_get_first_child(attachment_node, env); + if (binary_node) + { + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *bin_text = NULL; + axis2_char_t *attachment_id = NULL; + axiom_data_handler_t *data_handler_res = NULL; + axis2_char_t *location = NULL; + + bin_text = (axiom_text_t *)axiom_node_get_data_element(binary_node, env); + if(bin_text) + { + data_handler = axiom_text_get_data_handler(bin_text, env); + if(!data_handler) + { + return NULL; + } + } + + attachment_id = axiom_data_handler_get_mime_id(data_handler, env); + + if(!attachment_id) + { + return NULL; + } + + /* This is the case where the attachment resides in memory */ + + if (!axiom_data_handler_get_cached(data_handler, env)) + { + /* axis2_byte_t *input_buff = NULL; + axis2_byte_t *buff = NULL; + int buff_len = 0;*/ + + axiom_data_handler_set_file_name(data_handler, env, attachment_id); + axiom_data_handler_write_to(data_handler, env); + location = attachment_id; + } + + else + { + axiom_data_handler_type_t data_handler_type; + data_handler_type = axiom_data_handler_get_data_handler_type(data_handler, env); + + if(data_handler_type == AXIOM_DATA_HANDLER_TYPE_CALLBACK) + { + /* The service implementer should be aware of how to deal with the attachment + * Becasue it was stored using the callback he provided. */ + + /*axis2_char_t command[1000]; + + sprintf(command, "rm -f /opt/tmp/%s", attachment_id); + system(command);*/ + + /*location = attachment_id;*/ + /*location = "/home/manjula/axis2/mtom/resources/song.MP3"; */ + + location = "/opt/manjula-mtom.MPG"; + } + else if(data_handler_type == AXIOM_DATA_HANDLER_TYPE_FILE) + { + axis2_char_t *file_name = NULL; + + file_name = axiom_data_handler_get_file_name(data_handler, env); + if(file_name) + { + location = axutil_strdup(env, file_name); + } + } + } + + /* The samples sends back an attachment to the client. Hence we are creating the + * response data_handler as a type CALLBACK. So the sender callback should be + * specified either in the services.xml or in the axis2.xml. + */ + + data_handler_res = axiom_data_handler_create(env, NULL, NULL); + axiom_data_handler_set_data_handler_type(data_handler_res, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK); + axiom_data_handler_set_user_param(data_handler_res, env, (void *)location); + + axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE); + ret_node = build_response(env, data_handler_res); + } + else + { + 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"); + return NULL; + } + + return ret_node; +} + +/* Builds the response content */ + + +axiom_node_t *build_response( + const axutil_env_t *env, + axiom_data_handler_t *data_handler) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *text_node = NULL; + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "response", ns1, &mtom_om_node); + + axiom_text_create_with_data_handler(env, mtom_om_node, data_handler, + &text_node); + + return mtom_om_node; +} + +axis2_status_t process_attachments( + axis2_msg_ctx_t *msg_ctx, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name) +{ + axis2_op_ctx_t *op_ctx = NULL; + axis2_msg_ctx_t *in_msg_ctx = NULL; + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + + op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); + if(op_ctx) + { + in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); + if(in_msg_ctx) + { + soap_envelope = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env); + if(soap_envelope) + { + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + if(soap_body) + { + return axiom_soap_body_process_attachments(soap_body, env, user_param, callback_name); + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } +} + diff --git a/samples/server/mtom_callback/mtom_callback.h b/samples/server/mtom_callback/mtom_callback.h new file mode 100644 index 0000000..b7c0057 --- /dev/null +++ b/samples/server/mtom_callback/mtom_callback.h @@ -0,0 +1,33 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 MTOM_CALLBACK_H +#define MTOM_CALLBACK_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_mtom_callback_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx); + +#endif /* MTOM_CALLBACK_H */ diff --git a/samples/server/mtom_callback/mtom_callback.mk b/samples/server/mtom_callback/mtom_callback.mk new file mode 100644 index 0000000..29cca6a --- /dev/null +++ b/samples/server/mtom_callback/mtom_callback.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:mtom_callback.dll + + + + + diff --git a/samples/server/mtom_callback/mtom_skeleton.c b/samples/server/mtom_callback/mtom_skeleton.c new file mode 100644 index 0000000..941521e --- /dev/null +++ b/samples/server/mtom_callback/mtom_skeleton.c @@ -0,0 +1,166 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include "mtom_callback.h" +#include + +int AXIS2_CALL mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { + mtom_init, + mtom_invoke, + mtom_on_fault, + mtom_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_mtom_create( + const axutil_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 = &mtom_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of mtom service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only mtom in this sample, hence invoke mtom method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + return axis2_mtom_callback_mtom(env, node, msg_ctx); +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_node_t *text_node = NULL; + axiom_element_t *error_ele = NULL; + error_ele = axiom_element_create(env, node, "EchoServiceError", NULL, + &error_node); + axiom_element_set_text(error_ele, env, "Echo service failed ", text_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_mtom_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/mtom_callback/services.xml b/samples/server/mtom_callback/services.xml new file mode 100644 index 0000000..7219c8b --- /dev/null +++ b/samples/server/mtom_callback/services.xml @@ -0,0 +1,16 @@ + + mtom_callback + + + + + + + This is a testing service , to test the system is working or not + + + + http://ws.apache.org/axis2/c/samples/mtomCallbackSample + + + diff --git a/samples/server/notify/Makefile.am b/samples/server/notify/Makefile.am new file mode 100644 index 0000000..2e2bf2c --- /dev/null +++ b/samples/server/notify/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/notify +prglib_LTLIBRARIES = libnotify.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml notify.mk notify.h +noinst_HEADERS = notify.h +SUBDIRS = +libnotify_la_SOURCES = notify.c notify_skeleton.c +libnotify_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/notify/notify.c b/samples/server/notify/notify.c new file mode 100644 index 0000000..80dc5bd --- /dev/null +++ b/samples/server/notify/notify.c @@ -0,0 +1,77 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "notify.h" +#include + +void +axis2_notify_notify( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *text_node = NULL; + + if (!env || !env) + { + return; + } + + /* Expected request format is :- + Message 3 + */ + if (!node) /* 'notify' node */ + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: input parameter NULL"); + return; + } + + text_node = axiom_node_get_first_child(node, env); + if (!text_node) /* actual text to notify */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: invalid XML in request"); + return; + } + + if (axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(text_node, env); + if (text && axiom_text_get_value(text, env)) + { + axis2_char_t *text_str = + (axis2_char_t *) axiom_text_get_value(text, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Notification received : %s", text_str); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: invalid XML in request"); + return; + } + + return; +} + diff --git a/samples/server/notify/notify.h b/samples/server/notify/notify.h new file mode 100644 index 0000000..5a175a0 --- /dev/null +++ b/samples/server/notify/notify.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 +#include +#include +#include +#include +#include + +void axis2_notify_notify( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* CALC_H */ diff --git a/samples/server/notify/notify.mk b/samples/server/notify/notify.mk new file mode 100644 index 0000000..9f3d533 --- /dev/null +++ b/samples/server/notify/notify.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:notify.dll + + + + + diff --git a/samples/server/notify/notify_skeleton.c b/samples/server/notify/notify_skeleton.c new file mode 100644 index 0000000..82acf49 --- /dev/null +++ b/samples/server/notify/notify_skeleton.c @@ -0,0 +1,167 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "notify.h" +#include + +int AXIS2_CALL notify_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL notify_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL notify_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL notify_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t notify_svc_skeleton_ops_var = { + notify_init, + notify_invoke, + notify_on_fault, + notify_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_notify_create( + const axutil_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 = ¬ify_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +notify_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of notify service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +notify_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only notify in this sample, hence invoke notify method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + axis2_notify_notify(env, node); + return NULL; +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +notify_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_node_t *text_node = NULL; + axiom_element_t *error_ele = NULL; + error_ele = axiom_element_create(env, node, "NotifyServiceError", NULL, + &error_node); + axiom_element_set_text(error_ele, env, "Notify service failed ", text_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +notify_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_notify_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/notify/services.xml b/samples/server/notify/services.xml new file mode 100644 index 0000000..ff2be47 --- /dev/null +++ b/samples/server/notify/services.xml @@ -0,0 +1,13 @@ + + notify + + + This is a testing service , to test one way service support + + + + + http://example.org/action/notify + + + diff --git a/samples/server/sg_math/Makefile.am b/samples/server/sg_math/Makefile.am new file mode 100644 index 0000000..82cc1ba --- /dev/null +++ b/samples/server/sg_math/Makefile.am @@ -0,0 +1,11 @@ +prglibdir=$(prefix)/services/sg_math +prglib_LTLIBRARIES = libadd.la libsub.la libmul.la libdiv.la +prglib_DATA=services.xml +EXTRA_DIST = services.xml sg_math.mk add.h div.h mul.h sub.h + +noinst_HEADERS = add.h sub.h mul.h div.h +libadd_la_SOURCES = add.c add_skeleton.c +libsub_la_SOURCES = sub.c sub_skeleton.c +libmul_la_SOURCES = mul.c mul_skeleton.c +libdiv_la_SOURCES = div.c div_skeleton.c +INCLUDES = @AXIS2INC@ diff --git a/samples/server/sg_math/add.c b/samples/server/sg_math/add.c new file mode 100644 index 0000000..91cf99a --- /dev/null +++ b/samples/server/sg_math/add.c @@ -0,0 +1,180 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "add.h" +#include +#include + +axiom_node_t * +axis2_add_add( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + 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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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; + + axis2_svc_grp_ctx_t *svc_grp_ctx = 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); + + /* Put the result into service group context */ + svc_grp_ctx = axis2_msg_ctx_get_svc_grp_ctx(msg_ctx, env); + if (svc_grp_ctx) + { + axis2_ctx_t *ctx = NULL; + ctx = axis2_svc_grp_ctx_get_base(svc_grp_ctx, env); + if (ctx) + { + axutil_property_t *prop = NULL; + /* get value */ + prop = axis2_ctx_get_property(ctx, env, "ADD_RESULT"); + if (prop) + { + axis2_char_t *val = + (axis2_char_t *) axutil_property_get_value(prop, env); + printf("Previous result = %s\n", val); + } + /* set value */ + prop = axutil_property_create(env); + if (prop) + { + axutil_property_set_value(prop, env, + axutil_strdup(env, result_str)); + axis2_ctx_set_property(ctx, env, "ADD_RESULT", prop); + } + } + } + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/add.h b/samples/server/sg_math/add.h new file mode 100644 index 0000000..40ec76b --- /dev/null +++ b/samples/server/sg_math/add.h @@ -0,0 +1,33 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 ADD_H +#define ADD_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_add_add( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +#endif /* ADD_H */ diff --git a/samples/server/sg_math/add_skeleton.c b/samples/server/sg_math/add_skeleton.c new file mode 100644 index 0000000..7e7e13a --- /dev/null +++ b/samples/server/sg_math/add_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "add.h" +#include +#include + +int AXIS2_CALL add_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL add_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL add_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t add_svc_skeleton_ops_var = { + add_init, + add_invoke, + NULL, + add_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_add_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &add_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +add_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of add goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +add_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 +add_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding add 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 (axutil_strcmp(op_name, "add") == 0) + return axis2_add_add(env, node, msg_ctx); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = axis2_add_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/sg_math/div.c b/samples/server/sg_math/div.c new file mode 100644 index 0000000..13ac9b5 --- /dev/null +++ b/samples/server/sg_math/div.c @@ -0,0 +1,150 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "div.h" +#include + +axiom_node_t * +axis2_div_div( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/div.h b/samples/server/sg_math/div.h new file mode 100644 index 0000000..3b03e42 --- /dev/null +++ b/samples/server/sg_math/div.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 DIV_H +#define DIV_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_div_div( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* DIV_H */ diff --git a/samples/server/sg_math/div_skeleton.c b/samples/server/sg_math/div_skeleton.c new file mode 100644 index 0000000..9007a58 --- /dev/null +++ b/samples/server/sg_math/div_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "div.h" +#include +#include + +int AXIS2_CALL div_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL div_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL div_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t div_svc_skeleton_ops_var = { + div_init, + div_invoke, + NULL, + div_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_div_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &div_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +div_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of div goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +div_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 +div_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding div 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 (axutil_strcmp(op_name, "div") == 0) + return axis2_div_div(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = axis2_div_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/sg_math/mul.c b/samples/server/sg_math/mul.c new file mode 100644 index 0000000..b86a22b --- /dev/null +++ b/samples/server/sg_math/mul.c @@ -0,0 +1,148 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "mul.h" +#include + +axiom_node_t * +axis2_mul_mul( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/mul.h b/samples/server/sg_math/mul.h new file mode 100644 index 0000000..5e2d243 --- /dev/null +++ b/samples/server/sg_math/mul.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 MUL_H +#define MUL_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_mul_mul( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* MUL_H */ diff --git a/samples/server/sg_math/mul_skeleton.c b/samples/server/sg_math/mul_skeleton.c new file mode 100644 index 0000000..1a58e3b --- /dev/null +++ b/samples/server/sg_math/mul_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "mul.h" +#include +#include + +int AXIS2_CALL mul_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL mul_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL mul_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t mul_svc_skeleton_ops_var = { + mul_init, + mul_invoke, + NULL, + mul_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_mul_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &mul_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +mul_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of mul goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +mul_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 +mul_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding mul 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 (axutil_strcmp(op_name, "mul") == 0) + return axis2_mul_mul(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = axis2_mul_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/sg_math/services.xml b/samples/server/sg_math/services.xml new file mode 100644 index 0000000..524a7ee --- /dev/null +++ b/samples/server/sg_math/services.xml @@ -0,0 +1,30 @@ + + + add + + This is add service, that belongs to the math service group. + + + + + sub + + This is sub service, that belongs to the math service group. + + + + + mul + + This is mul service, that belongs to the math service group. + + + + + div + + This is div service, that belongs to the math service group. + + + + diff --git a/samples/server/sg_math/sg_math.mk b/samples/server/sg_math/sg_math.mk new file mode 100644 index 0000000..5ee16ed --- /dev/null +++ b/samples/server/sg_math/sg_math.mk @@ -0,0 +1,15 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" add.c add_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo add.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:add.dll + + + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" div.c div_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo div.obj /LIBPATH:.\..\..\..\lib axiom.lib axis2_util.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:div.dll + + + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" sub.c sub_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo sub.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:sub.dll + + + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" mul.c mul_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo mul.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:mul.dll diff --git a/samples/server/sg_math/sub.c b/samples/server/sg_math/sub.c new file mode 100644 index 0000000..2b6b4e9 --- /dev/null +++ b/samples/server/sg_math/sub.c @@ -0,0 +1,148 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "sub.h" +#include + +axiom_node_t * +axis2_sub_sub( + const axutil_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("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math 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("Math 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 = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math 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("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/sub.h b/samples/server/sg_math/sub.h new file mode 100644 index 0000000..9083c57 --- /dev/null +++ b/samples/server/sg_math/sub.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 SUB_H +#define SUB_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_sub_sub( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* SUB_H */ diff --git a/samples/server/sg_math/sub_skeleton.c b/samples/server/sg_math/sub_skeleton.c new file mode 100644 index 0000000..aedeac7 --- /dev/null +++ b/samples/server/sg_math/sub_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "sub.h" +#include +#include + +int AXIS2_CALL sub_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL sub_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL sub_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t sub_svc_skeleton_ops_var = { + sub_init, + sub_invoke, + NULL, + sub_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_sub_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &sub_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +sub_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of sub goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +sub_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 +sub_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding sub 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 (axutil_strcmp(op_name, "sub") == 0) + return axis2_sub_sub(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = axis2_sub_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/version/Makefile.am b/samples/server/version/Makefile.am new file mode 100644 index 0000000..9e6f94a --- /dev/null +++ b/samples/server/version/Makefile.am @@ -0,0 +1,10 @@ +prglibdir=$(prefix)/services/version +prglib_LTLIBRARIES = libversion.la +prglib_DATA=services.xml +noinst_HEADERS = version.h +SUBDIRS = +libversion_la_SOURCES = version.c version_skel.c +libversion_la_LIBADD = +INCLUDES = @AXIS2INC@ +EXTRA_DIST = services.xml version.h + diff --git a/samples/server/version/services.xml b/samples/server/version/services.xml new file mode 100644 index 0000000..37bdc6b --- /dev/null +++ b/samples/server/version/services.xml @@ -0,0 +1,9 @@ + + version + + This is a testing service, named 'version' to test multiple operations in the same service + + + + + diff --git a/samples/server/version/version.c b/samples/server/version/version.c new file mode 100644 index 0000000..81182eb --- /dev/null +++ b/samples/server/version/version.c @@ -0,0 +1,59 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "version.h" +#include + +axiom_node_t * +axis2_version_get_version( + const axutil_env_t * env, + axiom_node_t * node) +{ + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + else + { + 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; + + sprintf(result_str, "%s", "Version 1.6"); + + ns1 = axiom_namespace_create(env, + "urn:aewebservices71", "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("Math service ERROR: invalid parameters\n"); + return NULL; +} + diff --git a/samples/server/version/version.h b/samples/server/version/version.h new file mode 100644 index 0000000..56fc54e --- /dev/null +++ b/samples/server/version/version.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 MATH_H +#define MATH_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_version_get_version( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* MATH_H */ diff --git a/samples/server/version/version_skel.c b/samples/server/version/version_skel.c new file mode 100644 index 0000000..961c3d8 --- /dev/null +++ b/samples/server/version/version_skel.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "version.h" +#include +#include + +int AXIS2_CALL version_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL version_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL version_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t version_svc_skeleton_ops_var = { + version_init, + version_invoke, + NULL, + version_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +version_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &version_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +version_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of version goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +version_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + 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 +version_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding version 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 (axutil_strcmp(op_name, "GetVersion") == 0) + return axis2_version_get_version(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: 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 axutil_env_t * env) +{ + *inst = version_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} -- cgit v1.1-32-gdbae