[prev in list] [next in list] [prev in thread] [next in thread]
List: axis-cvs
Subject: svn commit: r373880 - in /webservices/axis2/trunk/c/test/client/math: ./
From: samisa () apache ! org
Date: 2006-01-31 18:10:44
Message-ID: 20060131181045.37815.qmail () minotaur ! apache ! org
[Download RAW message or body]
Author: samisa
Date: Tue Jan 31 10:10:36 2006
New Revision: 373880
URL: http://svn.apache.org/viewcvs?rev=373880&view=rev
Log:
Adding the math client sample
Added:
webservices/axis2/trunk/c/test/client/math/
webservices/axis2/trunk/c/test/client/math/Makefile.am
webservices/axis2/trunk/c/test/client/math/axis2_math_stub.c
webservices/axis2/trunk/c/test/client/math/axis2_math_stub.h
webservices/axis2/trunk/c/test/client/math/math_client.c
Added: webservices/axis2/trunk/c/test/client/math/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/client/math/Makefile.am?rev=373880&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/client/math/Makefile.am (added)
+++ webservices/axis2/trunk/c/test/client/math/Makefile.am Tue Jan 31 10:10:36 2006
@@ -0,0 +1,38 @@
+bin_PROGRAMS = math
+math_SOURCES = axis2_math_stub.c \
+ math_client.c
+
+math_LDADD = -L$(AXIS2C_HOME)/lib \
+ -laxis2_util \
+ -laxis2_context \
+ -laxis2_description \
+ -laxis2_deployment \
+ -laxis2_phaseresolver \
+ -laxis2_om \
+ -laxis2_wsdl \
+ -laxis2_engine \
+ -laxis2_parser \
+ -laxis2_addr \
+ -laxis2_unix \
+ -laxis2_receivers \
+ -laxis2_core_util \
+ -laxis2_clientapi \
+ -laxis2_soap \
+ -laxis2_http_transport \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ -L$(GUTHTHILA_LIB) $(GUTHTHILA_LIBNAME) \
+ -L$(LIBXML2_LIB) $(LIBXML2_LIBNAME)
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/modules/util \
+ -I$(top_builddir)/modules/core/description \
+ -I$(top_builddir)/modules/core/deployment \
+ -I$(top_builddir)/modules/wsdl \
+ -I$(top_builddir)/modules/core/transport \
+ -I$(top_builddir)/modules/platforms \
+ -I$(top_builddir)/modules/xml/parser \
+ -I$(top_builddir)/include
+
+
+
Added: webservices/axis2/trunk/c/test/client/math/axis2_math_stub.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/client/math/axis2_math_stub.c?rev=373880&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/client/math/axis2_math_stub.c (added)
+++ webservices/axis2/trunk/c/test/client/math/axis2_math_stub.c Tue Jan 31 10:10:36 \
2006 @@ -0,0 +1,131 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "axis2_math_stub.h"
+#include <axis2_om_node.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_call.h>
+
+
+axis2_stub_t *AXIS2_CALL
+axis2_math_stub_create_with_endpoint_ref_and_client_home(axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref,
+ axis2_char_t *client_home)
+{
+ axis2_stub_t *stub = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ stub = (axis2_stub_t *)
+ axis2_stub_create_with_endpoint_ref_and_client_home(env, endpoint_ref,
+ client_home);
+ if(NULL == stub)
+ {
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ return stub;
+}
+
+axis2_stub_t *AXIS2_CALL
+axis2_math_stub_create_with_endpoint_uri_and_client_home(axis2_env_t **env,
+ axis2_char_t *endpoint_uri,
+ axis2_char_t *client_home)
+{
+ axis2_stub_t *stub = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ stub = (axis2_stub_t *)
+ axis2_stub_create_with_endpoint_uri_and_client_home(env, endpoint_uri,
+ client_home);
+ if(NULL == stub)
+ {
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+
+ return stub;
+}
+
+/***************************Function implementation****************************/
+
+axis2_om_node_t *AXIS2_CALL
+axis2_math_stub_add(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node)
+{
+ axis2_call_t *call = NULL;
+ axis2_om_node_t *ret_node = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ call = AXIS2_STUB_GET_CALL_OBJ(stub, env);
+ ret_node = AXIS2_CALL_INVOKE_BLOCKING_WITH_OM(call, env, "add", node);
+
+ return ret_node;
+}
+
+axis2_om_node_t *AXIS2_CALL
+axis2_math_stub_sub(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node)
+{
+ axis2_call_t *call = NULL;
+ axis2_om_node_t *ret_node = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ call = AXIS2_STUB_GET_CALL_OBJ(stub, env);
+ ret_node = AXIS2_CALL_INVOKE_BLOCKING_WITH_OM(call, env, "sub", node);
+
+ return ret_node;
+}
+
+axis2_om_node_t *AXIS2_CALL
+axis2_math_stub_mul(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node)
+{
+ axis2_call_t *call = NULL;
+ axis2_om_node_t *ret_node = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ call = AXIS2_STUB_GET_CALL_OBJ(stub, env);
+ ret_node = AXIS2_CALL_INVOKE_BLOCKING_WITH_OM(call, env, "mul", node);
+
+ return ret_node;
+}
+
+axis2_om_node_t *AXIS2_CALL
+axis2_math_stub_div(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node)
+{
+ axis2_call_t *call = NULL;
+ axis2_om_node_t *ret_node = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ call = AXIS2_STUB_GET_CALL_OBJ(stub, env);
+ ret_node = AXIS2_CALL_INVOKE_BLOCKING_WITH_OM(call, env, "div", node);
+
+ return ret_node;
+}
+
Added: webservices/axis2/trunk/c/test/client/math/axis2_math_stub.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/client/math/axis2_math_stub.h?rev=373880&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/client/math/axis2_math_stub.h (added)
+++ webservices/axis2/trunk/c/test/client/math/axis2_math_stub.h Tue Jan 31 10:10:36 \
2006 @@ -0,0 +1,83 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_ECHO_STUB_H
+#define AXIS2_ECHO_STUB_H
+
+/**
+ * @file axis2_math_stub.h
+ * @brief axis2 math stub interface
+ */
+
+#include <axis2.h>
+#include <axis2_error.h>
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axis2_allocator.h>
+#include <axis2_stub.h>
+#include <axis2_endpoint_ref.h>
+#include <axis2_om_node.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_DECLARE(axis2_om_node_t *)
+axis2_math_stub_add(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node);
+
+AXIS2_DECLARE(axis2_om_node_t *)
+axis2_math_stub_sub(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node);
+
+AXIS2_DECLARE(axis2_om_node_t *)
+axis2_math_stub_mul(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node);
+
+AXIS2_DECLARE(axis2_om_node_t *)
+axis2_math_stub_div(axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_om_node_t *node);
+
+/**
+ * Creates axis2_stub struct
+ * @param endpoint reference
+ * @return pointer to newly created axis2_stub struct
+ */
+AXIS2_DECLARE(axis2_stub_t *)
+axis2_math_stub_create_with_endpoint_ref_and_client_home(axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref,
+ axis2_char_t *client_home);
+
+/**
+ * Creates axis2_stub struct
+ * @param endpoint uri
+ * @return pointer to newly created axis2_stub struct
+ */
+AXIS2_DECLARE(axis2_stub_t *)
+axis2_math_stub_create_with_endpoint_uri_and_client_home(axis2_env_t **env,
+ axis2_char_t *endpoint_uri,
+ axis2_char_t *client_home);
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* AXIS2_ECHO_STUB_H */
Added: webservices/axis2/trunk/c/test/client/math/math_client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/client/math/math_client.c?rev=373880&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/client/math/math_client.c (added)
+++ webservices/axis2/trunk/c/test/client/math/math_client.c Tue Jan 31 10:10:36 2006
@@ -0,0 +1,158 @@
+#include "axis2_math_stub.h"
+#include <axis2_om_stax_builder.h>
+#include <axis2_om_document.h>
+#include <axis2_om_node.h>
+#include <axis2_om_element.h>
+#include <axis2_om_text.h>
+#include <axis2_stream_default.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axis2_xml_reader.h>
+#include <stdio.h>
+#include <axis2_xml_writer.h>
+#include <axis2_soap_builder.h>
+#include <axis2_soap.h>
+#include <axis2_soap_envelope.h>
+#include <axis2_soap_body.h>
+#include <axis2_soap_header.h>
+#include <axis2_soap_message.h>
+#include <axis2_soap_header_block.h>
+#include <axis2_soap_fault.h>
+#include <axis2_soap_fault_code.h>
+#include <axis2_soap_fault_role.h>
+
+axis2_om_node_t *
+build_om_programatically(axis2_env_t **env, axis2_char_t *operation, axis2_char_t \
*param1, axis2_char_t *param2); +
+int main(int argc, char** argv)
+{
+ axis2_stub_t *stub = NULL;
+ axis2_om_node_t *node = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_env_t *env = NULL;
+ axis2_error_t *error = NULL;
+ axis2_log_t *log = NULL;
+ axis2_allocator_t *allocator = NULL;
+ axis2_char_t *address = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_om_node_t *ret_node = NULL;
+
+ axis2_char_t *operation = "add";
+ axis2_char_t *param1 = "40";
+ axis2_char_t *param2 = "8";
+
+ allocator = axis2_allocator_init (NULL);
+ error = axis2_error_create(allocator);
+ log = axis2_log_create(allocator, NULL);
+ env = axis2_env_create_with_error_log(allocator, error, log);
+ env->log->level = AXIS2_LOG_LEVEL_INFO;
+ axis2_error_init();
+
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home)
+ client_home = "../../deploy";
+
+ address = "http://localhost:9090/axis2/services/math";
+ if (argc > 1 )
+ operation = argv[1];
+ if (AXIS2_STRCMP(operation, "-h") == 0)
+ {
+ printf("Usage : %s [operation] [param1] [param2] [endpoint_url]\n", \
argv[0]); + printf("use -h for help\n");
+ printf("default operation add\n");
+ printf("default param1 %s\n", param1);
+ printf("default param2 %s\n", param2);
+ printf("default endpoint_url %s\n", address);
+ printf("NOTE: command line arguments must appear in given order, with \
trailing ones being optional\n"); + return 0;
+ }
+ if (argc > 2 )
+ param1 = argv[2];
+ if (argc > 3 )
+ param2 = argv[3];
+ if (argc > 4 )
+ address = argv[4];
+
+ printf ("Using endpoint : %s\n", address);
+ printf ("\nInvoking operation %s with params %s and %s\n", operation, param1, \
param2); +
+ node = build_om_programatically(&env, operation, param1, param2);
+ stub =
+ axis2_stub_create_with_endpoint_uri_and_client_home(&env, address,
+ client_home);
+ AXIS2_STUB_SET_TRANSPORT_INFO(stub, &env, AXIS2_TRANSPORT_HTTP,
+ AXIS2_TRANSPORT_HTTP, AXIS2_FALSE);
+ /* create node and invoke math */
+ ret_node = axis2_math_stub_add(stub, &env, node);
+ if(ret_node)
+ {
+ if (AXIS2_OM_NODE_GET_NODE_TYPE(ret_node, &env) == AXIS2_OM_ELEMENT)
+ {
+ axis2_char_t *result = NULL;
+ axis2_om_element_t *result_ele = \
(axis2_om_element_t*)AXIS2_OM_NODE_GET_DATA_ELEMENT(ret_node, &env); +
+ result = AXIS2_OM_ELEMENT_GET_TEXT(result_ele, &env, ret_node);
+ printf( "\nResult = %s\n", result);
+ }
+ else
+ {
+ axis2_xml_writer_t *writer = NULL;
+ axis2_om_output_t *om_output = NULL;
+ axis2_char_t *buffer = NULL;
+ writer = axis2_xml_writer_create_for_memory(&env, NULL, AXIS2_TRUE, 0);
+ om_output = axis2_om_output_create (&env, writer);
+
+ AXIS2_OM_NODE_SERIALIZE (ret_node, &env, om_output);
+ buffer = AXIS2_XML_WRITER_GET_XML(writer, &env);
+ printf ("\nReceived invalid OM as result : %s\n", buffer);
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server start failed: Error code:"
+ " %d :: %s", env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("math stub invoke failed!\n");
+ }
+
+ if (node)
+ {
+ AXIS2_OM_NODE_FREE_TREE(node, &env);
+ }
+ return status;
+}
+
+axis2_om_node_t *
+build_om_programatically(axis2_env_t **env, axis2_char_t *operation, axis2_char_t \
*param1, axis2_char_t *param2) +{
+ axis2_om_node_t *math_om_node = NULL;
+ axis2_om_element_t* math_om_ele = NULL;
+ axis2_om_node_t* text_om_node = NULL;
+ axis2_om_element_t * text_om_ele = NULL;
+ axis2_om_namespace_t *ns1 = NULL;
+
+
+ axis2_xml_writer_t *xml_writer = NULL;
+ axis2_om_output_t *om_output = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 = axis2_om_namespace_create (env, \
"http://localhost:9090/axis2/services/math", "ns1"); +
+ math_om_ele = axis2_om_element_create(env, NULL, operation, ns1, &math_om_node);
+
+ text_om_ele = axis2_om_element_create(env, math_om_node, "param1", NULL, \
&text_om_node); + AXIS2_OM_ELEMENT_SET_TEXT(text_om_ele, env, param1, \
text_om_node); +
+ text_om_ele = axis2_om_element_create(env, math_om_node, "param2", NULL, \
&text_om_node); + AXIS2_OM_ELEMENT_SET_TEXT(text_om_ele, env, param2, \
text_om_node); +
+ xml_writer = axis2_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, \
AXIS2_FALSE); + om_output = axis2_om_output_create( env, xml_writer);
+
+ AXIS2_OM_NODE_SERIALIZE(math_om_node, env, om_output);
+ buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
+ AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n", \
buffer); +
+ return math_om_node;
+}
+
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic