axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r377114 - in /webservices/axis2/trunk/c/samples/client/addr_echo: ./ Makefile.am README.txt echo_client.c
Date Sun, 12 Feb 2006 03:15:41 GMT
Author: samisa
Date: Sat Feb 11 19:15:39 2006
New Revision: 377114

URL: http://svn.apache.org/viewcvs?rev=377114&view=rev
Log:
Added sample to demo addressing on client side

Added:
    webservices/axis2/trunk/c/samples/client/addr_echo/
    webservices/axis2/trunk/c/samples/client/addr_echo/Makefile.am
    webservices/axis2/trunk/c/samples/client/addr_echo/README.txt
    webservices/axis2/trunk/c/samples/client/addr_echo/echo_client.c

Added: webservices/axis2/trunk/c/samples/client/addr_echo/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/client/addr_echo/Makefile.am?rev=377114&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/client/addr_echo/Makefile.am (added)
+++ webservices/axis2/trunk/c/samples/client/addr_echo/Makefile.am Sat Feb 11 19:15:39 2006
@@ -0,0 +1,38 @@
+prgbindir=$(prefix)/bin/samples
+prgbin_PROGRAMS = addr_echo
+addr_echo_SOURCES = echo_client.c
+
+addr_echo_LDADD   =  -L$(AXIS2C_HOME)/lib \
+					-laxis2_util \
+                    -laxis2_context \
+                    -laxis2_description \
+                    -laxis2_deployment \
+                    -laxis2_phaseresolver \
+                    -laxis2_om \
+                    -laxis2_wsdl \
+                    -laxis2_engine \
+                    -laxis2_parser \
+                    -laxis2_addr \
+                    -laxis2_unix \
+                    -laxis2_receivers \
+                    -laxis2_core_util \
+                    -laxis2_clientapi \
+                    -laxis2_soap \
+                    -laxis2_http_transport \
+                    -laxis2_http_sender \
+                    -laxis2_http_receiver \
+                    -L$(GUTHTHILA_LIB) $(GUTHTHILA_LIBNAME) \
+                    -L$(LIBXML2_LIB) $(LIBXML2_LIBNAME)
+
+INCLUDES = -I$(top_builddir)/include \
+            -I$(top_builddir)/modules/util \
+            -I$(top_builddir)/modules/core/description \
+            -I$(top_builddir)/modules/core/deployment \
+            -I$(top_builddir)/modules/wsdl \
+            -I$(top_builddir)/modules/core/transport \
+            -I$(top_builddir)/modules/platforms \
+            -I$(top_builddir)/modules/xml/parser \
+            -I$(top_builddir)/include
+
+
+

Added: webservices/axis2/trunk/c/samples/client/addr_echo/README.txt
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/client/addr_echo/README.txt?rev=377114&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/client/addr_echo/README.txt (added)
+++ webservices/axis2/trunk/c/samples/client/addr_echo/README.txt Sat Feb 11 19:15:39 2006
@@ -0,0 +1,2 @@
+This is a sample to help test addressing.
+This sample works with echo service.

