Author: samisa
Date: Thu Jun 15 01:45:38 2006
New Revision: 414507

URL: http://svn.apache.org/viewvc?rev=414507&view=rev
Log:
Updated to use service client API

Modified:
    webservices/axis2/trunk/c/test/itest/whitemesa/round1/round1_client.c
    webservices/axis2/trunk/c/test/itest/whitemesa/round2/input
    webservices/axis2/trunk/c/test/itest/whitemesa/round2/round2_client.c

Modified: webservices/axis2/trunk/c/test/itest/whitemesa/round1/round1_client.c
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/c/test/itest/whitemesa/round1/round1_client.c?rev=414507&r1=414506&r2=414507&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/itest/whitemesa/round1/round1_client.c 
(original)
+++ webservices/axis2/trunk/c/test/itest/whitemesa/round1/round1_client.c Thu 
Jun 15 01:45:38 2006
@@ -14,92 +14,48 @@
  * limitations under the License.
  */
 
-#include <axiom_stax_builder.h>
-#include <axiom_document.h>
-#include <axiom_node.h>
-#include <axiom_element.h>
-#include <axiom_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 <axiom_soap_builder.h>
-#include <axiom_soap_const.h>
-#include <axiom_soap_envelope.h>
-#include <axiom_soap_body.h>
-#include <axiom_soap_header.h>
-#include <axiom_soap_message.h>
-#include <axiom_soap_header_block.h>
-#include <axiom_soap_fault.h>
-#include <axiom_soap_fault_code.h>
-#include <axiom_soap_fault_role.h>
-#include <axiom_node.h>
-#include <axis2_msg_ctx.h>
-#include <axis2_call.h>
-#include <ctype.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
 #include <string.h>
 
 axiom_node_t *build_soap_body_content (const axis2_env_t *env,
                                           axis2_char_t * echo_operation,
                                           axis2_char_t * echo_type,
-                                          axis2_char_t * word_to_echo,
-                                          axiom_node_t * body_node);
-
-void print_invalid_om (const axis2_env_t *env, axiom_node_t * ret_node);
+                                          axis2_char_t * word_to_echo);
 
 int
 main (int argc, char **argv)
 {
-    axiom_node_t *node = NULL;
-    axis2_status_t status = AXIS2_FAILURE;
-    const axis2_env_t *env = NULL;
-    axis2_error_t *error = NULL;
-    axis2_log_t *log = NULL;
-    axis2_allocator_t *allocator = NULL;
+    axis2_env_t *env = NULL;
     axis2_char_t *address = NULL;
+    axis2_endpoint_ref_t* endpoint_ref = NULL;
+    axis2_options_t *options = NULL;
     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_svc_t *svc = NULL;
-    axis2_op_t *op = NULL;
-    axis2_call_t *call = NULL;
-    axis2_msg_ctx_t *msg_ctx = NULL;
-    axis2_mep_client_t *mep_client = NULL;
-    axis2_endpoint_ref_t *endpoint_ref = NULL;
-    axis2_conf_t *conf = NULL;
-    axis2_msg_ctx_t *response_ctx = NULL;
-    axiom_soap_envelope_t *soap_envelope = NULL;
-    axiom_soap_body_t *soap_body = NULL;
-    axiom_namespace_t *env_ns = NULL;
-    axiom_node_t *body_node = NULL;
+    axiom_element_t *ret_ele = NULL;
+    axis2_char_t *om_str = NULL;
+    axis2_char_t *result = NULL;
+    
     axis2_char_t *echo_operation = NULL;
     axis2_char_t *word_to_echo = NULL;
     axis2_char_t *echo_type = NULL;
     axis2_char_t operation[32];
-    allocator = axis2_allocator_init (NULL);
+    axis2_char_t echo_response_buff[32];
 
     echo_operation = "String";
     word_to_echo = "helloworld";
     echo_type = "string";
-
-    allocator = axis2_allocator_init (NULL);
-    error = axis2_error_create (allocator);
-    log = axis2_log_create (allocator, NULL, "test_client.log");
-    env = axis2_env_create_with_error_log (allocator, error, log);
-    env->log->level = AXIS2_LOG_LEVEL_INFO;
-    axis2_error_init ();
-
-    client_home = getenv ("AXIS2C_HOME");
-    if (!client_home)
-        client_home = "../../deploy";
-
-    address = "http://easysoap.sourceforge.net/cgi-bin/interopserver";;
-
+ 
     if ((argc > 1) && (AXIS2_STRCMP ("-h", argv[1]) == 0))
     {
         printf ("\nUsage : %s [echo_operation] [echo_value] [XSD_type]\n",
                 argv[0]);
+               printf("use -h for help\n");
         return 0;
     }
 
@@ -109,127 +65,77 @@
         word_to_echo = argv[2];
     if (argc > 3)
         echo_type = argv[3];
-
+    
+    /* address = "http://localhost:7070/cgi-bin/interopserver";; */
+    address = "http://easysoap.sourceforge.net/cgi-bin/interopserver";;
+       
     sprintf (operation, "echo%s", echo_operation);
 
     printf ("Using endpoint : %s\n", address);
     printf ("Invoking %s with param %s\n", operation, word_to_echo);
 
 
-    /* create call without passing svc_ctx_t struct */
-    call = axis2_call_create (env, NULL, client_home);
-    mep_client = AXIS2_CALL_GET_BASE (call, env);
-    /* prepare SOAP envelope */
-    env_ns =
-        axiom_namespace_create (env,
-                                   AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI,
-                                   "soap");
-    soap_envelope = axiom_soap_envelope_create (env, env_ns);
-    soap_body = axiom_soap_body_create_with_parent (env, soap_envelope);
-    body_node = AXIOM_SOAP_BODY_GET_BASE_NODE (soap_body, env);
-    build_soap_body_content (env, echo_operation, echo_type, word_to_echo,
-                             body_node);
-
-    /*print_invalid_om(env, body_node); */
-
+    /* Set up the environment */
+    env = axis2_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
 
-    msg_ctx = AXIS2_MEP_CLIENT_PREPARE_SOAP_ENVELOPE (mep_client, env, node);
-    if (!msg_ctx)
-    {
-        printf("ERROR: Could not prepare message context. ");
-        printf("May be you havent set the repository corretly.\n");
-        return -1;
-    }
-
-    AXIS2_MSG_CTX_SET_SOAP_ENVELOPE (msg_ctx, env, soap_envelope);
-    endpoint_ref = axis2_endpoint_ref_create (env, address);
-    AXIS2_CALL_SET_TO (call, env, endpoint_ref);
-    conf =
-        AXIS2_CONF_CTX_GET_CONF (AXIS2_SVC_CTX_GET_CONF_CTX
-                                 (AXIS2_MEP_CLIENT_GET_SVC_CTX
-                                  (mep_client, env), env), env);
-    svc = AXIS2_CONF_GET_SVC (conf, env, "echo");
-    /*if (svc)
-       {
-       op = AXIS2_SVC_GET_OP_WITH_NAME(svc, env, "echoString");
-       if (op)
-       {
-       AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, env, AXIS2_MEP_URI_OUT_IN);
-       }
-       }
-       else */
-    {
-        axis2_qname_t *op_qname = NULL;
-        axis2_qname_t *svc_qname =
-            axis2_qname_create (env, "echo", NULL, NULL);
-        svc = axis2_svc_create_with_qname (env, svc_qname);
-        op_qname = axis2_qname_create (env, operation, NULL, 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);
-        AXIS2_CONF_ADD_SVC (conf, env, svc);
-    }
+    /* Create EPR with given address */
+       
+    endpoint_ref = axis2_endpoint_ref_create(env, address);
+    options = axis2_options_create(env);
+    AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref);
+  
+    /* this itest requried soap 1.1 message */ 
+    AXIS2_OPTIONS_SET_SOAP_VERSION(options, env, AXIOM_SOAP11); 
+    client_home = AXIS2_GETENV("AXIS2C_HOME");
+    if (!client_home)
+        client_home = "../../deploy";
 
