You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/12/05 08:10:52 UTC

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

Author: samisa
Date: Mon Dec  4 23:10:51 2006
New Revision: 482532

URL: http://svn.apache.org/viewvc?view=rev&rev=482532
Log:
Addede non-optimized case to the MTOM sample. AXIS2C-442

Modified:
    webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
    webservices/axis2/trunk/c/samples/server/mtom/mtom.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?view=diff&rev=482532&r1=482531&r2=482532
==============================================================================
--- webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c (original)
+++ webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c Mon Dec  4 23:10:51 2006
@@ -23,7 +23,8 @@
 axiom_node_t *
 build_om_programatically(const axis2_env_t *env,
         const axis2_char_t *image_name,
-        const axis2_char_t *to_save_name);
+        const axis2_char_t *to_save_name,
+        axis2_bool_t optimized);
 
 int main(int argc, char** argv)
 {
@@ -38,6 +39,7 @@
     const axis2_char_t *image_name = "resources/axis2.jpg";
     const axis2_char_t *to_save_name = "test.jpg";
     axis2_endpoint_ref_t* reply_to = NULL;
+    axis2_bool_t optimized = AXIS2_TRUE;
 
 
     /* Set up the environment */
@@ -49,7 +51,7 @@
         address = argv[1];
     if (AXIS2_STRCMP(address, "-h") == 0)
     {
-        printf("Usage : %s [endpoint_url] [image_name] [to_save_name]\n", argv[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;
     }
@@ -57,6 +59,8 @@
         image_name = argv[2];
     if (argc > 3)
         to_save_name = argv[3];
+    if (argc > 4)
+        optimized = AXIS2_FALSE;
 
     printf("Using endpoint : %s\n", address);
 
@@ -106,7 +110,7 @@
     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);
+    payload = build_om_programatically(env, image_name, to_save_name, optimized);
 
     /* Send request */
     ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload);
@@ -150,7 +154,8 @@
 axiom_node_t *
 build_om_programatically(const axis2_env_t *env,
         const axis2_char_t *image_name,
-        const axis2_char_t *to_save_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;
@@ -175,6 +180,7 @@
 
     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)
     {

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?view=diff&rev=482532&r1=482531&r2=482532
==============================================================================
--- webservices/axis2/trunk/c/samples/server/mtom/mtom.c (original)
+++ webservices/axis2/trunk/c/samples/server/mtom/mtom.c Mon Dec  4 23:10:51 2006
@@ -90,6 +90,26 @@
                             ret_node = build_om_programatically(env, text_str);
                         }
                     }
+                    else /* attachment has come by value, as non-optimized binary */
+                    {
+                        axiom_text_t *bin_text = (axiom_text_t *)
+                                AXIOM_NODE_GET_DATA_ELEMENT(inc_node, env);
+                        int plain_binary_len = 0;
+                        axis2_byte_t *plain_binary = NULL;
+                        axiom_data_handler_t *data_handler = NULL;
+                        
+                        axis2_char_t *base64text = AXIOM_TEXT_GET_VALUE(bin_text, env);
+                        printf("base64text = %s\n", base64text);
+                        plain_binary_len = axis2_base64_decode_len(base64text);
+                        plain_binary =  AXIS2_MALLOC(env->
+                                    allocator, sizeof(unsigned char) * plain_binary_len);
+                        axis2_base64_decode_binary((unsigned char*)plain_binary,
+                                    base64text);
+                        data_handler = axiom_data_handler_create(env, text_str, NULL);
+                        AXIOM_DATA_HANDLER_SET_BINARY_DATA(data_handler, env, plain_binary, plain_binary_len);
+                        AXIOM_DATA_HANDLER_WRITE_TO(data_handler, env);
+                        ret_node = build_om_programatically(env, text_str);
+                    }
                 }
             }
 



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