Added: webservices/axis2/trunk/c/samples/client/addr_echo/echo_client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/client/addr_echo/echo_client.c?rev=377114&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/client/addr_echo/echo_client.c (added)
+++ webservices/axis2/trunk/c/samples/client/addr_echo/echo_client.c Sat Feb 11 19:15:39 2006
@@ -0,0 +1,153 @@
+#include <axis2_om_stax_builder.h>
+#include <axis2_om_document.h>
+#include <axis2_om_node.h>
+#include <axis2_om_element.h>
+#include <axis2_om_text.h>
+#include <axis2_stream.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axis2_xml_reader.h>
+#include <stdio.h>
+#include <axis2_xml_writer.h>
+#include <axis2_soap_builder.h>
+#include <axis2_soap.h>
+#include <axis2_soap_envelope.h>
+#include <axis2_soap_body.h>
+#include <axis2_soap_header.h>
+#include <axis2_soap_message.h>
+#include <axis2_soap_header_block.h>
+#include <axis2_soap_fault.h>
+#include <axis2_soap_fault_code.h>
+#include <axis2_soap_fault_role.h>
+
+axis2_om_node_t *
+build_om_programatically(axis2_env_t **env);
+
+int main(int argc, char** argv)
+{
+    axis2_om_node_t *node = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_env_t *env = NULL;
+    axis2_error_t *error = NULL;
+    axis2_log_t *log = NULL;
+    axis2_allocator_t *allocator = NULL;
+    axis2_char_t *address = NULL;
+    axis2_char_t *wsa_action = NULL;
+    axis2_char_t *client_home = NULL;
+    axis2_om_node_t *ret_node = NULL;
+    
+    allocator = axis2_allocator_init (NULL);
+    error = axis2_error_create(allocator);
+    log = axis2_log_create(allocator, NULL, "/dev/stderr");
+    env = axis2_env_create_with_error_log(allocator, error, log);
+    env->log->level = AXIS2_LOG_LEVEL_TRACE;
+    axis2_error_init();
+
+    client_home = AXIS2_GETENV("AXIS2C_HOME");
+    if (!client_home)
+        client_home = "../../deploy";
+    
+    address = "http://localhost:9090/axis2/services/echo/echo";
+    wsa_action = "http://127.0.0.1:9090/axis2/services/echo/echoString";
+    if (argc > 1 )
+        address = argv[1];
+    if (AXIS2_STRCMP(address, "-h") == 0)
+    {
+        printf("Usage : %s [endpoint_url]\n", argv[0]);
+        printf("use -h for help\n");
+        return 0;
+    }
+
+    printf ("Using endpoint : %s\n", address);
+
+    node = build_om_programatically(&env);
+
+    /* create call without passing svc_ctx_t struct */
+    axis2_call_t *call = axis2_call_create(&env, NULL, client_home);
+    axis2_msg_ctx_t *msg_ctx = NULL;
+    axis2_mep_client_t *mep_client = AXIS2_CALL_GET_BASE(call, &env);
+    msg_ctx = AXIS2_MEP_CLIENT_PREPARE_SOAP_ENVELOPE(mep_client, &env, node);
+    axis2_msg_info_headers_t *msg_info_headers = AXIS2_MSG_CTX_GET_MSG_INFO_HEADERS(msg_ctx,
&env);
+    axis2_endpoint_ref_t* endpoint_ref = axis2_endpoint_ref_create(&env, address);
+    AXIS2_MSG_INFO_HEADERS_SET_TO(msg_info_headers, &env, endpoint_ref);
+    AXIS2_MSG_INFO_HEADERS_SET_ACTION(msg_info_headers, &env, wsa_action); 
+    AXIS2_CALL_SET_TO(call, &env, endpoint_ref);
+    axis2_qname_t *svc_qname = axis2_qname_create(&env, "echo", NULL, NULL);
+    axis2_svc_t *svc = axis2_svc_create_with_qname(&env, svc_qname);
+    axis2_qname_t *op_qname = axis2_qname_create(&env, "echoString", NULL, NULL);
+    axis2_op_t *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);
+
+    AXIS2_CONF_ADD_SVC(AXIS2_CONF_CTX_GET_CONF(AXIS2_SVC_CTX_GET_CONF_CTX(AXIS2_MEP_CLIENT_GET_SVC_CTX(mep_client,
&env), &env), &env), &env, svc);
+
+    axis2_msg_ctx_t *response_ctx = AXIS2_CALL_INVOKE_BLOCKING(call, &env, op, msg_ctx);
+
+    if (response_ctx)
+    {
+        axis2_soap_envelope_t *soap_envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(response_ctx,
&env);
+        ret_node = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(soap_envelope, &env);
+    }
+                                                        
+    if(ret_node)
+    {
+        axis2_xml_writer_t *writer = NULL;
+        axis2_om_output_t *om_output = NULL;
+        axis2_char_t *buffer = NULL;
+        
+        printf("\necho stub invoke successful!\n");
+        writer = axis2_xml_writer_create_for_memory(&env, NULL, AXIS2_TRUE, 0);
+        om_output = axis2_om_output_create (&env, writer);
+
+        AXIS2_OM_NODE_SERIALIZE (ret_node, &env, om_output);
+        buffer = AXIS2_XML_WRITER_GET_XML(writer, &env);
+        printf ("\nReceived OM node in XML : %s\n", buffer);
+    }
+    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 stub invoke failed!\n");
+    }
+    
+    if (node)
+    {
+        AXIS2_OM_NODE_FREE_TREE(node, &env);
+    }
+    return status;
+}
+
+axis2_om_node_t *
+build_om_programatically(axis2_env_t **env)
+{
+    axis2_om_node_t *echo_om_node = NULL;
+    axis2_om_element_t* echo_om_ele = NULL;
+    axis2_om_node_t* text_om_node = NULL;
+    axis2_om_element_t * text_om_ele = NULL;
+    axis2_om_namespace_t *ns1 = NULL;
+    
+
+    axis2_xml_writer_t *xml_writer = NULL;
+    axis2_om_output_t *om_output = NULL;
+    axis2_char_t *buffer = NULL;
+
+    ns1 = axis2_om_namespace_create (env, "http://localhost:9090/axis2/services/echo", "ns1");
+
+    echo_om_ele = axis2_om_element_create(env, NULL, "echoString", ns1, &echo_om_node);
+    
+    text_om_ele = axis2_om_element_create(env, echo_om_node, "text", NULL, &text_om_node);
+
+    AXIS2_OM_ELEMENT_SET_TEXT(text_om_ele, env, "echo5", text_om_node);
+    
+    
+    xml_writer = axis2_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE);
+    om_output = axis2_om_output_create( env, xml_writer);
+    
+    AXIS2_OM_NODE_SERIALIZE(echo_om_node, env, om_output);
+    buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);         
+    printf("\nSending OM node in XML : %s \n",  buffer); 
+
+    return echo_om_node;
+}
+



Mime
View raw message