-    if (!op)
-    {
-        printf ("ERROR: echo_operation not present in service\n");
-        return -1;
-    }
-    response_ctx = AXIS2_CALL_INVOKE_BLOCKING (call, env, op, msg_ctx);
+    /* Create service client */
+    svc_client = axis2_svc_client_create(env, client_home);
+    if (!svc_client)
+    {
+        printf("Error creating service client\n");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"Stub invoke FAILED: Error 
code:"
+                  " %d :: %s", env->error->error_number,
+                        AXIS2_ERROR_GET_MESSAGE(env->error));
+    }
+    
+    /* Set service client options */
+    AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options);
+
+    payload = build_soap_body_content (env, echo_operation,
+                                      echo_type, word_to_echo);
+    /* Send request */
+    ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload );
+    
 
-    if (response_ctx)
-    {
-        axiom_soap_envelope_t *soap_envelope =
-            AXIS2_MSG_CTX_GET_SOAP_ENVELOPE (response_ctx, env);
-        ret_node = AXIOM_SOAP_ENVELOPE_GET_BASE_NODE (soap_envelope, env);
-    }
 
     if (ret_node)
     {
-        print_invalid_om (env, ret_node);
+        om_str = AXIOM_NODE_TO_STRING(ret_node, env);
+        if (om_str)
+          printf("\nRecieving OM : %s\n", om_str);
         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;
-            axis2_char_t echo_response_buff[32];
-            
-            ret_node1 = AXIOM_NODE_GET_FIRST_CHILD (ret_node, env); /*Body */
-            if (!ret_node1)
-            {
-                print_invalid_om (env, ret_node);
-                return AXIS2_FAILURE;
-            }
-            ret_node = AXIOM_NODE_GET_FIRST_CHILD (ret_node1, env); 
/*GetTypeResponse */
-            if (!ret_node)
-            {
-                print_invalid_om (env, ret_node1);
-                return AXIS2_FAILURE;
-            }
-            /*see if we have got a fault */
             
             sprintf (echo_response_buff, "echo%sResponse", echo_operation);
-            result_ele =
+            ret_ele =
                 (axiom_element_t *)
                 AXIOM_NODE_GET_DATA_ELEMENT (ret_node, env);
             if (AXIS2_STRCMP
-                (AXIOM_ELEMENT_GET_LOCALNAME (result_ele, env),
+                (AXIOM_ELEMENT_GET_LOCALNAME (ret_ele, env),
                  echo_response_buff) != 0)
             {
-                print_invalid_om (env, ret_node1);
+               printf ( "%s != %s\n", AXIOM_ELEMENT_GET_LOCALNAME (ret_ele, 
env), echo_response_buff);
+                printf ("\nFAIL\n\n");
                 return AXIS2_FAILURE;
             }
 
-            ret_node1 = AXIOM_NODE_GET_FIRST_CHILD (ret_node, env); /*return */
-            if (!ret_node1)
-            {
-                print_invalid_om (env, ret_node);
-                return AXIS2_FAILURE;
-            }
-            result_ele =
+            ret_node = AXIOM_NODE_GET_FIRST_CHILD (ret_node, env);
+            ret_ele =
                 (axiom_element_t *)
-                AXIOM_NODE_GET_DATA_ELEMENT (ret_node1, env);
-            result = AXIOM_ELEMENT_GET_TEXT (result_ele, env, ret_node1);
+                AXIOM_NODE_GET_DATA_ELEMENT (ret_node, env);
+            result = AXIOM_ELEMENT_GET_TEXT (ret_ele, env, ret_node);
             if (!strcmp (word_to_echo, result))
             {
                 printf ("\nSUCCESS\n\n");
@@ -253,52 +159,43 @@
                          env->error->error_number,
                          AXIS2_ERROR_GET_MESSAGE (env->error));
         printf ("round1 stub invoke FAILED!\n");
+        return AXIS2_FAILURE;
     }
 
-    /*if (node)
-       {
-       AXIOM_NODE_FREE_TREE(node, env);
-       } */
-    return status;
+    return AXIS2_SUCCESS;
 }
 
 axiom_node_t *
 build_soap_body_content (const axis2_env_t *env, axis2_char_t * echo_operation,
                          axis2_char_t * echo_type,
-                         axis2_char_t * word_to_echo,
-                         axiom_node_t * body_node)
+                         axis2_char_t * word_to_echo)
 {
-    axiom_node_t *envelope_node = NULL;
-    axiom_element_t *envelope_element = NULL;
-    axiom_element_t *body_om_ele = NULL;
 
-    axiom_node_t *echo_om_node = NULL;
-    axiom_element_t *echo_om_ele = NULL;
+    axiom_node_t *operation_om_node = NULL;
+    axiom_element_t *operation_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,
-        *ns4 = NULL, *ns5 = NULL, *ns6 = NULL;
 
     axiom_attribute_t *attri1 = NULL;
-
-    axis2_xml_writer_t *xml_writer = NULL;
-    axis2_xml_writer_t *writer = NULL;
-    axiom_output_t *om_output = NULL;
-    axis2_char_t *buffer = NULL;
+    axiom_namespace_t *ns0 = NULL, *ns1 = NULL, *ns2 = NULL, *ns3 = NULL,
+        *ns4 = NULL, *ns5 = NULL;
+    axis2_char_t *om_str = NULL;
+    
 
     axis2_char_t echo_operation_buff[32];
     axis2_char_t input_type_buff[32];
     axis2_char_t xsd_type_buff[32];
 
     /*generating the requried parameters */
-
-
-
     sprintf (echo_operation_buff, "echo%s", echo_operation);
     sprintf (input_type_buff, "input%s", echo_operation);
     sprintf (xsd_type_buff, "xsd:%s", echo_type);
 
-
+    ns0 =
+        axiom_namespace_create (env,
+                                   "http://schemas.xmlsoap.org/soap/envelope/";,
+                                   "soapenv");
     ns1 =
         axiom_namespace_create (env,
                                    "http://www.w3.org/2001/XMLSchema-instance";,
@@ -315,73 +212,41 @@
         axiom_namespace_create (env, "http://soapinterop.org/encodedTypes";,
                                    "types");
 
-    envelope_node = AXIOM_NODE_GET_PARENT (body_node, env);
-    envelope_element =
-        (axiom_element_t *) AXIOM_NODE_GET_DATA_ELEMENT (envelope_node,
-                                                               env);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE (envelope_element, env, envelope_node,
-                                        ns1);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE (envelope_element, env, envelope_node,
-                                        ns2);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE (envelope_element, env, envelope_node,
-                                        ns3);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE (envelope_element, env, envelope_node,
-                                        ns4);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE (envelope_element, env, envelope_node,
-                                        ns5);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE (envelope_element, env, envelope_node,
-                                        ns6);
-    ns0 = AXIOM_ELEMENT_GET_NAMESPACE (envelope_element, env, envelope_node);
+    operation_om_ele = axiom_element_create(env, NULL, echo_operation_buff,
+                                              ns4, &operation_om_node);
+   
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns0);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns1);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns2);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns3);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns4);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns5);
+
     attri1 =
         axiom_attribute_create (env, "encodingStyle",
                                    "http://schemas.xmlsoap.org/soap/encoding/";,
                                    ns0);
 
