summaryrefslogtreecommitdiffstats
path: root/samples/client
diff options
context:
space:
mode:
authorGravatar gmcdonald2010-02-13 01:32:03 +0000
committerGravatar gmcdonald2010-02-13 01:32:03 +0000
commit0425aadc78680e53000fd0108b540d6eca048516 (patch)
tree8ec7ab8e015d454c5ec586dfc91e05a2dce1cfc0 /samples/client
downloadaxis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.gz
axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.bz2
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
Diffstat (limited to 'samples/client')
-rw-r--r--samples/client/Makefile.am2
-rw-r--r--samples/client/amqp/Makefile.am1
-rw-r--r--samples/client/amqp/echo/Makefile.am36
-rw-r--r--samples/client/amqp/echo/echo_blocking.c124
-rw-r--r--samples/client/amqp/echo/echo_blocking_addr.c132
-rw-r--r--samples/client/amqp/echo/echo_blocking_dual.c142
-rw-r--r--samples/client/amqp/echo/echo_blocking_soap11.c135
-rw-r--r--samples/client/amqp/echo/echo_non_blocking.c217
-rw-r--r--samples/client/amqp/echo/echo_non_blocking_dual.c235
-rw-r--r--samples/client/amqp/echo/echo_util.c47
-rw-r--r--samples/client/amqp/echo/echo_util.h54
-rw-r--r--samples/client/amqp/mtom/Makefile.am18
-rw-r--r--samples/client/amqp/mtom/mtom_client.c259
-rw-r--r--samples/client/amqp/mtom/resources/Makefile.am5
-rw-r--r--samples/client/amqp/mtom/resources/axis2.jpgbin0 -> 13887 bytes
-rw-r--r--samples/client/amqp/notify/Makefile.am15
-rw-r--r--samples/client/amqp/notify/notify_client.c152
-rw-r--r--samples/client/echo/Makefile.am18
-rw-r--r--samples/client/echo/README.txt5
-rw-r--r--samples/client/echo/echo.c196
-rw-r--r--samples/client/echo/echo.mk8
-rw-r--r--samples/client/google/Makefile.am17
-rw-r--r--samples/client/google/README.txt10
-rw-r--r--samples/client/google/google.mk8
-rw-r--r--samples/client/google/google_client.c290
-rw-r--r--samples/client/math/Makefile.am20
-rw-r--r--samples/client/math/axis2_math_stub.c193
-rw-r--r--samples/client/math/axis2_math_stub.h86
-rw-r--r--samples/client/math/math.mk8
-rw-r--r--samples/client/math/math_client.c201
-rw-r--r--samples/client/math/services.xml18
-rw-r--r--samples/client/mtom/Makefile.am20
-rw-r--r--samples/client/mtom/mtom.mk8
-rw-r--r--samples/client/mtom/mtom_client.c271
-rw-r--r--samples/client/mtom/resources/Makefile.am3
-rw-r--r--samples/client/mtom/resources/axis2.jpgbin0 -> 13887 bytes
-rw-r--r--samples/client/mtom_callback/Makefile.am19
-rw-r--r--samples/client/mtom_callback/mtom_callback.mk4
-rw-r--r--samples/client/mtom_callback/mtom_callback_client.c261
-rw-r--r--samples/client/notify/Makefile.am18
-rw-r--r--samples/client/notify/notify.mk8
-rw-r--r--samples/client/notify/notify_client.c152
-rw-r--r--samples/client/version/Makefile.am19
-rw-r--r--samples/client/version/axis2_version_stub.c114
-rw-r--r--samples/client/version/axis2_version_stub.h71
-rw-r--r--samples/client/version/services.xml9
-rw-r--r--samples/client/version/test.xml5
-rw-r--r--samples/client/version/version_client.c185
-rw-r--r--samples/client/yahoo/Makefile.am17
-rw-r--r--samples/client/yahoo/yahoo.mk8
-rw-r--r--samples/client/yahoo/yahoo_client.c207
51 files changed, 4051 insertions, 0 deletions
diff --git a/samples/client/Makefile.am b/samples/client/Makefile.am
new file mode 100644
index 0000000..5e285b0
--- /dev/null
+++ b/samples/client/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = echo math google notify mtom yahoo amqp version mtom_callback
+EXTRA_DIST= Makefile.am
diff --git a/samples/client/amqp/Makefile.am b/samples/client/amqp/Makefile.am
new file mode 100644
index 0000000..10429ae
--- /dev/null
+++ b/samples/client/amqp/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = echo notify mtom
diff --git a/samples/client/amqp/echo/Makefile.am b/samples/client/amqp/echo/Makefile.am
new file mode 100644
index 0000000..b348c63
--- /dev/null
+++ b/samples/client/amqp/echo/Makefile.am
@@ -0,0 +1,36 @@
+prgbindir = $(prefix)/samples/bin/amqp
+
+prgbin_PROGRAMS = echo_blocking \
+ echo_non_blocking \
+ echo_blocking_addr \
+ echo_blocking_dual \
+ echo_non_blocking_dual \
+ echo_blocking_soap11
+
+
+echo_blocking_SOURCES = echo_blocking.c echo_util.c
+echo_non_blocking_SOURCES = echo_non_blocking.c echo_util.c
+echo_blocking_addr_SOURCES = echo_blocking_addr.c echo_util.c
+echo_blocking_dual_SOURCES = echo_blocking_dual.c echo_util.c
+echo_non_blocking_dual_SOURCES = echo_non_blocking_dual.c echo_util.c
+echo_blocking_soap11_SOURCES = echo_blocking_soap11.c echo_util.c
+
+LINK_FLAGS = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ $(GUTHTHILA_LIBS)
+
+echo_blocking_LDADD = $(LINK_FLAGS)
+echo_non_blocking_LDADD = $(LINK_FLAGS)
+echo_blocking_addr_LDADD = $(LINK_FLAGS)
+echo_blocking_dual_LDADD = $(LINK_FLAGS)
+echo_non_blocking_dual_LDADD = $(LINK_FLAGS)
+echo_blocking_soap11_LDADD = $(LINK_FLAGS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=echo_util.h
diff --git a/samples/client/amqp/echo/echo_blocking.c b/samples/client/amqp/echo/echo_blocking.c
new file mode 100644
index 0000000..d21b2bb
--- /dev/null
+++ b/samples/client/amqp/echo/echo_blocking.c
@@ -0,0 +1,124 @@
+
+/*
+ * 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_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main (int argc, char **argv)
+{
+ const axutil_env_t* env = NULL;
+ const axis2_char_t* address = NULL;
+ axis2_endpoint_ref_t* endpoint_ref = 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;
+ axiom_node_t* ret_node = NULL;
+
+ /* Set up the environment */
+ env = axutil_env_create_all ("echo_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+
+ if (axutil_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);
+
+ /* Set up deploy folder */
+ client_home = AXIS2_GETENV ("AXIS2C_HOME");
+ if (!client_home || !strcmp (client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create (env, client_home);
+ if (!svc_client)
+ {
+ printf ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc (env);
+
+ /* Send request and get response */
+ ret_node = axis2_svc_client_send_receive (svc_client, env, payload);
+
+ if (ret_node)
+ {
+ 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);
+ AXIS2_FREE (env->allocator, om_str);
+ }
+
+ printf ("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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 client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free (svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free ((axutil_env_t*)env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+
diff --git a/samples/client/amqp/echo/echo_blocking_addr.c b/samples/client/amqp/echo/echo_blocking_addr.c
new file mode 100644
index 0000000..1c0383c
--- /dev/null
+++ b/samples/client/amqp/echo/echo_blocking_addr.c
@@ -0,0 +1,132 @@
+
+/*
+ * 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_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_blocking_addr_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_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_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/echoString");
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ 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);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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 client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/client/amqp/echo/echo_blocking_dual.c b/samples/client/amqp/echo/echo_blocking_dual.c
new file mode 100644
index 0000000..2d20ad0
--- /dev/null
+++ b/samples/client/amqp/echo/echo_blocking_dual.c
@@ -0,0 +1,142 @@
+
+/*
+ * 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_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_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;
+ axiom_node_t *ret_node = NULL;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_blocking_dual_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_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://ws.apache.org/axis2/c/samples/echoString");
+ reply_to =
+ axis2_endpoint_ref_create(env,
+ "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
+ axis2_options_set_reply_to(options, env, reply_to);
+
+ axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ 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);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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 client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ AXIS2_SLEEP(1);
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/client/amqp/echo/echo_blocking_soap11.c b/samples/client/amqp/echo/echo_blocking_soap11.c
new file mode 100644
index 0000000..4281e14
--- /dev/null
+++ b/samples/client/amqp/echo/echo_blocking_soap11.c
@@ -0,0 +1,135 @@
+
+/*
+ * 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_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+ axutil_string_t *soap_action = NULL;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_blocking_soap11_amqp.log",
+ AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_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_soap_version(options, env, AXIOM_SOAP11);
+ soap_action =
+ axutil_string_create(env,
+ "http://ws.apache.org/axis2/c/samples/echo/soap_action");
+ axis2_options_set_soap_action(options, env, soap_action);
+ axutil_string_free(soap_action, env);
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ 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);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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 client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/client/amqp/echo/echo_non_blocking.c b/samples/client/amqp/echo/echo_non_blocking.c
new file mode 100644
index 0000000..9846977
--- /dev/null
+++ b/samples/client/amqp/echo/echo_non_blocking.c
@@ -0,0 +1,217 @@
+
+/*
+ * 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_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+/* my on_complete callback function */
+axis2_status_t AXIS2_CALL
+echo_callback_on_complete (struct axis2_callback* callback,
+ const axutil_env_t* env);
+
+/* my on_error callback function */
+axis2_status_t AXIS2_CALL
+echo_callback_on_error (struct axis2_callback* callback,
+ const axutil_env_t* env,
+ int exception);
+
+/* to check whether the callback is completed */
+int isComplete = 0;
+
+int
+main(int argc, char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ int count = 0;
+
+ /* Set up the environment */
+ env = axutil_env_create_all ("echo_non_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+
+ if (axutil_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);
+
+ /* Set up deploy folder */
+ client_home = AXIS2_GETENV ("AXIS2C_HOME");
+ if (!client_home || !strcmp (client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create (env, client_home);
+ if (!svc_client)
+ {
+ printf ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc (env);
+
+ /* Create the callback object with default on_complete and on_error
+ callback functions */
+ callback = axis2_callback_create (env);
+
+ /* Set our on_complete fucntion pointer to the callback object */
+ axis2_callback_set_on_complete (callback, echo_callback_on_complete);
+
+ /* Set our on_error function pointer to the callback object */
+ axis2_callback_set_on_error (callback, echo_callback_on_error);
+
+ /* Send request */
+ axis2_svc_client_send_receive_non_blocking (svc_client, env,
+ payload, callback);
+
+ /*Wait till callback is complete. Simply keep the parent thread running
+ until our on_complete or on_error is invoked */
+ while (count < 30)
+ {
+ if (isComplete)
+ {
+ /* We are done with the callback */
+ break;
+ }
+
+ AXIS2_SLEEP (1);
+ count++;
+ }
+
+ if (!(count < 30))
+ {
+ printf ("\necho client invoke FAILED. Counter timed out.\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free (svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free ((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_complete(struct axis2_callback* callback,
+ const axutil_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;
+
+ 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);
+ AXIS2_FREE (env->allocator, om_str);
+ }
+
+ printf ("\necho client invoke SUCCESSFUL!\n");
+ }
+ }
+
+ isComplete = 1;
+ return status;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_error (struct axis2_callback* callback,
+ const axutil_env_t* env,
+ int exception)
+{
+
+ /** take necessary action on error */
+ printf ("\necho client invike FAILED. Error code:%d ::%s", exception,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+
+ isComplete = 1;
+
+ return AXIS2_SUCCESS;
+}
+
+
diff --git a/samples/client/amqp/echo/echo_non_blocking_dual.c b/samples/client/amqp/echo/echo_non_blocking_dual.c
new file mode 100644
index 0000000..b1ce5a1
--- /dev/null
+++ b/samples/client/amqp/echo/echo_non_blocking_dual.c
@@ -0,0 +1,235 @@
+
+/*
+ * 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_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+#define MAX_COUNT 10
+
+/* my on_complete callback function */
+axis2_status_t AXIS2_CALL echo_callback_on_complete(
+ struct axis2_callback * callback,
+ const axutil_env_t * env);
+
+/* my on_error callback function */
+axis2_status_t AXIS2_CALL echo_callback_on_error(
+ struct axis2_callback *callback,
+ const axutil_env_t * env,
+ int exception);
+
+/* to check whether the callback is completed */
+int isComplete = 0;
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_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;
+ int count = 0;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_non_blocking_dual_amqp.log",
+ AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_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://ws.apache.org/axis2/c/samples/echoString");
+ reply_to =
+ axis2_endpoint_ref_create(env,
+ "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
+ axis2_options_set_reply_to(options, env, reply_to);
+
+ axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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"); */
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Create the callback object with default on_complete and on_error
+ callback functions */
+ callback = axis2_callback_create(env);
+
+ /* Set our on_complete fucntion pointer to the callback object */
+ axis2_callback_set_on_complete(callback, echo_callback_on_complete);
+
+ /* Set our on_error function pointer to the callback object */
+ axis2_callback_set_on_error(callback, echo_callback_on_error);
+
+ /* Send request */
+ axis2_svc_client_send_receive_non_blocking(svc_client, env,
+ payload, callback);
+
+ /** Wait till callback is complete. Simply keep the parent thread running
+ until our on_complete or on_error is invoked */
+ while (count < MAX_COUNT)
+ {
+ if (isComplete)
+ {
+ /* We are done with the callback */
+ break;
+ }
+
+ AXIS2_SLEEP(1);
+ count++;
+ }
+
+ if (!(count < MAX_COUNT))
+ {
+ printf("\necho client invoke FAILED. Counter timed out.\n");
+ }
+
+ if (svc_client)
+ {
+ AXIS2_SLEEP(1);
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_complete(
+ struct axis2_callback * callback,
+ const axutil_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;
+
+ 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");
+ }
+ }
+ isComplete = 1;
+ return status;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_error(
+ struct axis2_callback * callback,
+ const axutil_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));
+ isComplete = 1;
+ return AXIS2_SUCCESS;
+}
diff --git a/samples/client/amqp/echo/echo_util.c b/samples/client/amqp/echo/echo_util.c
new file mode 100644
index 0000000..c49d42d
--- /dev/null
+++ b/samples/client/amqp/echo/echo_util.c
@@ -0,0 +1,47 @@
+
+/*
+ * 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_util.h"
+
+/* build SOAP request message content using OM */
+axiom_node_t*
+build_om_payload_for_echo_svc (const axutil_env_t* env)
+{
+ 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;
+ axis2_char_t* om_str = NULL;
+
+ ns1 = axiom_namespace_create (env, "http://ws.apache.org/axis2/services/echo",
+ "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, "Hello World!", text_om_node);
+
+ om_str = axiom_node_to_string (echo_om_node, env);
+ if (om_str)
+ printf ("\nSending OM : %s\n", om_str);
+
+ AXIS2_FREE (env->allocator, om_str);
+
+ return echo_om_node;
+}
+
+
diff --git a/samples/client/amqp/echo/echo_util.h b/samples/client/amqp/echo/echo_util.h
new file mode 100644
index 0000000..c932efb
--- /dev/null
+++ b/samples/client/amqp/echo/echo_util.h
@@ -0,0 +1,54 @@
+
+/*
+ * 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 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 axutil_env_t * env);
+
+#endif
+
+/*
+ * 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 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 axutil_env_t * env);
+
+#endif
diff --git a/samples/client/amqp/mtom/Makefile.am b/samples/client/amqp/mtom/Makefile.am
new file mode 100644
index 0000000..fa2f51a
--- /dev/null
+++ b/samples/client/amqp/mtom/Makefile.am
@@ -0,0 +1,18 @@
+SUBDIRS = resources
+
+prgbindir = $(prefix)/samples/bin/amqp
+
+prgbin_PROGRAMS = mtom
+
+mtom_SOURCES = mtom_client.c
+
+mtom_LDADD = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
diff --git a/samples/client/amqp/mtom/mtom_client.c b/samples/client/amqp/mtom/mtom_client.c
new file mode 100644
index 0000000..da87e1b
--- /dev/null
+++ b/samples/client/amqp/mtom/mtom_client.c
@@ -0,0 +1,259 @@
+
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name,
+ const axis2_char_t * to_save_name,
+ axis2_bool_t optimized);
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node,
+ const axis2_char_t * to_save_name);
+
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+ const axis2_char_t *image_name = "resources/axis2.jpg";
+ const axis2_char_t *to_save_name = "test.jpg";
+ axis2_bool_t optimized = AXIS2_TRUE;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("mtom_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of mtom service */
+ address = "amqp://localhost:5672/axis2/services/mtom";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf
+ ("Usage : %s [endpoint_url] [image_name] [to_save_name] [do_not_optimize]\n",
+ argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ if (argc > 2)
+ image_name = argv[2];
+ if (argc > 3)
+ to_save_name = argv[3];
+ if (argc > 4)
+ optimized = AXIS2_FALSE;
+
+ 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_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/mtomSample");
+
+ axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
+
+ if(optimized)
+ {
+ axis2_options_set_enable_mtom(options, env, AXIS2_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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload =
+ build_om_programatically(env, image_name, to_save_name, optimized);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE)
+ {
+ printf("\nRecieved Fault : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ else
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ printf("\nmtom client invoke SUCCESSFUL!\n");
+ process_response_node(env, ret_node, to_save_name);
+ }
+ }
+ }
+ else
+ {
+ 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("\nmtom client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name,
+ const axis2_char_t * to_save_name,
+ axis2_bool_t optimized)
+{
+ axiom_node_t *mtom_om_node = NULL;
+ axiom_element_t *mtom_om_ele = NULL;
+ axiom_node_t *image_om_node = NULL;
+ axiom_element_t *image_om_ele = NULL;
+ axiom_node_t *file_om_node = NULL;
+ axiom_element_t *file_om_ele = NULL;
+ axiom_node_t *data_om_node = NULL;
+ axiom_text_t *data_text = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *om_str = NULL;
+
+ axiom_data_handler_t *data_handler = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom",
+ "ns1");
+ mtom_om_ele =
+ axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);
+
+ file_om_ele =
+ axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node);
+ axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node);
+
+ image_om_ele =
+ axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node);
+
+ data_handler = axiom_data_handler_create(env, image_name, "image/jpeg");
+ data_text =
+ axiom_text_create_with_data_handler(env, image_om_node, data_handler,
+ &data_om_node);
+ axiom_text_set_optimize(data_text, env, optimized);
+ om_str = axiom_node_to_string(mtom_om_node, env);
+ if (om_str)
+ {
+ printf("%s", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ return mtom_om_node;
+}
+
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node,
+ const axis2_char_t * to_save_name)
+{
+ axiom_node_t *res_om_node = NULL;
+ axiom_element_t *res_om_ele = NULL;
+ res_om_node = axiom_node_get_first_child(node, env);
+
+ if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT)
+ {/** received mtom atttachment */
+ axiom_data_handler_t *data_handler = NULL;
+ axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env);
+ data_handler = axiom_text_get_data_handler(axiom_text, env);
+
+ /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/
+ if(axiom_data_handler_get_cached(data_handler, env))
+ {
+ printf("Attachment is cached.\n");
+ }
+ else
+ {
+ axiom_data_handler_set_file_name(data_handler, env, "test");
+ axiom_data_handler_write_to(data_handler, env);
+ }
+ }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){
+ res_om_ele = axiom_node_get_data_element(res_om_node, env);
+ printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node));
+ }
+
+ return 0;
+}
+
+
diff --git a/samples/client/amqp/mtom/resources/Makefile.am b/samples/client/amqp/mtom/resources/Makefile.am
new file mode 100644
index 0000000..2d60ebd
--- /dev/null
+++ b/samples/client/amqp/mtom/resources/Makefile.am
@@ -0,0 +1,5 @@
+samplesdir = $(prefix)/samples/bin/amqp/resources
+
+samples_DATA = axis2.jpg
+
+EXTRA_DIST = axis2.jpg
diff --git a/samples/client/amqp/mtom/resources/axis2.jpg b/samples/client/amqp/mtom/resources/axis2.jpg
new file mode 100644
index 0000000..73371d8
--- /dev/null
+++ b/samples/client/amqp/mtom/resources/axis2.jpg
Binary files differ
diff --git a/samples/client/amqp/notify/Makefile.am b/samples/client/amqp/notify/Makefile.am
new file mode 100644
index 0000000..85cc43e
--- /dev/null
+++ b/samples/client/amqp/notify/Makefile.am
@@ -0,0 +1,15 @@
+prgbindir = $(prefix)/samples/bin/amqp
+
+prgbin_PROGRAMS = notify
+
+notify_SOURCES = notify_client.c
+
+notify_LDADD = -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
diff --git a/samples/client/amqp/notify/notify_client.c b/samples/client/amqp/notify/notify_client.c
new file mode 100644
index 0000000..f562a5c
--- /dev/null
+++ b/samples/client/amqp/notify/notify_client.c
@@ -0,0 +1,152 @@
+
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("notify_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/notify";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_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_action(options, env, "http://example.org/action/notify");
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_programatically(env);
+
+ /* Send request */
+ status = axis2_svc_client_send_robust(svc_client, env, payload);
+
+ if (status == AXIS2_SUCCESS)
+ {
+ printf("\nnotify client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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("notify client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env)
+{
+ axiom_node_t *notify_om_node = NULL;
+ axiom_element_t *notify_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 = axiom_namespace_create(env, "http://example.org/notify", "m");
+ notify_om_ele =
+ axiom_element_create(env, NULL, "notify", ns1, &notify_om_node);
+ axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node);
+
+ buffer = axiom_node_to_string(notify_om_node, env);
+ if (buffer)
+ {
+ printf("\nSending OM node in XML : %s \n", buffer);
+ AXIS2_FREE(env->allocator, buffer);
+ }
+
+ return notify_om_node;
+}
diff --git a/samples/client/echo/Makefile.am b/samples/client/echo/Makefile.am
new file mode 100644
index 0000000..340e826
--- /dev/null
+++ b/samples/client/echo/Makefile.am
@@ -0,0 +1,18 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = echo
+echo_SOURCES = echo.c
+
+echo_LDADD = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=README.txt echo.mk
diff --git a/samples/client/echo/README.txt b/samples/client/echo/README.txt
new file mode 100644
index 0000000..e3284a5
--- /dev/null
+++ b/samples/client/echo/README.txt
@@ -0,0 +1,5 @@
+Client Sample -echo
+-------------------
+
+This is a sample to help test addressing.
+This sample works with echo service.
diff --git a/samples/client/echo/echo.c b/samples/client/echo/echo.c
new file mode 100644
index 0000000..94a0a20
--- /dev/null
+++ b/samples/client/echo/echo.c
@@ -0,0 +1,196 @@
+
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_payload_for_echo_svc(
+ const axutil_env_t * env);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+ axiom_node_t *payload2 = NULL;
+ axiom_node_t *ret_node2 = NULL;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "http://localhost:9090/axis2/services/echo";
+ if (argc > 1)
+ {
+ if (axutil_strcmp(argv[1], "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n",
+ argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ else
+ {
+ address = argv[1];
+ }
+ }
+ 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_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/echoString");
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ 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");
+
+ AXIS2_FREE(env->allocator, om_str);
+ ret_node = NULL;
+ }
+ else
+ {
+ 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 client invoke FAILED!\n");
+ }
+
+ payload2 = build_om_payload_for_echo_svc(env);
+ ret_node2 = axis2_svc_client_send_receive(svc_client, env, payload2);
+ if (ret_node2)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node2, env);
+ if (om_str)
+ printf("\nReceived OM : %s\n", om_str);
+ printf("\necho client invoke SUCCESSFUL!\n");
+
+ AXIS2_FREE(env->allocator, om_str);
+ ret_node2 = NULL;
+ }
+ else
+ {
+ 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 client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_payload_for_echo_svc(
+ const axutil_env_t * env)
+{
+ 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;
+ axis2_char_t *om_str = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "http://ws.apache.org/axis2/services/echo",
+ "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, "Hello World!", text_om_node);
+ om_str = axiom_node_to_string(echo_om_node, env);
+
+ if (om_str)
+ {
+ printf("\nSending OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ om_str = NULL;
+ }
+ return echo_om_node;
+}
diff --git a/samples/client/echo/echo.mk b/samples/client/echo/echo.mk
new file mode 100644
index 0000000..fc9b65b
--- /dev/null
+++ b/samples/client/echo/echo.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo echo.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo.exe
+
+
+
+
+
diff --git a/samples/client/google/Makefile.am b/samples/client/google/Makefile.am
new file mode 100644
index 0000000..b44e9b8
--- /dev/null
+++ b/samples/client/google/Makefile.am
@@ -0,0 +1,17 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = google
+google_SOURCES = google_client.c
+
+google_LDADD = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=README.txt google.mk
diff --git a/samples/client/google/README.txt b/samples/client/google/README.txt
new file mode 100644
index 0000000..de8e74e
--- /dev/null
+++ b/samples/client/google/README.txt
@@ -0,0 +1,10 @@
+Client Sample- Google
+---------------------
+
+In order to run this sample, you need to get a Google license key.
+Please visit http://www.google.com/apis/ for details on how to get a license key.
+
+Use the '-h' option with the sample to get help on command line options.
+e.g.
+./google -h
+
diff --git a/samples/client/google/google.mk b/samples/client/google/google.mk
new file mode 100644
index 0000000..56fa2b1
--- /dev/null
+++ b/samples/client/google/google.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:google.exe
+
+
+
+
+
diff --git a/samples/client/google/google_client.c b/samples/client/google/google_client.c
new file mode 100644
index 0000000..05e9f33
--- /dev/null
+++ b/samples/client/google/google_client.c
@@ -0,0 +1,290 @@
+
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_soap_body_content(
+ const axutil_env_t * env,
+ const axis2_char_t * operation,
+ const axis2_char_t * google_key,
+ const axis2_char_t * word_to_spell);
+
+void print_invalid_om(
+ const axutil_env_t * env,
+ axiom_node_t * ret_node);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+
+ const axis2_char_t *google_key = NULL;
+ const axis2_char_t *word_to_spell = NULL;
+ const axis2_char_t *operation = NULL;
+
+ operation = "doSpellingSuggestion";
+ google_key = "00000000000000000000000000000000";
+ word_to_spell = "salvasion";
+
+ /* Set up the environment */
+ env = axutil_env_create_all("google_client.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of google service */
+ address = "http://api.google.com/search/beta2";
+
+ if ((argc > 1) && (axutil_strcmp("-h", argv[1]) == 0))
+ {
+ printf("\nUsage : %s [google_key] [word_to_spell] \n", argv[0]);
+ printf
+ ("\tgoogle_key Your Google license key. Default value won't work. You must use your key here.\n");
+ printf
+ ("\tword_to_spell Word to be spelled by Google service. Default is %s\n",
+ word_to_spell);
+ printf
+ ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n");
+ printf("\tUse -h for help\n");
+ return 0;
+ }
+
+ if (argc > 1)
+ google_key = argv[1];
+ if (argc > 2)
+ word_to_spell = argv[2];
+ if (argc > 3)
+ address = argv[3];
+
+ printf("Using endpoint : %s\n", address);
+ printf("\nInvoking operation %s with params %s and %s\n", operation,
+ google_key, word_to_spell);
+
+ /* 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_soap_version(options, env, AXIOM_SOAP11);
+
+ /* Set up deploy folder. */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload =
+ build_soap_body_content(env, operation, google_key, word_to_spell);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
+ {
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_soap_body_t *soap_body = NULL;
+ axiom_soap_fault_t *soap_fault = NULL;
+ axis2_char_t *fault_string = NULL;
+
+ printf("\nResponse has a SOAP fault\n");
+ soap_envelope =
+ axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
+ if (soap_envelope)
+ {
+ soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+ }
+
+ if (soap_body)
+ {
+ soap_fault = axiom_soap_body_get_fault(soap_body, env);
+ }
+
+ if (soap_fault)
+ {
+ fault_string = axiom_node_to_string(axiom_soap_fault_get_base_node
+ (soap_fault, env), env);
+ printf("\nReturned SOAP fault: %s\n", fault_string);
+ AXIS2_FREE (env->allocator, fault_string);
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return -1;
+ }
+
+ if (ret_node)
+ {
+ if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
+ {
+ axis2_char_t *result = NULL;
+ axiom_element_t *result_ele = NULL;
+ axiom_node_t *ret_node1 = NULL;
+
+ result_ele =
+ (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
+ if (axutil_strcmp
+ (axiom_element_get_localname(result_ele, env),
+ "doSpellingSuggestionResponse") != 0)
+ {
+ print_invalid_om(env, ret_node);
+ return AXIS2_FAILURE;
+ }
+
+ ret_node1 = axiom_node_get_first_element(ret_node, env); /*return */
+ if (!ret_node1)
+ {
+ print_invalid_om(env, ret_node);
+ return AXIS2_FAILURE;
+ }
+ result_ele =
+ (axiom_element_t *) axiom_node_get_data_element(ret_node1, env);
+ result = axiom_element_get_text(result_ele, env, ret_node1);
+ printf("\nResult = %s\n", result);
+ }
+ else
+ {
+ print_invalid_om(env, ret_node);
+ return AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ 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("Google client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+axiom_node_t *
+build_soap_body_content(
+ const axutil_env_t * env,
+ const axis2_char_t * operation,
+ const axis2_char_t * google_key,
+ const axis2_char_t * word_to_spell)
+{
+ axiom_node_t *google_om_node = NULL;
+ axiom_element_t *google_om_ele = NULL;
+ axiom_node_t *text_om_node = NULL;
+ axiom_element_t *text_om_ele = NULL;
+ axiom_namespace_t *ns0 = NULL,
+ *ns1 = NULL,
+ *ns2 = NULL,
+ *ns3 = NULL;
+ axiom_attribute_t *attri1 = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns0 =
+ axiom_namespace_create(env, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI,
+ "soapenv");
+ ns1 = axiom_namespace_create(env, "urn:GoogleSearch", "ns1");
+ ns2 =
+ axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema-instance",
+ "xsi");
+ ns3 =
+ axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema", "xsd");
+
+ attri1 = axiom_attribute_create(env, "encodingStyle",
+ "http://schemas.xmlsoap.org/soap/encoding/",
+ ns0);
+
+ google_om_ele =
+ axiom_element_create(env, NULL, operation, ns1, &google_om_node);
+ axiom_element_add_attribute(google_om_ele, env, attri1, google_om_node);
+ axiom_element_declare_namespace(google_om_ele, env, google_om_node, ns2);
+ axiom_element_declare_namespace(google_om_ele, env, google_om_node, ns3);
+
+ text_om_ele =
+ axiom_element_create(env, google_om_node, "key", NULL, &text_om_node);
+ attri1 = axiom_attribute_create(env, "type", "xsd:string", ns2);
+ axiom_element_add_attribute(text_om_ele, env, attri1, text_om_node);
+ axiom_element_set_text(text_om_ele, env, google_key, text_om_node);
+
+ text_om_ele =
+ axiom_element_create(env, google_om_node, "phrase", NULL,
+ &text_om_node);
+ axiom_element_add_attribute(text_om_ele, env, attri1, text_om_node);
+ axiom_element_set_text(text_om_ele, env, word_to_spell, text_om_node);
+
+ buffer = axiom_node_to_string(google_om_node, env);
+ printf("%s\n", buffer);
+ AXIS2_FREE (env->allocator, buffer);
+ return google_om_node;
+}
+
+void
+print_invalid_om(
+ const axutil_env_t * env,
+ axiom_node_t * ret_node)
+{
+ axis2_char_t *buffer = NULL;
+ buffer = axiom_node_get_data_element(ret_node, env);
+ printf("\nReceived OM as result : %s\n", buffer);
+}
diff --git a/samples/client/math/Makefile.am b/samples/client/math/Makefile.am
new file mode 100644
index 0000000..8cca62e
--- /dev/null
+++ b/samples/client/math/Makefile.am
@@ -0,0 +1,20 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = math
+noinst_HEADERS = axis2_math_stub.h
+math_SOURCES = axis2_math_stub.c \
+ math_client.c
+
+math_LDADD = \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=math.mk
diff --git a/samples/client/math/axis2_math_stub.c b/samples/client/math/axis2_math_stub.c
new file mode 100644
index 0000000..366e159
--- /dev/null
+++ b/samples/client/math/axis2_math_stub.c
@@ -0,0 +1,193 @@
+
+/*
+ * 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_math_stub.h"
+
+axis2_stub_t *
+axis2_math_stub_create_with_endpoint_ref_and_client_home(
+ const axutil_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 (!stub)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ axis2_populate_axis_service(stub, env);
+ return stub;
+}
+
+void
+axis2_populate_axis_service(
+ axis2_stub_t * stub,
+ const axutil_env_t * env)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axutil_qname_t *op_qname = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_op_t *op = NULL;
+
+ /*Modifying the Service */
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ svc = axis2_svc_client_get_svc(svc_client, env);
+
+ /*creating the operations */
+
+ op_qname = axutil_qname_create(env, "add", "", NULL);
+ op = axis2_op_create_with_qname(env, op_qname);
+ axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN);
+ axis2_svc_add_op(svc, env, op);
+ axutil_qname_free(op_qname, env);
+
+ op_qname = axutil_qname_create(env, "sub", "", NULL);
+ op = axis2_op_create_with_qname(env, op_qname);
+ axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN);
+ axis2_svc_add_op(svc, env, op);
+ axutil_qname_free(op_qname, env);
+
+ op_qname = axutil_qname_create(env, "mul", "", NULL);
+ op = axis2_op_create_with_qname(env, op_qname);
+ axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN);
+ axis2_svc_add_op(svc, env, op);
+ axutil_qname_free(op_qname, env);
+
+ op_qname = axutil_qname_create(env, "div", "", NULL);
+ op = axis2_op_create_with_qname(env, op_qname);
+ axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN);
+ axis2_svc_add_op(svc, env, op);
+ axutil_qname_free(op_qname, env);
+}
+
+axis2_stub_t *
+axis2_math_stub_create_with_endpoint_uri_and_client_home(
+ const axutil_env_t * env,
+ const axis2_char_t * endpoint_uri,
+ const 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 (!stub)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axis2_populate_axis_service(stub, env);
+
+ return stub;
+}
+
+/***************************Function implementation****************************/
+
+axiom_node_t *
+axis2_math_stub_add(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *ret_node = NULL;
+ axutil_qname_t *op_qname = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ op_qname = axutil_qname_create(env, "add", "", NULL);
+ ret_node =
+ axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname,
+ node);
+ axutil_qname_free(op_qname, env);
+
+ return ret_node;
+}
+
+axiom_node_t *
+axis2_math_stub_sub(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *ret_node = NULL;
+ axutil_qname_t *op_qname = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ op_qname = axutil_qname_create(env, "sub", "", NULL);
+ ret_node =
+ axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname,
+ node);
+
+ return ret_node;
+}
+
+axiom_node_t *
+axis2_math_stub_mul(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *ret_node = NULL;
+ axutil_qname_t *op_qname = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ op_qname = axutil_qname_create(env, "mul", "", NULL);
+ ret_node =
+ axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname,
+ node);
+
+ return ret_node;
+}
+
+axiom_node_t *
+axis2_math_stub_div(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *ret_node = NULL;
+ axutil_qname_t *op_qname = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ op_qname = axutil_qname_create(env, "div", "", NULL);
+ ret_node =
+ axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname,
+ node);
+
+ return ret_node;
+}
diff --git a/samples/client/math/axis2_math_stub.h b/samples/client/math/axis2_math_stub.h
new file mode 100644
index 0000000..20497b5
--- /dev/null
+++ b/samples/client/math/axis2_math_stub.h
@@ -0,0 +1,86 @@
+
+/*
+ * 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 AXIS2_ECHO_STUB_H
+#define AXIS2_ECHO_STUB_H
+
+/**
+ * @file axis2_math_stub.h
+ * @brief axis2 math stub interface
+ */
+
+#include <axis2_stub.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ axiom_node_t *axis2_math_stub_add(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+ axiom_node_t *axis2_math_stub_sub(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+ axiom_node_t *axis2_math_stub_mul(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+ axiom_node_t *axis2_math_stub_div(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+ /**
+ * populate services
+ */
+ void axis2_populate_axis_service(
+ axis2_stub_t * stub,
+ const axutil_env_t * env);
+
+ /**
+ * Creates axis2_stub struct
+ * @param endpoint reference
+ * @return pointer to newly created axis2_stub struct
+ */
+ axis2_stub_t *axis2_math_stub_create_with_endpoint_ref_and_client_home(
+ const axutil_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_stub_t *axis2_math_stub_create_with_endpoint_uri_and_client_home(
+ const axutil_env_t * env,
+ const axis2_char_t * endpoint_uri,
+ const axis2_char_t * client_home);
+
+ /** @} */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* AXIS2_ECHO_STUB_H */
diff --git a/samples/client/math/math.mk b/samples/client/math/math.mk
new file mode 100644
index 0000000..c82a342
--- /dev/null
+++ b/samples/client/math/math.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:math.exe
+
+
+
+
+
diff --git a/samples/client/math/math_client.c b/samples/client/math/math_client.c
new file mode 100644
index 0000000..5d783a7
--- /dev/null
+++ b/samples/client/math/math_client.c
@@ -0,0 +1,201 @@
+
+/*
+ * 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_math_stub.h"
+#include <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * operation,
+ const axis2_char_t * param1,
+ const axis2_char_t * param2);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ axis2_stub_t *stub = NULL;
+ axiom_node_t *node = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ const axis2_char_t *client_home = NULL;
+ axiom_node_t *ret_node = NULL;
+
+ const axis2_char_t *operation = "add";
+ const axis2_char_t *param1 = "40";
+ const axis2_char_t *param2 = "8";
+
+ env = axutil_env_create_all("math_blocking.log", AXIS2_LOG_LEVEL_TRACE);
+
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ address = "http://localhost:9090/axis2/services/math";
+ if (argc > 1)
+ operation = argv[1];
+ if (axutil_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_math_stub_create_with_endpoint_uri_and_client_home(env, address,
+ client_home);
+
+ /* create node and invoke math */
+ if (stub)
+ {
+ ret_node = axis2_math_stub_add(stub, env, node);
+ }
+
+ if (ret_node)
+ {
+ if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
+ {
+ axis2_char_t *result = NULL;
+ axiom_element_t *result_ele =
+ (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
+
+ result = axiom_element_get_text(result_ele, env, ret_node);
+ printf("\nResult = %s\n", result);
+ }
+ else
+ {
+ axiom_xml_writer_t *writer = NULL;
+ axiom_output_t *om_output = NULL;
+ axis2_char_t *buffer = NULL;
+ writer =
+ axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ om_output = axiom_output_create(env, writer);
+
+ axiom_node_serialize(ret_node, env, om_output);
+ buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, env);
+ printf("\nReceived invalid OM as result : %s\n", buffer);
+ if (buffer)
+ {
+ AXIS2_FREE(env->allocator, buffer);
+ buffer = NULL;
+ }
+ if (om_output)
+ {
+ axiom_output_free(om_output, env);
+ om_output = NULL;
+ }
+ axiom_xml_writer_free(writer, env);
+ }
+ }
+ else
+ {
+ 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("math stub invoke FAILED!\n");
+ }
+
+ if (stub)
+ {
+ axis2_stub_free(stub, env);
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return status;
+}
+
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * operation,
+ const axis2_char_t * param1,
+ const axis2_char_t * param2)
+{
+ axiom_node_t *math_om_node = NULL;
+ axiom_element_t *math_om_ele = NULL;
+ axiom_node_t *text_om_node = NULL;
+ axiom_element_t *text_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+
+ axiom_xml_writer_t *xml_writer = NULL;
+ axiom_output_t *om_output = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "http://ws.apache.org/axis2/services/math",
+ "ns1");
+
+ math_om_ele =
+ axiom_element_create(env, NULL, operation, ns1, &math_om_node);
+
+ text_om_ele =
+ axiom_element_create(env, math_om_node, "param1", NULL, &text_om_node);
+ axiom_element_set_text(text_om_ele, env, param1, text_om_node);
+
+ text_om_ele =
+ axiom_element_create(env, math_om_node, "param2", NULL, &text_om_node);
+ axiom_element_set_text(text_om_ele, env, param2, text_om_node);
+
+ xml_writer =
+ axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ om_output = axiom_output_create(env, xml_writer);
+
+ axiom_node_serialize(math_om_node, env, om_output);
+ buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n",
+ buffer);
+ if (om_output)
+ {
+ axiom_output_free(om_output, env);
+ om_output = NULL;
+ }
+
+ return math_om_node;
+}
diff --git a/samples/client/math/services.xml b/samples/client/math/services.xml
new file mode 100644
index 0000000..53c43e9
--- /dev/null
+++ b/samples/client/math/services.xml
@@ -0,0 +1,18 @@
+<service name="math">
+ <parameter name="ServiceClass" locked="xsd:false">math</parameter>
+ <description>
+ This is a testing service, named 'math' to test multiple operations in the same service
+ </description>
+ <operation name="add">
+ <!--messageReceiver class="axis2_receivers" /-->
+ </operation>
+ <operation name="sub">
+ <!--messageReceiver class="axis2_receivers" /-->
+ </operation>
+ <operation name="mul">
+ <!--messageReceiver class="axis2_receivers" /-->
+ </operation>
+ <operation name="div">
+ <!--messageReceiver class="axis2_receivers" /-->
+ </operation>
+</service>
diff --git a/samples/client/mtom/Makefile.am b/samples/client/mtom/Makefile.am
new file mode 100644
index 0000000..df1a866
--- /dev/null
+++ b/samples/client/mtom/Makefile.am
@@ -0,0 +1,20 @@
+SUBDIRS=resources
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = mtom
+
+mtom_SOURCES = mtom_client.c
+
+mtom_LDADD = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=mtom.mk
diff --git a/samples/client/mtom/mtom.mk b/samples/client/mtom/mtom.mk
new file mode 100644
index 0000000..01f0e3c
--- /dev/null
+++ b/samples/client/mtom/mtom.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:mtom.exe
+
+
+
+
+
diff --git a/samples/client/mtom/mtom_client.c b/samples/client/mtom/mtom_client.c
new file mode 100644
index 0000000..070ee5b
--- /dev/null
+++ b/samples/client/mtom/mtom_client.c
@@ -0,0 +1,271 @@
+
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+#include <axutil_uuid_gen.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name,
+ const axis2_char_t * to_save_name,
+ axis2_bool_t optimized);
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node,
+ const axis2_char_t * to_save_name);
+
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+ const axis2_char_t *image_name = "resources/axis2.jpg";
+ const axis2_char_t *to_save_name = "test.jpg";
+ axis2_bool_t optimized = AXIS2_TRUE;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("mtom.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of mtom service */
+ address = "http://localhost:9090/axis2/services/mtom";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf
+ ("Usage : %s [endpoint_url] [image_name] [to_save_name] [do_not_optimize]\n",
+ argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ if (argc > 2)
+ image_name = argv[2];
+ if (argc > 3)
+ to_save_name = argv[3];
+ if (argc > 4)
+ optimized = AXIS2_FALSE;
+
+ 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_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/mtomSample");
+
+ axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
+
+ if(optimized)
+ {
+ axis2_options_set_enable_mtom(options, env, AXIS2_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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload =
+ build_om_programatically(env, image_name, to_save_name, optimized);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE)
+ {
+ printf("\nRecieved Fault : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ else
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ printf("\nmtom client invoke SUCCESSFUL!\n");
+ process_response_node(env, ret_node, to_save_name);
+ }
+ }
+ }
+ else
+ {
+ 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("\nmtom client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name,
+ const axis2_char_t * to_save_name,
+ axis2_bool_t optimized)
+{
+ axiom_node_t *mtom_om_node = NULL;
+ axiom_element_t *mtom_om_ele = NULL;
+ axiom_node_t *image_om_node = NULL;
+ axiom_element_t *image_om_ele = NULL;
+ axiom_node_t *file_om_node = NULL;
+ axiom_element_t *file_om_ele = NULL;
+ axiom_node_t *data_om_node = NULL;
+ axiom_text_t *data_text = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *om_str = NULL;
+
+ axiom_data_handler_t *data_handler = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom",
+ "ns1");
+ mtom_om_ele =
+ axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);
+
+ file_om_ele =
+ axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node);
+ axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node);
+
+ image_om_ele =
+ axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node);
+
+ /* This is when we directly give file name */
+
+ data_handler = axiom_data_handler_create(env, image_name, "image/jpeg");
+
+ /* Uncomment following to set a callback instead of a file */
+
+ /*data_handler = axiom_data_handler_create(env, NULL, "image/jpeg");
+ axiom_data_handler_set_data_handler_type(data_handler, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK);
+ axiom_data_handler_set_user_param(data_handler, env, (void *)image_name);*/
+
+ data_text =
+ axiom_text_create_with_data_handler(env, image_om_node, data_handler,
+ &data_om_node);
+
+ axiom_text_set_optimize(data_text, env, optimized);
+ /*axiom_text_set_is_swa(data_text, env, AXIS2_TRUE);*/
+ om_str = axiom_node_to_string(mtom_om_node, env);
+ if (om_str)
+ {
+ printf("%s", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ return mtom_om_node;
+}
+
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node,
+ const axis2_char_t * to_save_name)
+{
+ axiom_node_t *res_om_node = NULL;
+ axiom_element_t *res_om_ele = NULL;
+ res_om_node = axiom_node_get_first_child(node, env);
+
+ if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT)
+ {/** received mtom atttachment */
+ axiom_data_handler_t *data_handler = NULL;
+ axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env);
+ data_handler = axiom_text_get_data_handler(axiom_text, env);
+
+ /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/
+ if(axiom_data_handler_get_cached(data_handler, env))
+ {
+ printf("Attachment is cached.\n");
+ }
+ else
+ {
+ axiom_data_handler_set_file_name(data_handler, env, "test");
+ axiom_data_handler_write_to(data_handler, env);
+ }
+ }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){
+ res_om_ele = axiom_node_get_data_element(res_om_node, env);
+ printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node));
+ }
+
+ return 0;
+}
+
+
diff --git a/samples/client/mtom/resources/Makefile.am b/samples/client/mtom/resources/Makefile.am
new file mode 100644
index 0000000..ee7e84b
--- /dev/null
+++ b/samples/client/mtom/resources/Makefile.am
@@ -0,0 +1,3 @@
+samplesdir=$(prefix)/samples/bin/resources
+samples_DATA=axis2.jpg
+EXTRA_DIST=axis2.jpg
diff --git a/samples/client/mtom/resources/axis2.jpg b/samples/client/mtom/resources/axis2.jpg
new file mode 100644
index 0000000..73371d8
--- /dev/null
+++ b/samples/client/mtom/resources/axis2.jpg
Binary files differ
diff --git a/samples/client/mtom_callback/Makefile.am b/samples/client/mtom_callback/Makefile.am
new file mode 100644
index 0000000..10b1001
--- /dev/null
+++ b/samples/client/mtom_callback/Makefile.am
@@ -0,0 +1,19 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = mtom_callback
+
+mtom_callback_SOURCES = mtom_callback_client.c
+
+mtom_callback_LDADD = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=mtom_callback.mk
diff --git a/samples/client/mtom_callback/mtom_callback.mk b/samples/client/mtom_callback/mtom_callback.mk
new file mode 100644
index 0000000..ff59030
--- /dev/null
+++ b/samples/client/mtom_callback/mtom_callback.mk
@@ -0,0 +1,4 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:mtom_callback.exe
+
diff --git a/samples/client/mtom_callback/mtom_callback_client.c b/samples/client/mtom_callback/mtom_callback_client.c
new file mode 100644
index 0000000..464d997
--- /dev/null
+++ b/samples/client/mtom_callback/mtom_callback_client.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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+#include <axutil_uuid_gen.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name);
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node);
+
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+ const axis2_char_t *image_name = "resources/axis2.jpg";
+
+ /* Set up the environment */
+ env = axutil_env_create_all("mtom_callback.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of mtom service */
+ address = "http://localhost:9090/axis2/services/mtom_callback";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf
+ ("Usage : %s [endpoint_url] [image_name] \n",
+ argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ if (argc > 2)
+ image_name = argv[2];
+
+ 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_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/mtomCallbackSample");
+
+ axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
+
+ axis2_options_set_enable_mtom(options, env, AXIS2_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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload =
+ build_om_programatically(env, image_name);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE)
+ {
+ printf("\nRecieved Fault : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ else
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ printf("\nmtom client invoke SUCCESSFUL!\n");
+ process_response_node(env, ret_node);
+ }
+ }
+ }
+ else
+ {
+ 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("\nmtom client invoke FAILED!\n");
+ printf("\nSending callback may not be set. Check the log for more details.\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * attachment_name)
+{
+ axiom_node_t *mtom_om_node = NULL;
+ axiom_element_t *mtom_om_ele = NULL;
+ axiom_node_t *attachment_om_node = NULL;
+ axiom_element_t *attachment_om_ele = NULL;
+ axiom_node_t *data_om_node = NULL;
+ axiom_text_t *data_text = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *om_str = NULL;
+
+ axiom_data_handler_t *data_handler = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom",
+ "ns1");
+ mtom_om_ele =
+ axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);
+
+ attachment_om_ele =
+ axiom_element_create(env, mtom_om_node, "attachment", ns1, &attachment_om_node);
+
+ /* The attachment is loaded using the callback. The callback should be
+ * specified in the axis2.xml */
+
+ data_handler = axiom_data_handler_create(env, NULL, "image/jpeg");
+ axiom_data_handler_set_data_handler_type(data_handler, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK);
+ axiom_data_handler_set_user_param(data_handler, env, (void *)attachment_name);
+
+ data_text =
+ axiom_text_create_with_data_handler(env, attachment_om_node, data_handler,
+ &data_om_node);
+
+ axiom_text_set_optimize(data_text, env, AXIS2_TRUE);
+ om_str = axiom_node_to_string(mtom_om_node, env);
+ if (om_str)
+ {
+ printf("%s", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ return mtom_om_node;
+}
+
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node)
+{
+ axiom_node_t *res_om_node = NULL;
+ res_om_node = axiom_node_get_first_child(node, env);
+
+ if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT)
+ {/** received mtom atttachment */
+ axiom_data_handler_t *data_handler = NULL;
+ axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env);
+ data_handler = axiom_text_get_data_handler(axiom_text, env);
+
+ if(axiom_data_handler_get_cached(data_handler, env))
+ {
+ axis2_char_t *mime_id = NULL;
+
+ printf("Attachment is cached.\n");
+
+ mime_id = axiom_data_handler_get_mime_id(data_handler, env);
+ if(mime_id)
+ {
+ /* The client implementer should know what to do with
+ * the attachment in the response. Becasue the attachment
+ * was stored using the callback given by the client */
+
+ /*axis2_char_t command[1000];
+
+ sprintf(command, "rm -f /opt/tmp/%s", mime_id);
+ system(command);*/
+ }
+ }
+ else
+ {
+ axiom_data_handler_set_file_name(data_handler, env, "test");
+ axiom_data_handler_write_to(data_handler, env);
+ }
+ }
+ else
+ {
+ printf("No attachemnt in the response\n");
+ }
+
+ return 0;
+}
+
+
diff --git a/samples/client/notify/Makefile.am b/samples/client/notify/Makefile.am
new file mode 100644
index 0000000..c89bd4c
--- /dev/null
+++ b/samples/client/notify/Makefile.am
@@ -0,0 +1,18 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = notify
+notify_SOURCES = notify_client.c
+
+notify_LDADD = \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=notify.mk
diff --git a/samples/client/notify/notify.mk b/samples/client/notify/notify.mk
new file mode 100644
index 0000000..f1759e2
--- /dev/null
+++ b/samples/client/notify/notify.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:notify.exe
+
+
+
+
+
diff --git a/samples/client/notify/notify_client.c b/samples/client/notify/notify_client.c
new file mode 100644
index 0000000..15629b0
--- /dev/null
+++ b/samples/client/notify/notify_client.c
@@ -0,0 +1,152 @@
+
+/*
+ * 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 <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("notify.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "http://localhost:9090/axis2/services/notify";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_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_action(options, env, "http://example.org/action/notify");
+
+ /* 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 || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_programatically(env);
+
+ /* Send request */
+ status = axis2_svc_client_send_robust(svc_client, env, payload);
+
+ if (status == AXIS2_SUCCESS)
+ {
+ printf("\nnotify client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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("notify client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env)
+{
+ axiom_node_t *notify_om_node = NULL;
+ axiom_element_t *notify_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 = axiom_namespace_create(env, "http://example.org/notify", "m");
+ notify_om_ele =
+ axiom_element_create(env, NULL, "notify", ns1, &notify_om_node);
+ axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node);
+
+ buffer = axiom_node_to_string(notify_om_node, env);
+ if (buffer)
+ {
+ printf("\nSending OM node in XML : %s \n", buffer);
+ AXIS2_FREE(env->allocator, buffer);
+ }
+
+ return notify_om_node;
+}
diff --git a/samples/client/version/Makefile.am b/samples/client/version/Makefile.am
new file mode 100644
index 0000000..9e66c83
--- /dev/null
+++ b/samples/client/version/Makefile.am
@@ -0,0 +1,19 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = version
+noinst_HEADERS = axis2_version_stub.h
+version_SOURCES = axis2_version_stub.c \
+ version_client.c
+
+version_LDADD = \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -lpthread \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
diff --git a/samples/client/version/axis2_version_stub.c b/samples/client/version/axis2_version_stub.c
new file mode 100644
index 0000000..168e1b0
--- /dev/null
+++ b/samples/client/version/axis2_version_stub.c
@@ -0,0 +1,114 @@
+
+/*
+ * 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_version_stub.h"
+
+axis2_stub_t *
+axis2_version_stub_create_with_endpoint_ref_and_client_home(
+ const axutil_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 (!stub)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ axis2_populate_axis_service(stub, env);
+ return stub;
+}
+
+void
+axis2_populate_axis_service(
+ axis2_stub_t * stub,
+ const axutil_env_t * env)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axutil_qname_t *op_qname = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_op_t *op = NULL;
+
+ /*Modifying the Service */
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ svc = axis2_svc_client_get_svc(svc_client, env);
+
+ /*creating the operations */
+
+ op_qname = axutil_qname_create(env, "GetVersion", "", NULL);
+ op = axis2_op_create_with_qname(env, op_qname);
+ axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN);
+ axis2_svc_add_op(svc, env, op);
+ axutil_qname_free(op_qname, env);
+
+}
+
+axis2_stub_t *
+axis2_version_stub_create_with_endpoint_uri_and_client_home(
+ const axutil_env_t * env,
+ const axis2_char_t * endpoint_uri,
+ const 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 (!stub)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axis2_populate_axis_service(stub, env);
+
+ return stub;
+}
+
+/***************************Function implementation****************************/
+
+axiom_node_t *
+axis2_version_stub_get_version(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *ret_node = NULL;
+ axutil_qname_t *op_qname = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ svc_client = axis2_stub_get_svc_client(stub, env);
+ op_qname = axutil_qname_create(env, "GetVersion", "", NULL);
+ ret_node =
+ axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname,
+ node);
+ axutil_qname_free(op_qname, env);
+
+ return ret_node;
+}
+
diff --git a/samples/client/version/axis2_version_stub.h b/samples/client/version/axis2_version_stub.h
new file mode 100644
index 0000000..9ebdfa5
--- /dev/null
+++ b/samples/client/version/axis2_version_stub.h
@@ -0,0 +1,71 @@
+
+/*
+ * 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 AXIS2_VERSION_STUB_H
+#define AXIS2_VERSION_STUB_H
+
+/**
+ * @file axis2_version_stub.h
+ * @brief axis2 version stub interface
+ */
+
+#include <axis2_stub.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ axiom_node_t *axis2_version_stub_get_version(
+ axis2_stub_t * stub,
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+ /**
+ * populate services
+ */
+ void axis2_populate_axis_service(
+ axis2_stub_t * stub,
+ const axutil_env_t * env);
+
+ /**
+ * Creates axis2_stub struct
+ * @param endpoint reference
+ * @return pointer to newly created axis2_stub struct
+ */
+ axis2_stub_t *axis2_version_stub_create_with_endpoint_ref_and_client_home(
+ const axutil_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_stub_t *axis2_version_stub_create_with_endpoint_uri_and_client_home(
+ const axutil_env_t * env,
+ const axis2_char_t * endpoint_uri,
+ const axis2_char_t * client_home);
+
+ /** @} */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* AXIS2_VERSION_STUB_H */
diff --git a/samples/client/version/services.xml b/samples/client/version/services.xml
new file mode 100644
index 0000000..88fa9a1
--- /dev/null
+++ b/samples/client/version/services.xml
@@ -0,0 +1,9 @@
+<service name="version">
+ <parameter name="ServiceClass" locked="xsd:false">version</parameter>
+ <description>
+ This is a testing service, named 'version' to test multiple operations in the same service
+ </description>
+ <operation name="get_version">
+ <!--messageReceiver class="axis2_receivers" /-->
+ </operation>
+</service>
diff --git a/samples/client/version/test.xml b/samples/client/version/test.xml
new file mode 100644
index 0000000..ca6650c
--- /dev/null
+++ b/samples/client/version/test.xml
@@ -0,0 +1,5 @@
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://localhost:80/axisae/aewebservices71.wsdl">
+ <SOAP-ENV:Body>
+ <GetVersion xmlns="urn:aewebservices71" />
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
diff --git a/samples/client/version/version_client.c b/samples/client/version/version_client.c
new file mode 100644
index 0000000..b72d242
--- /dev/null
+++ b/samples/client/version/version_client.c
@@ -0,0 +1,185 @@
+
+/*
+ * 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_version_stub.h"
+#include <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ axis2_stub_t *stub = NULL;
+ axiom_node_t *node = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ const axis2_char_t *client_home = NULL;
+ axiom_node_t *ret_node = NULL;
+
+ const axis2_char_t *operation = "get_version";
+ const axis2_char_t *param1 = "40";
+ const axis2_char_t *param2 = "8";
+
+ env = axutil_env_create_all("version_blocking.log", AXIS2_LOG_LEVEL_TRACE);
+
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ address = "http://localhost:9090/axis2/services/version";
+ if (argc > 1)
+ operation = argv[1];
+ if (axutil_strcmp(operation, "-h") == 0)
+ {
+ printf("Usage : %s [operation] [param1] [param2] [endpoint_url]\n",
+ argv[0]);
+ printf("use -h for help\n");
+ printf("default operation get_version\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\n", operation);
+
+ node = build_om_programatically(env);
+ stub =
+ axis2_version_stub_create_with_endpoint_uri_and_client_home(env, address,
+ client_home);
+
+ /* create node and invoke version */
+ if (stub)
+ {
+ ret_node = axis2_version_stub_get_version(stub, env, node);
+ }
+
+ if (ret_node)
+ {
+ if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
+ {
+ axis2_char_t *result = NULL;
+ axiom_element_t *result_ele =
+ (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
+
+ result = axiom_element_get_text(result_ele, env, ret_node);
+ printf("\nResult = %s\n", result);
+ }
+ else
+ {
+ axiom_xml_writer_t *writer = NULL;
+ axiom_output_t *om_output = NULL;
+ axis2_char_t *buffer = NULL;
+ writer =
+ axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ om_output = axiom_output_create(env, writer);
+
+ axiom_node_serialize(ret_node, env, om_output);
+ buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, env);
+ printf("\nReceived invalid OM as result : %s\n", buffer);
+ if (buffer)
+ {
+ AXIS2_FREE(env->allocator, buffer);
+ buffer = NULL;
+ }
+ if (om_output)
+ {
+ axiom_output_free(om_output, env);
+ om_output = NULL;
+ }
+ axiom_xml_writer_free(writer, env);
+ }
+ }
+ else
+ {
+ 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("version stub invoke FAILED!\n");
+ }
+
+ if (stub)
+ {
+ axis2_stub_free(stub, env);
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return status;
+}
+
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env)
+{
+ axiom_node_t *version_om_node = NULL;
+ axiom_element_t *version_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+
+ axiom_xml_writer_t *xml_writer = NULL;
+ axiom_output_t *om_output = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "urn:aewebservices71",
+ "ns1");
+
+ version_om_ele =
+ axiom_element_create(env, NULL, "GetVersion", ns1, &version_om_node);
+
+
+ xml_writer =
+ axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ om_output = axiom_output_create(env, xml_writer);
+
+ axiom_node_serialize(version_om_node, env, om_output);
+ buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n",
+ buffer);
+ if (om_output)
+ {
+ axiom_output_free(om_output, env);
+ om_output = NULL;
+ }
+
+ return version_om_node;
+}
diff --git a/samples/client/yahoo/Makefile.am b/samples/client/yahoo/Makefile.am
new file mode 100644
index 0000000..3d8c3c8
--- /dev/null
+++ b/samples/client/yahoo/Makefile.am
@@ -0,0 +1,17 @@
+prgbindir=$(prefix)/samples/bin
+prgbin_PROGRAMS = yahoosearch
+yahoosearch_SOURCES = yahoo_client.c
+
+yahoosearch_LDADD = $(LDFLAGS) \
+ -L$(AXIS2C_HOME)/lib \
+ -laxutil \
+ -laxis2_axiom \
+ -laxis2_engine \
+ -laxis2_parser \
+ -laxis2_http_sender \
+ -laxis2_http_receiver \
+ $(GUTHTHILA_LIBS)
+
+INCLUDES = @AXIS2INC@
+
+EXTRA_DIST=yahoo.mk
diff --git a/samples/client/yahoo/yahoo.mk b/samples/client/yahoo/yahoo.mk
new file mode 100644
index 0000000..815ad00
--- /dev/null
+++ b/samples/client/yahoo/yahoo.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:yahoo.exe
+
+
+
+
+
diff --git a/samples/client/yahoo/yahoo_client.c b/samples/client/yahoo/yahoo_client.c
new file mode 100644
index 0000000..01fd97b
--- /dev/null
+++ b/samples/client/yahoo/yahoo_client.c
@@ -0,0 +1,207 @@
+
+/*
+ * 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_util.h>
+#include <axiom.h>
+#include <axis2_client.h>
+#include <axis2_http_transport.h>
+
+axiom_node_t *build_yahoo_rest_payload(
+ const axutil_env_t * env,
+ axis2_char_t * string);
+
+void format_output(
+ const axutil_env_t * env,
+ axiom_node_t * ret_node);
+
+void format_output_one(
+ const axutil_env_t * env,
+ axiom_node_t * child_node);
+
+int print_help(
+ );
+
+int
+main(
+ int argc,
+ char *argv[])
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = 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;
+ axiom_node_t *ret_node = NULL;
+ axis2_char_t *search_string = NULL;
+
+ if (argc > 1)
+ {
+
+ if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
+ {
+ print_help();
+ }
+ else
+ search_string = argv[1];
+ }
+
+ env = axutil_env_create_all("yahoo_rest_search.log", AXIS2_LOG_LEVEL_TRACE);
+ address = "http://search.yahooapis.com/WebSearchService/V1/webSearch";
+
+ printf("using endpoint %s \n", address);
+
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+
+ axis2_options_set_enable_rest(options, env, AXIS2_TRUE);
+ axis2_options_set_http_method(options, env, AXIS2_HTTP_GET);
+
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\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);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_yahoo_rest_payload(env, search_string);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ format_output(env, ret_node);
+ printf("\nYahoo REST client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ 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("Yahoo REST client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+axiom_node_t *
+build_yahoo_rest_payload(
+ const axutil_env_t * env,
+ axis2_char_t * string)
+{
+ axiom_node_t *root_node;
+ axiom_node_t *appid_node;
+ axiom_node_t *query_node;
+ axiom_element_t *appid_element;
+ axiom_element_t *query_element;
+ axiom_element_t *root_element;
+
+ root_element =
+ axiom_element_create(env, NULL, "yahoo_rest_search", NULL, &root_node);
+ appid_element =
+ axiom_element_create(env, root_node, "appid", NULL, &appid_node);
+ axiom_element_set_text(appid_element, env, "YahooDemo", appid_node);
+ query_element =
+ axiom_element_create(env, root_node, "query", NULL, &query_node);
+
+ if (string)
+ {
+ axiom_element_set_text(query_element, env, string, query_node);
+ }
+ else
+ {
+ axiom_element_set_text(query_element, env, "finance", query_node);
+ }
+
+ return root_node;
+}
+
+void
+format_output(
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axiom_node_t *child_node;
+ child_node = axiom_node_get_first_child(node, env);
+ while (axiom_node_is_complete(node, env) && child_node)
+ {
+ printf("\n\n");
+ format_output_one(env, child_node);
+ child_node = axiom_node_get_next_sibling(child_node, env);
+ }
+
+}
+
+void
+format_output_one(
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axiom_node_t *child_node;
+ child_node = axiom_node_get_first_child(node, env);
+ while (axiom_node_is_complete(node, env) && child_node)
+ {
+ axis2_char_t *om_str = axiom_node_to_string(child_node, env);
+ if (om_str)
+ {
+ printf("\t%s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ child_node = axiom_node_get_next_sibling(child_node, env);
+ }
+}
+
+int
+print_help(
+ )
+{
+ printf("./yahoosearch string_to_search \n");
+ exit(0);
+ return 0;
+}