You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by da...@apache.org on 2006/11/06 12:38:00 UTC
svn commit: r471700 - in /webservices/sandesha/trunk/c/samples: rm_echo/
rm_echo/Makefile.am rm_echo/echo_util.c rm_echo/echo_util.h
rm_echo/rm_echo_client.c rm_ping/ rm_ping/Makefile.am
rm_ping/rm_ping_client.c
Author: damitha
Date: Mon Nov 6 03:37:59 2006
New Revision: 471700
URL: http://svn.apache.org/viewvc?view=rev&rev=471700
Log:
added new samples
Added:
webservices/sandesha/trunk/c/samples/rm_echo/
webservices/sandesha/trunk/c/samples/rm_echo/Makefile.am
webservices/sandesha/trunk/c/samples/rm_echo/echo_util.c
webservices/sandesha/trunk/c/samples/rm_echo/echo_util.h
webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c
webservices/sandesha/trunk/c/samples/rm_ping/
webservices/sandesha/trunk/c/samples/rm_ping/Makefile.am
webservices/sandesha/trunk/c/samples/rm_ping/rm_ping_client.c
Added: webservices/sandesha/trunk/c/samples/rm_echo/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo/Makefile.am?view=auto&rev=471700
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo/Makefile.am (added)
+++ webservices/sandesha/trunk/c/samples/rm_echo/Makefile.am Mon Nov 6 03:37:59 2006
@@ -0,0 +1,24 @@
+prgbindir=$(prefix)/bin/samples
+prgbin_PROGRAMS = rm_echo
+samplesdir=$(prefix)/samples/client/rm_echo
+samples_DATA=rm_echo_client.c Makefile.am Makefile.in
+rm_echo_SOURCES = rm_echo_client.c echo_util.c
+
+rm_echo_LDADD = \
+ -L$(AXIS2C_HOME)/lib \
+ -laxis2_util \
+ -laxis2_axiom \
+ -laxis2_wsdl \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ -lwoden \
+ -laxis2_xml_schema \
+ $(GUTHTHILA_LIBS) \
+ $(LIBXML2_LIBS)
+
+INCLUDES = -I$(AXIS2C_HOME)/include \
+ @UTILINC@ \
+ @AXIOMINC@
Added: webservices/sandesha/trunk/c/samples/rm_echo/echo_util.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo/echo_util.c?view=auto&rev=471700
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo/echo_util.c (added)
+++ webservices/sandesha/trunk/c/samples/rm_echo/echo_util.c Mon Nov 6 03:37:59 2006
@@ -0,0 +1,50 @@
+/*
+ * 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 "echo_util.h"
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_payload_for_echo_svc(
+ const axis2_env_t *env,
+ axis2_char_t *text,
+ axis2_char_t *seq)
+{
+ 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_node_t* seq_om_node = NULL;
+ axiom_element_t * seq_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *om_str = NULL;
+ axis2_char_t *ns = NULL;
+
+ ns = "http://tempuri.org/";
+
+ ns1 = axiom_namespace_create (env, ns, "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", ns1, &text_om_node);
+ seq_om_ele = axiom_element_create(env, echo_om_node, "Sequence", ns1, &seq_om_node);
+ AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, text, text_om_node);
+ AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, seq, seq_om_node);
+
+ om_str = AXIOM_NODE_TO_STRING(echo_om_node, env);
+ if (om_str)
+ printf("\nSending OM : %s\n", om_str);
+
+ return echo_om_node;
+}
Added: webservices/sandesha/trunk/c/samples/rm_echo/echo_util.h
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo/echo_util.h?view=auto&rev=471700
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo/echo_util.h (added)
+++ webservices/sandesha/trunk/c/samples/rm_echo/echo_util.h Mon Nov 6 03:37:59 2006
@@ -0,0 +1,29 @@
+/*
+ * 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_UG_ECHO_UTIL_H
+#define AXIS2_UG_ECHO_UTIL_H
+
+#include <stdio.h>
+#include <axiom.h>
+
+axiom_node_t *
+build_om_payload_for_echo_svc(
+ const axis2_env_t *env,
+ axis2_char_t *text,
+ axis2_char_t *seq);
+
+#endif
Added: webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c?view=auto&rev=471700
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c (added)
+++ webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c Mon Nov 6 03:37:59 2006
@@ -0,0 +1,370 @@
+/*
+ * 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 "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+#include <axis2_svc_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_op_client.h>
+#include <axis2_listener_manager.h>
+#include <callback_recv.h>
+
+/* on_complete callback function */
+axis2_status_t AXIS2_CALL
+rm_echo_callback_on_complete(struct axis2_callback *callback,
+ const axis2_env_t *env);
+
+/* on_error callback function */
+axis2_status_t AXIS2_CALL
+rm_echo_callback_on_error(struct axis2_callback *callback,
+ const axis2_env_t *env,
+ int exception);
+
+void wait_on_callback(
+ const axis2_env_t *env,
+ axis2_callback_t *callback);
+
+static axis2_status_t
+send_non_blocking(
+ const axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ axis2_options_t *options,
+ axis2_qname_t *op_qname,
+ axis2_callback_t *callback,
+ axiom_node_t *payload,
+ axis2_listener_manager_t *listner_manager);
+
+static axis2_bool_t
+fill_soap_envelope(
+ const axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ axis2_msg_ctx_t *msg_ctx,
+ axis2_options_t *options,
+ const axiom_node_t *payload);
+
+int main(int argc, char** argv)
+{
+ const axis2_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t* endpoint_ref = NULL;
+ axis2_endpoint_ref_t* reply_to = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t* svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axis2_callback_t *callback = NULL;
+ axis2_callback_t *callback2 = NULL;
+ axis2_callback_t *callback3 = NULL;
+ axis2_property_t *property = NULL;
+ axis2_listener_manager_t *listener_manager = NULL;
+
+ /* Set up the environment */
+ env = axis2_env_create_all("echo_non_blocking_dual.log",
+ AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ /*address = "http://127.0.0.1:8888/axis2/services/RMSampleService";*/
+ address = "http://127.0.0.1:5555/axis2/services/RMSampleService";
+ if (argc > 1 )
+ address = argv[1];
+ if (AXIS2_STRCMP(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf ("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref);
+ AXIS2_OPTIONS_SET_USE_SEPARATE_LISTENER(options, env, AXIS2_TRUE);
+
+ /* Seperate listner needs addressing, hence addressing stuff in options */
+ /*AXIS2_OPTIONS_SET_ACTION(options, env,
+ "http://127.0.0.1:8080/axis2/services/RMSampleService/anonOutInOp");*/
+ reply_to = axis2_endpoint_ref_create(env,
+ "http://localhost:7777/axis2/services/__ANONYMOUS_SERVICE__/"\
+ "__OPERATION_OUT_IN__");
+
+ AXIS2_OPTIONS_SET_REPLY_TO(options, env, reply_to);
+ property = axis2_property_create(env);
+ AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_APPLICATION);
+ AXIS2_PROPERTY_SET_VALUE(property, env, AXIS2_VALUE_TRUE);
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is
+ * picked up using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder.
+ * The client_home can be different from this folder on your system. For
+ * example, you may have a different folder (say, my_client_folder) with its
+ * own axis2.xml file. my_client_folder/modules will have the modules that
+ * the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home)
+ client_home = "../../deploy";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf("Error creating service client\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:"
+ " %d :: %s", env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options);
+
+ AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, AXIS2_MODULE_ADDRESSING);
+ AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, "sandesha2");
+
+ listener_manager = axis2_listener_manager_create(env);
+ if (!listener_manager)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ payload = build_om_payload_for_echo_svc(env, "echo1", "sequence1");
+ callback = axis2_callback_create(env);
+ AXIS2_CALLBACK_SET_ON_COMPLETE(callback, rm_echo_callback_on_complete);
+ AXIS2_CALLBACK_SET_ON_ERROR(callback, rm_echo_callback_on_error);
+ send_non_blocking(env, svc_client, options, NULL, callback, payload,
+ listener_manager);
+
+ wait_on_callback(env, callback);
+
+ payload = build_om_payload_for_echo_svc(env, "echo2", "sequence1");
+ callback2 = axis2_callback_create(env);
+ AXIS2_CALLBACK_SET_ON_COMPLETE(callback2, rm_echo_callback_on_complete);
+ AXIS2_CALLBACK_SET_ON_ERROR(callback2, rm_echo_callback_on_error);
+ send_non_blocking(env, svc_client, options, NULL, callback2, payload,
+ listener_manager);
+ wait_on_callback(env, callback2);
+
+ callback3 = axis2_callback_create(env);
+ AXIS2_CALLBACK_SET_ON_COMPLETE(callback3, rm_echo_callback_on_complete);
+ AXIS2_CALLBACK_SET_ON_ERROR(callback3, rm_echo_callback_on_error);
+ payload = build_om_payload_for_echo_svc(env, "echo3", "sequence1");
+ AXIS2_OPTIONS_SET_PROPERTY(options, env, "Sandesha2LastMessage",
+ property);
+ send_non_blocking(env, svc_client, options, NULL, callback3, payload,
+ listener_manager);
+ wait_on_callback(env, callback3);
+ AXIS2_SLEEP(10);
+ if (svc_client)
+ {
+ AXIS2_SVC_CLIENT_FREE(svc_client, env);
+ svc_client = NULL;
+ }
+
+ return 0;
+}
+
+axis2_status_t AXIS2_CALL
+rm_echo_callback_on_complete(
+ struct axis2_callback *callback,
+ const axis2_env_t *env)
+{
+ /** SOAP response has arrived here; get the soap envelope
+ from the callback object and do whatever you want to do with it */
+
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_node_t *ret_node = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ printf("inside on_complete_callback function\n");
+
+ soap_envelope = AXIS2_CALLBACK_GET_ENVELOPE(callback, env);
+
+ if (!soap_envelope)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:"
+ " %d :: %s", env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo stub invoke FAILED!\n");
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ ret_node = AXIOM_SOAP_ENVELOPE_GET_BASE_NODE(soap_envelope, env);
+
+ if(!ret_node)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:%d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo stub invoke FAILED!\n");
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = AXIOM_NODE_TO_STRING(ret_node, env);
+ if (om_str)
+ printf("\nReceived OM : %s\n", om_str);
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ }
+ return status;
+}
+
+axis2_status_t AXIS2_CALL
+rm_echo_callback_on_error(
+ struct axis2_callback *callback,
+ const axis2_env_t *env,
+ int exception)
+{
+ /** take necessary action on error */
+ printf("\nEcho client invoke FAILED. Error code:%d ::%s", exception,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return AXIS2_SUCCESS;
+}
+
+void wait_on_callback(
+ const axis2_env_t *env,
+ axis2_callback_t *callback)
+{
+ /** Wait till callback is complete. Simply keep the parent thread running
+ until our on_complete or on_error is invoked */
+ while(1)
+ {
+ if (AXIS2_CALLBACK_GET_COMPLETE(callback, env))
+ {
+ /* We are done with the callback */
+ break;
+ }
+ }
+ return;
+}
+
+static axis2_status_t
+send_non_blocking(
+ const axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ axis2_options_t *options,
+ axis2_qname_t *op_qname,
+ axis2_callback_t *callback,
+ axiom_node_t *payload,
+ axis2_listener_manager_t *listener_manager)
+{
+ axis2_op_client_t *op_client = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_msg_ctx_t *msg_ctx = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_op_t *op = NULL;
+ axis2_callback_recv_t *callback_recv = NULL;
+ const axis2_char_t *transport_in_protocol = NULL;
+ axis2_callback_t *callback_temp = NULL;
+
+ if(!op_qname)
+ op_qname = axis2_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
+ svc_ctx = AXIS2_SVC_CLIENT_GET_SVC_CTX(svc_client, env);
+ conf_ctx = AXIS2_SVC_CTX_GET_CONF_CTX(svc_ctx, env);
+ msg_ctx = axis2_msg_ctx_create(env, conf_ctx, NULL, NULL);
+ svc = AXIS2_SVC_CLIENT_GET_AXIS_SERVICE(svc_client, env);
+ op = AXIS2_SVC_GET_OP_WITH_QNAME(svc, env,
+ op_qname);
+ op_client = axis2_op_client_create(env, op, svc_ctx, options);
+ if (!op_client)
+ {
+ return AXIS2_FAILURE;
+ }
+ if (!fill_soap_envelope(env, svc_client, msg_ctx, options, payload))
+ return AXIS2_FAILURE;
+ AXIS2_OP_CLIENT_SET_CALLBACK(op_client, env, callback);
+ AXIS2_OP_CLIENT_ADD_OUT_MSG_CTX(op_client, env, msg_ctx);
+ transport_in_protocol = AXIS2_OPTIONS_GET_TRANSPORT_IN_PROTOCOL(
+ options, env);
+ if (!transport_in_protocol)
+ transport_in_protocol = AXIS2_TRANSPORT_HTTP;
+ AXIS2_LISTNER_MANAGER_MAKE_SURE_STARTED(listener_manager, env,
+ transport_in_protocol, conf_ctx);
+ callback_recv = axis2_callback_recv_create(env);
+ if (!(callback_recv))
+ {
+ axis2_svc_client_free(svc_client, env);
+ return AXIS2_FAILURE;
+ }
+
+ AXIS2_OP_SET_MSG_RECV(op, env,
+ AXIS2_CALLBACK_RECV_GET_BASE(callback_recv, env));
+ AXIS2_OP_CLIENT_SET_CALLBACK_RECV(op_client, env, callback_recv);
+ return AXIS2_OP_CLIENT_EXECUTE(op_client, env, AXIS2_FALSE);
+}
+
+static axis2_bool_t
+fill_soap_envelope(
+ const axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ axis2_msg_ctx_t *msg_ctx,
+ axis2_options_t *options,
+ const axiom_node_t *payload)
+{
+ const axis2_char_t *soap_version_uri;
+ int soap_version;
+ axiom_soap_envelope_t *envelope = NULL;
+
+ soap_version_uri = AXIS2_OPTIONS_GET_SOAP_VERSION_URI(options, env);
+
+ if (!soap_version_uri)
+ {
+ return AXIS2_FALSE;
+ }
+
+ if (AXIS2_STRCMP(soap_version_uri,
+ AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0)
+ soap_version = AXIOM_SOAP11;
+ else
+ soap_version = AXIOM_SOAP12;
+
+
+ envelope = axiom_soap_envelope_create_default_soap_envelope(env,
+ soap_version);
+ if (!envelope)
+ {
+ return AXIS2_FALSE;
+ }
+
+ if (payload)
+ {
+ axiom_soap_body_t *soap_body = NULL;
+ soap_body = AXIOM_SOAP_ENVELOPE_GET_BODY(envelope, env);
+ if (soap_body)
+ {
+ axiom_node_t *node = NULL;
+ node = AXIOM_SOAP_BODY_GET_BASE_NODE(soap_body, env);
+ if (node)
+ {
+ AXIOM_NODE_ADD_CHILD(node, env, (axiom_node_t *)payload);
+ }
+ }
+ }
+
+ AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(msg_ctx, env, envelope);
+
+ return AXIS2_TRUE;
+}
+
Added: webservices/sandesha/trunk/c/samples/rm_ping/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_ping/Makefile.am?view=auto&rev=471700
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_ping/Makefile.am (added)
+++ webservices/sandesha/trunk/c/samples/rm_ping/Makefile.am Mon Nov 6 03:37:59 2006
@@ -0,0 +1,24 @@
+prgbindir=$(prefix)/bin/samples
+prgbin_PROGRAMS = rm_ping
+samplesdir=$(prefix)/samples/client/rm_ping
+samples_DATA=rm_ping_client.c Makefile.am Makefile.in
+rm_ping_SOURCES = rm_ping_client.c
+
+rm_ping_LDADD = \
+ -L$(AXIS2C_HOME)/lib \
+ -laxis2_util \
+ -laxis2_axiom \
+ -laxis2_wsdl \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ -lwoden \
+ -laxis2_xml_schema \
+ $(GUTHTHILA_LIBS) \
+ $(LIBXML2_LIBS)
+
+INCLUDES = -I$(AXIS2C_HOME)/include \
+ @UTILINC@ \
+ @AXIOMINC@
Added: webservices/sandesha/trunk/c/samples/rm_ping/rm_ping_client.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_ping/rm_ping_client.c?view=auto&rev=471700
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_ping/rm_ping_client.c (added)
+++ webservices/sandesha/trunk/c/samples/rm_ping/rm_ping_client.c Mon Nov 6 03:37:59 2006
@@ -0,0 +1,166 @@
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+#define MAX_COUNT 10
+
+axiom_node_t *
+build_om_programatically(
+ const axis2_env_t *env,
+ axis2_char_t *text);
+
+int main(int argc, char** argv)
+{
+ const axis2_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ const axis2_char_t *to = NULL;
+ axis2_endpoint_ref_t* endpoint_ref = NULL;
+ axis2_endpoint_ref_t* target_epr = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t* svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_property_t *property = NULL;
+ int count = 0;
+
+ /* Set up the environment */
+ env = axis2_env_create_all("rm_ping.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ /*address = "http://127.0.0.1:8888/axis2/services/RMSampleService";*/
+ address = "http://127.0.0.1:5555/axis2/services/RMSampleService";
+ /*to = "http://127.0.0.1:8080/axis2/services/RMSampleService";*/
+ to = "http://127.0.0.1:9090/axis2/services/RMSampleService";
+ if (argc > 1 )
+ {
+ address = argv[1];
+ }
+ if (AXIS2_STRCMP(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf ("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, to);
+ target_epr = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref);
+ property = axis2_property_create(env);
+ AXIS2_PROPERTY_SET_VALUE(property, env, target_epr);
+ AXIS2_OPTIONS_SET_PROPERTY(options, env, AXIS2_TARGET_EPR, property);
+ /*AXIS2_OPTIONS_SET_ACTION(options, env, "urn:wsrm:Ping");*/
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is
+ * picked up using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder.
+ * The client_home can be different from this folder on your system. For
+ * example, you may have a different folder (say, my_client_folder) with its
+ * own axis2.xml file. my_client_folder/modules will have the modules that
+ * the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home)
+ client_home = "../../deploy";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf("Error creating service client\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:"
+ " %d :: %s", env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ }
+
+ /* Set service client options */
+ AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options);
+
+ /* Engage addressing module */
+ AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API.*/
+ AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, "sandesha2");
+
+ /* Send request */
+ payload = build_om_programatically(env, "ping1");
+ status = AXIS2_SVC_CLIENT_SEND_ROBUST(svc_client, env, payload);
+ if(status)
+ printf("\nping client invoke SUCCESSFUL!\n");
+ payload = NULL;
+
+ payload = build_om_programatically(env, "ping2");
+ status = AXIS2_SVC_CLIENT_SEND_ROBUST(svc_client, env, payload);
+ if(status)
+ printf("\nping client invoke SUCCESSFUL!\n");
+ payload = NULL;
+
+ property = axis2_property_create(env);
+ AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
+ AXIS2_PROPERTY_SET_VALUE(property, env, AXIS2_VALUE_TRUE);
+ AXIS2_OPTIONS_SET_PROPERTY(options, env, "Sandesha2LastMessage",
+ property);
+ payload = build_om_programatically(env, "ping3");
+ status = AXIS2_SVC_CLIENT_SEND_ROBUST(svc_client, env, payload);
+ if(status)
+ printf("\nping client invoke SUCCESSFUL!\n");
+ /** Wait till callback is complete. Simply keep the parent thread running
+ until our on_complete or on_error is invoked */
+
+ AXIS2_SLEEP(MAX_COUNT);
+
+ if (svc_client)
+ {
+ AXIS2_SVC_CLIENT_FREE(svc_client, env);
+ svc_client = NULL;
+ }
+ return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axis2_env_t *env,
+ axis2_char_t *text)
+{
+ axiom_node_t *ping_om_node = NULL;
+ axiom_element_t* ping_om_ele = NULL;
+ axiom_node_t *text_om_node = NULL;
+ axiom_element_t* text_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 = axiom_namespace_create (env, "http://tempuri.org/", "ns1");
+ ping_om_ele = axiom_element_create(env, NULL, "ping", ns1, &ping_om_node);
+ text_om_ele = axiom_element_create(env, ping_om_node, "Text", ns1, &text_om_node);
+ AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, text, text_om_node);
+
+ buffer = AXIOM_NODE_TO_STRING(ping_om_node, env);
+ printf("\nSending OM node in XML : %s \n", buffer);
+
+ return ping_om_node;
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org