-    body_om_ele = AXIOM_NODE_GET_DATA_ELEMENT (body_node, env);
-    AXIOM_ELEMENT_ADD_ATTRIBUTE (body_om_ele, env, attri1, body_node);
+    operation_om_ele = AXIOM_NODE_GET_DATA_ELEMENT (operation_om_node, env);
+    AXIOM_ELEMENT_ADD_ATTRIBUTE (operation_om_ele, env, attri1, 
operation_om_node);
 
-    echo_om_ele =
-        axiom_element_create (env, body_node, echo_operation_buff, ns4,
-                                 &echo_om_node);
 
     text_om_ele =
-        axiom_element_create (env, echo_om_node, input_type_buff, NULL,
+        axiom_element_create (env, operation_om_node, input_type_buff, NULL,
                                  &text_om_node);
     attri1 = axiom_attribute_create (env, "type", xsd_type_buff, ns1);
     AXIOM_ELEMENT_ADD_ATTRIBUTE (text_om_ele, env, attri1, text_om_node);
     AXIOM_ELEMENT_SET_TEXT (text_om_ele, env, word_to_echo, text_om_node);
 
-    xml_writer =
-        axis2_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 (echo_om_node, env, om_output);
-    buffer = (axis2_char_t*)AXIS2_XML_WRITER_GET_XML (xml_writer, env);
-    AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
-                     "\nSending OM node in XML : %s \n", buffer);
-
-    writer = axis2_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 (envelope_node, env, om_output);
-    buffer = (axis2_char_t*)AXIS2_XML_WRITER_GET_XML (writer, env);
-    printf ("Sending :\n%s\n", buffer);
-    return echo_om_node;
-}
-
-void
-print_invalid_om (const axis2_env_t *env, axiom_node_t * ret_node)
-{
+    om_str = AXIOM_NODE_TO_STRING(operation_om_node, env);
+    if (om_str)
+        printf("\nSending OM : %s\n", om_str);
 
-    axis2_xml_writer_t *writer = NULL;
-    axiom_output_t *om_output = NULL;
-    axis2_char_t *buffer = NULL;
-    writer = axis2_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*)AXIS2_XML_WRITER_GET_XML (writer, env);
-    printf ("Received : \n%s\n", buffer);
+    return operation_om_node;
 }

