Author: samisa
Date: Wed May  3 21:57:51 2006
New Revision: 399550

URL: http://svn.apache.org/viewcvs?rev=399550&view=rev
Log:
Updated to sepereate common logic

Added:
    webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.c
    webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.h
Modified:
    webservices/axis2/trunk/c/samples/user_guide/clients/Makefile.am
    webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c

Modified: webservices/axis2/trunk/c/samples/user_guide/clients/Makefile.am
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/user_guide/clients/Makefile.am?rev=399550&r1=399549&r2=399550&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/Makefile.am (original)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/Makefile.am Wed May  3 
21:57:51 2006
@@ -1,8 +1,8 @@
 prgbindir=$(prefix)/bin/samples
 prgbin_PROGRAMS = echo_blocking
 samplesdir=$(prefix)/samples/user_guide/clients
-samples_DATA=echo_blocking.c Makefile.am Makefile.in
-echo_blocking_SOURCES = echo_blocking.c
+samples_DATA=echo_util.h echo_util.c echo_blocking.c Makefile.am Makefile.in
+echo_blocking_SOURCES = echo_blocking.c echo_util.c
 echo_blocking_LDADD   = $(LDFLAGS) \
                     -L$(AXIS2C_HOME)/lib \
                                        -laxis2_util \

Modified: webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c?rev=399550&r1=399549&r2=399550&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c 
(original)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c Wed 
May  3 21:57:51 2006
@@ -14,18 +14,11 @@
  * limitations under the License.
  */
 
-#include <stdio.h>
+#include "echo_util.h"
 #include <axis2_util.h>
-#include <axis2_om.h>
 #include <axis2_soap.h>
 #include <axis2_client.h>
 
-axis2_om_node_t *
-build_om_payload(axis2_env_t **env);
-
-void 
-print_om(axis2_env_t **env, axis2_om_node_t *node);
-
 int main(int argc, char** argv)
 {
     axis2_env_t *env = NULL;
@@ -84,15 +77,17 @@
     AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, &env, options);    
 
     /* Build the SOAP request message payload using OM API.*/
-    payload = build_om_payload(&env);
+    payload = build_om_payload_for_echo_svc(&env);
     
     /* Send request */
     ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, &env, payload);
     
     if(ret_node)
     {
-        printf("\nReceived OM : ");
-        print_om(&env, ret_node);
+        axis2_char_t *om_str = NULL;
+        om_str = AXIS2_OM_NODE_TO_STRING(ret_node, &env);
+        if (om_str)
+            printf("\nReceived OM : %s\n", om_str);
         printf("\necho client invoke SUCCESSFUL!\n");
     }
     else
@@ -114,42 +109,4 @@
         endpoint_ref = NULL;
     }
     return 0;
-}
-
-/* build SOAP request message content using OM */
-axis2_om_node_t *
-build_om_payload(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;
-    
-    ns1 = axis2_om_namespace_create (env, 
"http://ws.apache.org/axis2/c/samples";, "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);
-    
-    printf("\nSending OM : ");
-    print_om(env, echo_om_node);
-
-    return echo_om_node;
-}
-
-void print_om(axis2_env_t **env, axis2_om_node_t *node)
-{
-    axis2_xml_writer_t *xml_writer = NULL;
-    axis2_om_output_t *om_output = NULL;
-    axis2_char_t *buffer = NULL;
-
-    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(node, env, om_output);
-    buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);         
-    printf("%s\n",  buffer); 
-    AXIS2_FREE((*env)->allocator, buffer);
-    AXIS2_OM_OUTPUT_FREE(om_output, env);
-    return;
 }

Added: webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.c
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.c?rev=399550&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.c (added)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.c Wed May  3 
21:57:51 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "echo_util.h"
+
+/* build SOAP request message content using OM */
+axis2_om_node_t *
+build_om_payload_for_echo_svc(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_char_t *om_str = NULL;
+    
+    ns1 = axis2_om_namespace_create (env, 
"http://ws.apache.org/axis2/c/samples";, "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);
+    
+    om_str = AXIS2_OM_NODE_TO_STRING(echo_om_node, env);
+    if (om_str)
+        printf("\nSending OM : %s\n", om_str);
+
+    return echo_om_node;
+}

Added: webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.h
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.h?rev=399550&view=auto
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.h (added)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/echo_util.h Wed May  3 
21:57:51 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_UG_ECHO_UTIL_H
+#define AXIS2_UG_ECHO_UTIL_H
+
+#include <stdio.h>
+#include <axis2_om.h>
+
+axis2_om_node_t *
+build_om_payload_for_echo_svc(axis2_env_t **env);
+
+#endif


Reply via email to