summaryrefslogtreecommitdiffstats
path: root/samples/server/Calculator
diff options
context:
space:
mode:
Diffstat (limited to 'samples/server/Calculator')
-rw-r--r--samples/server/Calculator/Calculator.mk7
-rw-r--r--samples/server/Calculator/Calculator.wsdl183
-rw-r--r--samples/server/Calculator/Makefile.am9
-rw-r--r--samples/server/Calculator/calc.c553
-rw-r--r--samples/server/Calculator/calc.h41
-rw-r--r--samples/server/Calculator/calc_skeleton.c157
-rw-r--r--samples/server/Calculator/services.xml28
7 files changed, 978 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- -->
+<!-- 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. -->
+<!-- -->
+<wsdl:definitions
+ targetNamespace="http://ws.apache.org/axis2/services/Calculator"
+ xmlns:impl="http://ws.apache.org/axis2/services/Calculator"
+ xmlns:type="http://ws.apache.org/axis2/services/Calculator/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema
+ targetNamespace="http://ws.apache.org/axis2/services/Calculator/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:impl="http://ws.apache.org/axis2/services/Calculator"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <element name="add">
+ <complexType>
+ <sequence>
+ <element name="param_1" type="xsd:int"/>
+ <element name="param_2" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="addResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="sub">
+ <complexType>
+ <sequence>
+ <element name="param_1" type="xsd:int"/>
+ <element name="param_2" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="subResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="mul">
+ <complexType>
+ <sequence>
+ <element name="param_1" type="xsd:int"/>
+ <element name="param_2" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="mulResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="div">
+ <complexType>
+ <sequence>
+ <element name="param_1" type="xsd:int"/>
+ <element name="param_2" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="divResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="addResponse">
+ <wsdl:part element="type:addResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="addRequest">
+ <wsdl:part element="type:add" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="subResponse">
+ <wsdl:part element="type:subResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="subRequest">
+ <wsdl:part element="type:sub" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="divResponse">
+ <wsdl:part element="type:divResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="divRequest">
+ <wsdl:part element="type:div" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="mulResponse">
+ <wsdl:part element="type:mulResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="mulRequest">
+ <wsdl:part element="type:mul" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="CalculatorPortType">
+ <wsdl:operation name="add">
+ <wsdl:input message="impl:addRequest" name="addRequest"/>
+ <wsdl:output message="impl:addResponse" name="addResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="sub">
+ <wsdl:input message="impl:subRequest" name="subRequest"/>
+ <wsdl:output message="impl:subResponse" name="subResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="mul">
+ <wsdl:input message="impl:mulRequest" name="mulRequest"/>
+ <wsdl:output message="impl:mulResponse" name="mulResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="div">
+ <wsdl:input message="impl:divRequest" name="divRequest"/>
+ <wsdl:output message="impl:divResponse" name="divResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="CalculatorSoapBinding" type="impl:CalculatorPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="add">
+ <soap:operation soapAction="Calculator#add"/>
+ <wsdl:input name="addRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="addResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sub">
+ <soap:operation soapAction="Calculator#sub"/>
+ <wsdl:input name="subRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="subResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="mul">
+ <soap:operation soapAction="Calculator#mul"/>
+ <wsdl:input name="mulRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="mulResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="div">
+ <soap:operation soapAction="Calculator#div"/>
+ <wsdl:input name="divRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="divResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="Calculator">
+ <wsdl:port binding="impl:CalculatorSoapBinding" name="CalculatorSOAPport_http">
+ <soap:address location="http://localhost:9090/axis2/services/Calculator"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
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 <stdio.h>
+
+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 <axis2_svc_skeleton.h>
+#include <axutil_log_default.h>
+#include <axutil_error_default.h>
+#include <axiom_text.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+
+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 <axutil_array_list.h>
+#include <stdio.h>
+
+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 @@
+<service name="Calculator">
+ <parameter name="ServiceClass" locked="xsd:false">Calculator</parameter>
+
+ <description>
+ This is a testing service, named 'Calculator' to test dynamic client
+ </description>
+
+ <operation name="add">
+ <!--messageReceiver class="axis2_receivers" /-->
+ <parameter name="wsamapping" >Calculator#add</parameter>
+ </operation>
+
+ <operation name="sub">
+ <!--messageReceiver class="axis2_receivers" /-->
+ <parameter name="wsamapping" >Calculator#sub</parameter>
+ </operation>
+
+ <operation name="mul">
+ <!--messageReceiver class="axis2_receivers" /-->
+ <parameter name="wsamapping" >Calculator#mul</parameter>
+ </operation>
+
+ <operation name="div">
+ <!--messageReceiver class="axis2_receivers" /-->
+ <parameter name="wsamapping" >Calculator#div</parameter>
+ </operation>
+
+</service>