Modified: webservices/axis2/trunk/c/test/itest/whitemesa/round2/input
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/c/test/itest/whitemesa/round2/input?rev=414507&r1=414506&r2=414507&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/itest/whitemesa/round2/input (original)
+++ webservices/axis2/trunk/c/test/itest/whitemesa/round2/input Thu Jun 15 
01:45:38 2006
@@ -3,4 +3,4 @@
 Float 2.4
 Decimal 2.4
 Boolean true
-Date 2005-06-30T19:00:00Z
+Date 2005-06-30T12:00:00.0000000-07:00

Modified: webservices/axis2/trunk/c/test/itest/whitemesa/round2/round2_client.c
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/c/test/itest/whitemesa/round2/round2_client.c?rev=414507&r1=414506&r2=414507&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/itest/whitemesa/round2/round2_client.c 
(original)
+++ webservices/axis2/trunk/c/test/itest/whitemesa/round2/round2_client.c Thu 
Jun 15 01:45:38 2006
@@ -14,307 +14,228 @@
  * limitations under the License.
  */
 
-#include <axiom_stax_builder.h>
-#include <axiom_document.h>
-#include <axiom_node.h>
-#include <axiom_element.h>
-#include <axiom_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 <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
 #include <string.h>
-#include <axis2_xml_writer.h>
-#include <axiom_soap_builder.h>
-#include <axiom_soap_const.h>
-#include <axiom_soap_envelope.h>
-#include <axiom_soap_body.h>
-#include <axiom_soap_header.h>
-#include <axiom_soap_message.h>
-#include <axiom_soap_header_block.h>
-#include <axiom_soap_fault.h>
-#include <axiom_soap_fault_code.h>
-#include <axiom_soap_fault_role.h>
-#include <axiom_node.h>
-#include <axis2_msg_ctx.h>
-#include <axis2_call.h>
-#include <ctype.h>
 
