You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2007/11/02 08:15:36 UTC

svn commit: r591247 - in /webservices/axis2/trunk/c/samples: client/mtom/mtom_client.c server/mtom/mtom.c server/mtom/mtom.h server/mtom/mtom_skeleton.c

Author: nandika
Date: Fri Nov  2 00:15:36 2007
New Revision: 591247

URL: http://svn.apache.org/viewvc?rev=591247&view=rev
Log:
mtom sample modified to send back the received content

Modified:
    webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
    webservices/axis2/trunk/c/samples/server/mtom/mtom.c
    webservices/axis2/trunk/c/samples/server/mtom/mtom.h
    webservices/axis2/trunk/c/samples/server/mtom/mtom_skeleton.c

Modified: webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c?rev=591247&r1=591246&r2=591247&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c (original)
+++ webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c Fri Nov  2 00:15:36 2007
@@ -28,6 +28,13 @@
     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,
@@ -128,6 +135,9 @@
             AXIS2_FREE(env->allocator, om_str);
         }
         printf("\nmtom client invoke SUCCESSFUL!\n");
+
+        process_response_node(env, ret_node, to_save_name);
+    
     }
     else
     {
@@ -201,3 +211,32 @@
     }
     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, to_save_name);
+        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;
+}
+
+

Modified: webservices/axis2/trunk/c/samples/server/mtom/mtom.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/mtom/mtom.c?rev=591247&r1=591246&r2=591247&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/mtom/mtom.c (original)
+++ webservices/axis2/trunk/c/samples/server/mtom/mtom.c Fri Nov  2 00:15:36 2007
@@ -19,14 +19,19 @@
 #include <axiom.h>
 #include <stdio.h>
 
-axiom_node_t *build_om_programatically(
+axiom_node_t *build_response1(
     const axutil_env_t * env,
     axis2_char_t * text);
 
-axiom_node_t *
+axiom_node_t *build_response2(
+    const axutil_env_t *env,
+    axiom_data_handler_t *data_handler);
+
+axiom_node_t*
 axis2_mtom_mtom(
     const axutil_env_t * env,
-    axiom_node_t * node)
+    axiom_node_t * node,
+    axis2_msg_ctx_t *msg_ctx)
 {
     axiom_node_t *file_name_node = NULL;
     axiom_node_t *file_text_node = NULL;
@@ -98,10 +103,28 @@
                     data_handler = axiom_text_get_data_handler(bin_text, env);
                     if (data_handler)
                     {
+                        axiom_data_handler_t *data_handler_res = NULL;
+                        axis2_byte_t *input_buff = NULL;
+                        axis2_byte_t *buff = NULL;
+                        int buff_len = 0;
+
+
                         axiom_data_handler_set_file_name(data_handler, env,
                                                          text_str);
                         axiom_data_handler_write_to(data_handler, env);
-                        ret_node = build_om_programatically(env, text_str);
+                        
+                        input_buff = axiom_data_handler_get_input_stream(data_handler, env);
+                        buff_len = axiom_data_handler_get_input_stream_len(data_handler, env);
+                        
+                        data_handler_res = axiom_data_handler_create(env, NULL, NULL);
+                        
+                        buff = AXIS2_MALLOC(env->allocator, sizeof(axis2_byte_t)*buff_len);
+                        memcpy(buff, input_buff, buff_len);
+
+                        axiom_data_handler_set_binary_data(data_handler_res, env, buff, buff_len);
+
+                        axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE);
+                        ret_node = build_response2(env, data_handler_res);
                     }
                     else        /* attachment has come by value, as non-optimized binary */
                     {
@@ -131,7 +154,7 @@
                                                            plain_binary,
                                                            ret_len);
                         axiom_data_handler_write_to(data_handler, env);
-                        ret_node = build_om_programatically(env, text_str);
+                        ret_node = build_response1(env, base64text);
                     }
                     /* } */
                 }
@@ -153,12 +176,16 @@
 
 /* Builds the response content */
 axiom_node_t *
-build_om_programatically(
+build_response1(
     const axutil_env_t * env,
     axis2_char_t * text)
 {
     axiom_node_t *mtom_om_node = NULL;
     axiom_element_t *mtom_om_ele = NULL;
+    axiom_node_t *om_node = NULL;
+    axiom_element_t *om_ele = NULL;
+
+   
     axiom_namespace_t *ns1 = NULL;
 
     ns1 =
@@ -168,7 +195,35 @@
     mtom_om_ele =
         axiom_element_create(env, NULL, "response", ns1, &mtom_om_node);
 
-    axiom_element_set_text(mtom_om_ele, env, "Image Saved", mtom_om_node);
+    om_ele  = axiom_element_create(env, mtom_om_node, "string", NULL, &om_node);
+    
+    axiom_element_set_text(mtom_om_ele, env, text, om_node);
+   
+
+    return mtom_om_node;
+}
+
+
+axiom_node_t *build_response2(
+    const axutil_env_t *env,
+    axiom_data_handler_t *data_handler)
+{
+    axiom_node_t *mtom_om_node = NULL;
+    axiom_element_t *mtom_om_ele = NULL;
+    axiom_node_t *text_node = NULL;
+    axiom_namespace_t *ns1 = NULL;
+
+    ns1 =
+        axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples",
+                               "ns1");
+    mtom_om_ele =
+        axiom_element_create(env, NULL, "response", ns1, &mtom_om_node);
+
+    axiom_text_create_with_data_handler(env, mtom_om_node, data_handler,
+        &text_node);
 
     return mtom_om_node;
 }
+
+
+

Modified: webservices/axis2/trunk/c/samples/server/mtom/mtom.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/mtom/mtom.h?rev=591247&r1=591246&r2=591247&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/mtom/mtom.h (original)
+++ webservices/axis2/trunk/c/samples/server/mtom/mtom.h Fri Nov  2 00:15:36 2007
@@ -27,6 +27,7 @@
 
 axiom_node_t *axis2_mtom_mtom(
     const axutil_env_t * env,
-    axiom_node_t * node);
+    axiom_node_t * node,
+    axis2_msg_ctx_t *msg_ctx);
 
 #endif                          /* CALC_H */

Modified: webservices/axis2/trunk/c/samples/server/mtom/mtom_skeleton.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/mtom/mtom_skeleton.c?rev=591247&r1=591246&r2=591247&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/mtom/mtom_skeleton.c (original)
+++ webservices/axis2/trunk/c/samples/server/mtom/mtom_skeleton.c Fri Nov  2 00:15:36 2007
@@ -90,7 +90,7 @@
      * To see how to deal with multiple impl methods, have a look at the
      * math sample.
      */
-    return axis2_mtom_mtom(env, node);
+    return axis2_mtom_mtom(env, node, msg_ctx);
 }
 
 /* On fault, handle the fault */



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org