-axiom_node_t *
-build_soap_body_content(const axis2_env_t *env, axis2_char_t *echo_operation,
-                        axis2_char_t *word_to_echo, axiom_node_t *body_node);
-
-void print_invalid_om(const axis2_env_t *env, axiom_node_t *ret_node);
+axiom_node_t *build_soap_body_content (const axis2_env_t *env,
+                                          axis2_char_t * echo_operation,
+                                          axis2_char_t * echo_type,
+                                          axis2_char_t * word_to_echo);
 
-int main(int argc, char** argv)
+int
+main (int argc, char **argv)
 {
-    axiom_node_t *node = NULL;
-    axis2_status_t status = AXIS2_FAILURE;
-    const axis2_env_t *env = NULL;
-    axis2_error_t *error = NULL;
-    axis2_log_t *log = NULL;
-    axis2_allocator_t *allocator = NULL;
+    axis2_env_t *env = NULL;
     axis2_char_t *address = NULL;
+    axis2_endpoint_ref_t* endpoint_ref = NULL;
+    axis2_options_t *options = NULL;
     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_svc_t *svc = NULL;
-    axis2_op_t *op = NULL;
-    axis2_call_t *call = NULL;
-    axis2_msg_ctx_t *msg_ctx = NULL;
-    axis2_mep_client_t *mep_client = NULL;
-    axis2_endpoint_ref_t* endpoint_ref = NULL;
-    axis2_conf_t *conf = NULL;
-    axis2_msg_ctx_t *response_ctx = NULL;
-    axiom_soap_envelope_t *soap_envelope = NULL;
-    axiom_soap_body_t *soap_body = NULL;
-    axiom_namespace_t *env_ns = NULL;
-    axiom_node_t *body_node = NULL;
+    axiom_element_t *ret_ele = NULL;
+    axis2_char_t *om_str = NULL;
+    axis2_char_t *result = NULL;
+    
     axis2_char_t *echo_operation = NULL;
     axis2_char_t *word_to_echo = NULL;
-    axis2_char_t operation[32] ;
-    allocator = axis2_allocator_init (NULL);
+    axis2_char_t *echo_type = NULL;
+    axis2_char_t operation[32];
+    axis2_char_t echo_response_buff[32];
 
     echo_operation = "String";
     word_to_echo = "helloworld";
-    
-    allocator = axis2_allocator_init (NULL);
-    error = axis2_error_create(allocator);
-    log = axis2_log_create(allocator, NULL, "test_client.log");
-    env = axis2_env_create_with_error_log(allocator, error, log);
-    env->log->level = AXIS2_LOG_LEVEL_INFO;
-    axis2_error_init();
-
-    client_home = getenv("AXIS2C_HOME");
-    if (!client_home)
-        client_home = "../../deploy";
-    
-    address = "http://www.mssoapinterop.org/asmx/simple.asmx";;
-    
-    if ( (argc > 1) && (AXIS2_STRCMP("-h", argv[1]) == 0) )
-    {
-        printf("\nUsage : %s [echo_operation] [word_to_echo] \n", argv[0]);
+    echo_type = "string";
+ 
+    if ((argc > 1) && (AXIS2_STRCMP ("-h", argv[1]) == 0))
+    {
+        printf ("\nUsage : %s [echo_operation] [echo_value] [XSD_type]\n",
+                argv[0]);
+               printf("use -h for help\n");
         return 0;
     }
 
-    if (argc > 1 )
+    if (argc > 1)
         echo_operation = argv[1];
-    if (argc > 2 )
+    if (argc > 2)
         word_to_echo = argv[2];
-
-    sprintf( operation, "echo%s", echo_operation );
+    if (argc > 3)
+        echo_type = argv[3];
     
+    /* address = "http://localhost:7070/asmx/simple.asmx";; */
+    address = "http://www.mssoapinterop.org/asmx/simple.asmx";;
+       
+    sprintf (operation, "echo%s", echo_operation);
+
     printf ("Using endpoint : %s\n", address);
-    printf ("\nInvoking %s with param %s\n", operation, word_to_echo);
+    printf ("Invoking %s with param %s\n", operation, word_to_echo);
 
 
-    /* create call without passing svc_ctx_t struct */
-    call = axis2_call_create(env, NULL, client_home);
-    mep_client = AXIS2_CALL_GET_BASE(call, env);
-    /* prepare SOAP envelope */
-    env_ns = axiom_namespace_create(env, 
AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, "soap"); 
-    soap_envelope = axiom_soap_envelope_create(env, env_ns);
-    soap_body = axiom_soap_body_create_with_parent(env, soap_envelope);
-    body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(soap_body, env);
-    build_soap_body_content(env, echo_operation, word_to_echo, body_node);
+    /* Set up the environment */
+    env = axis2_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
 
-    
-    msg_ctx = AXIS2_MEP_CLIENT_PREPARE_SOAP_ENVELOPE(mep_client, env, node);
-    if (!msg_ctx)
-    {
-        printf("ERROR: Could not prepare message context. ");
-        printf("May be you havent set the repository corretly.\n");
-        return -1;
-    }
-
-    AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(msg_ctx, env, soap_envelope);
+    /* Create EPR with given address */
+       
     endpoint_ref = axis2_endpoint_ref_create(env, address);
-    AXIS2_CALL_SET_TO(call, env, endpoint_ref);
-    conf = AXIS2_CONF_CTX_GET_CONF(
-                            AXIS2_SVC_CTX_GET_CONF_CTX(
-                                AXIS2_MEP_CLIENT_GET_SVC_CTX(mep_client, env), 
-                                env), 
-                                env);
-    svc = AXIS2_CONF_GET_SVC(conf, env, "simpletest");
-    if (svc)
-    {
-        op = AXIS2_SVC_GET_OP_WITH_NAME(svc, env, "simpletest");
-        if (op)
-        {
-            AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, env, AXIS2_MEP_URI_OUT_IN);
-        }
-    }
-    else
-    {
-        axis2_qname_t *op_qname = NULL;
-        axis2_qname_t *svc_qname = axis2_qname_create(env, "simpletest", NULL, 
NULL);
-        svc = axis2_svc_create_with_qname(env, svc_qname);
-        op_qname = axis2_qname_create(env, operation , NULL, 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);
-        AXIS2_CONF_ADD_SVC(conf, env, svc);
-    }
+    options = axis2_options_create(env);
+    AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref);
+  
+    /* this itest requried soap 1.1 message */ 
+    AXIS2_OPTIONS_SET_SOAP_VERSION(options, env, AXIOM_SOAP11); 
+    client_home = AXIS2_GETENV("AXIS2C_HOME");
+    if (!client_home)
+        client_home = "../../deploy";
 
-    if (!op)
+    /* Create service client */
+    svc_client = axis2_svc_client_create(env, client_home);
+    if (!svc_client)
     {
-        printf("ERROR: echo_operation not present in service\n");
-        return -1;
+        printf("Error creating service client\n");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"Stub invoke FAILED: Error 
code:"
+                  " %d :: %s", env->error->error_number,
+                        AXIS2_ERROR_GET_MESSAGE(env->error));
     }
-    response_ctx = AXIS2_CALL_INVOKE_BLOCKING(call, env, op, msg_ctx);
+    
+    /* Set service client options */
+    AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options);
+
+    payload = build_soap_body_content (env, echo_operation,
+                                      echo_type, word_to_echo);
+    /* Send request */
+    ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload );
+    
 
-    if (response_ctx)
-    {
-        axiom_soap_envelope_t *soap_envelope = 
AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(response_ctx, env);
-        ret_node = AXIOM_SOAP_ENVELOPE_GET_BASE_NODE(soap_envelope, env);
-    }
 
-    if(ret_node)
+    if (ret_node)
     {
-        if (AXIOM_NODE_GET_NODE_TYPE(ret_node, env) == AXIOM_ELEMENT)
+        om_str = AXIOM_NODE_TO_STRING(ret_node, env);
+        if (om_str)
+          printf("\nRecieving OM : %s\n", om_str);
+        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;
-            axis2_char_t echo_response_buff[32];
             
-            ret_node1 = AXIOM_NODE_GET_FIRST_CHILD(ret_node, env); /*Body*/
-            if (!ret_node1)
+            sprintf (echo_response_buff, "echo%sResponse", echo_operation);
+            ret_ele =
+                (axiom_element_t *)
+                AXIOM_NODE_GET_DATA_ELEMENT (ret_node, env);
+            if (AXIS2_STRCMP
+                (AXIOM_ELEMENT_GET_LOCALNAME (ret_ele, env),
+                 echo_response_buff) != 0)
             {
-                print_invalid_om(env, ret_node);
+               printf ( "%s != %s\n", AXIOM_ELEMENT_GET_LOCALNAME (ret_ele, 
env), echo_response_buff);
+                printf ("\nFAIL\n\n");
                 return AXIS2_FAILURE;
             }
-            ret_node = AXIOM_NODE_GET_FIRST_CHILD(ret_node1, env); 
/*GetTypeResponse*/
-            if (!ret_node)
+
+            ret_node = AXIOM_NODE_GET_FIRST_CHILD (ret_node, env);
+            ret_ele =
+                (axiom_element_t *)
+                AXIOM_NODE_GET_DATA_ELEMENT (ret_node, env);
+            result = AXIOM_ELEMENT_GET_TEXT (ret_ele, env, ret_node);
+            if (!strcmp (word_to_echo, result))
             {
-                print_invalid_om(env, ret_node1);
-                return AXIS2_FAILURE;
+                printf ("\nSUCCESS\n\n");
             }
-            /*see if we have got a fault*/
-       
-       sprintf (echo_response_buff, "echo%sResponse", echo_operation);
-            result_ele = 
(axiom_element_t*)AXIOM_NODE_GET_DATA_ELEMENT(ret_node, env);
-            if (AXIS2_STRCMP(AXIOM_ELEMENT_GET_LOCALNAME(result_ele, env), 
echo_response_buff) != 0 )
+            else
             {
-                print_invalid_om(env, ret_node1);
-                return AXIS2_FAILURE;
+                printf ("\nFAIL\n\n");
             }
-            
-            ret_node1 = AXIOM_NODE_GET_FIRST_CHILD(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);
-            /*printf(AXIOM_ELEMENT_GET_LOCALNAME(result_ele, env)); */
-            result = AXIOM_ELEMENT_GET_TEXT(result_ele, env, ret_node1);
-       if (!strcmp( word_to_echo, result ) )
-       {
-      printf("Success\n");
-       }
-       else
-       {
-      printf("Fail\n" );
-       }
-             
+
         }
         else
         {
-            print_invalid_om(env, ret_node);
+            printf ("\nFAIL\n\n");
             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("test stub invoke failed!\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));
+        printf ("round1 stub invoke FAILED!\n");
+        return AXIS2_FAILURE;
     }
-    
-    return status;
+
+    return AXIS2_SUCCESS;
 }
 
 axiom_node_t *
-build_soap_body_content(const axis2_env_t *env, axis2_char_t *echo_operation,
-                        axis2_char_t *word_to_echo, axiom_node_t *body_node)
+build_soap_body_content (const axis2_env_t *env, axis2_char_t * echo_operation,
+                         axis2_char_t * echo_type,
+                         axis2_char_t * word_to_echo)
 {
-    axiom_node_t* envelope_node = NULL;
-    axiom_element_t* envelope_element = NULL;
-    axiom_element_t* body_om_ele = NULL;
-    
-    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 *ns0 = NULL, *ns1 = NULL, *ns2 = NULL, *ns3 = NULL,
-          *ns4 = NULL, *ns5 = NULL, *ns6 = NULL;
-    
-    axiom_attribute_t* attri1 = NULL;
-
-    axis2_xml_writer_t *xml_writer = NULL;
-    axiom_output_t *om_output = NULL;
-    axis2_char_t *buffer = NULL;
-
-    axis2_char_t echo_operation_buff[32];
-    axis2_char_t input_type_buff[32];
-
-    /*generating the requried parameters*/
-    
 
+    axiom_node_t *operation_om_node = NULL;
+    axiom_element_t *operation_om_ele = NULL;
 
-    sprintf( echo_operation_buff,  "echo%s", echo_operation );
-    sprintf( input_type_buff,  "input%s", echo_operation );
+    axiom_node_t *text_om_node = NULL;
+    axiom_element_t *text_om_ele = NULL;
 
-    ns1 = axiom_namespace_create (env, 
"http://www.w3.org/2001/XMLSchema-instance";, "xsi");
-    ns2 = axiom_namespace_create (env, "http://www.w3.org/2001/XMLSchema";, 
"xsd");
-    ns3 = axiom_namespace_create (env, 
"http://schemas.xmlsoap.org/soap/encoding/","soapenc";);
-    ns4 = axiom_namespace_create (env, "http://soapinterop.org/","tns";);
-    ns5 = axiom_namespace_create (env, 
"http://soapinterop.org/encodedTypes","types";);
-
-    envelope_node = AXIOM_NODE_GET_PARENT(body_node, env);
-    envelope_element = 
(axiom_element_t*)AXIOM_NODE_GET_DATA_ELEMENT(envelope_node, env);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(envelope_element, env, envelope_node, ns1);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(envelope_element, env, envelope_node, ns2);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(envelope_element, env, envelope_node, ns3);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(envelope_element, env, envelope_node, ns4);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(envelope_element, env, envelope_node, ns5);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(envelope_element, env, envelope_node, ns6);
-    ns0 = AXIOM_ELEMENT_GET_NAMESPACE(envelope_element, env, envelope_node);
-    attri1 = axiom_attribute_create (env, "encodingStyle", 
"http://schemas.xmlsoap.org/soap/encoding/";, ns0);
-    
-    body_om_ele = AXIOM_NODE_GET_DATA_ELEMENT( body_node, env );
-    AXIOM_ELEMENT_ADD_ATTRIBUTE(body_om_ele, env, attri1, body_node);
-    
-    echo_om_ele = axiom_element_create(env, body_node, echo_operation_buff, 
ns4, &echo_om_node);
-    AXIOM_ELEMENT_DECLARE_NAMESPACE(echo_om_ele, env, echo_om_node, ns4);
-    
-    text_om_ele = axiom_element_create(env, echo_om_node, input_type_buff, 
NULL, &text_om_node);
-    AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, word_to_echo, text_om_node);
-    
-    xml_writer = axis2_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_attribute_t *attri1 = NULL;
+    axiom_namespace_t *ns0 = NULL, *ns1 = NULL, *ns2 = NULL, *ns3 = NULL,
+        *ns4 = NULL, *ns5 = NULL;
+    axis2_char_t *om_str = NULL;
     
-    AXIOM_NODE_SERIALIZE(echo_om_node, env, om_output);
-    buffer = (axis2_char_t*)AXIS2_XML_WRITER_GET_XML(xml_writer, env);         
-    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s 
\n",  buffer); 
 
-    return echo_om_node;
-}
+    axis2_char_t echo_operation_buff[32];
+    axis2_char_t input_type_buff[32];
 
-void print_invalid_om(const axis2_env_t *env, axiom_node_t *ret_node)
-{
+    /*generating the requried parameters */
+    sprintf (echo_operation_buff, "echo%s", echo_operation);
+    sprintf (input_type_buff, "input%s", echo_operation);
+    
+    ns0 =  axiom_namespace_create (env,
+                   "http://schemas.xmlsoap.org/soap/envelope/";, "soapenv");
+    ns1 = axiom_namespace_create (env, 
+                   "http://www.w3.org/2001/XMLSchema-instance";, "xsi");
+    ns2 = axiom_namespace_create (env, 
+                   "http://www.w3.org/2001/XMLSchema";, "xsd");
+    ns3 = axiom_namespace_create (env, 
+                   "http://schemas.xmlsoap.org/soap/encoding/","soapenc";);
+    ns4 = axiom_namespace_create (env, 
+                   "http://soapinterop.org/","tns";);
+    ns5 = axiom_namespace_create (env,
+                   "http://soapinterop.org/encodedTypes","types";);
+
+    operation_om_ele = axiom_element_create(env, NULL, echo_operation_buff,
+                                              ns4, &operation_om_node);
+   
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns0);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns1);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns2);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns3);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns4);
+    AXIOM_ELEMENT_DECLARE_NAMESPACE (operation_om_ele, env,
+                                          operation_om_node, ns5);
+
+    attri1 =
+        axiom_attribute_create (env, "encodingStyle",
+                                   "http://schemas.xmlsoap.org/soap/encoding/";,
+                                   ns0);
+
+    operation_om_ele = AXIOM_NODE_GET_DATA_ELEMENT (operation_om_node, env);
+    AXIOM_ELEMENT_ADD_ATTRIBUTE (operation_om_ele, env, attri1, 
operation_om_node);
+
+
+    text_om_ele =
+        axiom_element_create (env, operation_om_node, input_type_buff, NULL,
+                                 &text_om_node);
+    AXIOM_ELEMENT_SET_TEXT (text_om_ele, env, word_to_echo, text_om_node);
+
+    om_str = AXIOM_NODE_TO_STRING(operation_om_node, env);
+    if (om_str)
+        printf("\nSending OM : %s\n", om_str);
 
-    axis2_xml_writer_t *writer = NULL;
-    axiom_output_t *om_output = NULL;
-    axis2_char_t *buffer = NULL;
-    writer = axis2_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*)AXIS2_XML_WRITER_GET_XML(writer, env);
-    printf ("\nReceived OM as result : %s\n", buffer);
+    return operation_om_node;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to