Author: damitha
Date: Sat Jan  5 01:27:27 2008
New Revision: 609111

URL: http://svn.apache.org/viewvc?rev=609111&view=rev
Log:

updating mtom server and client sample

Modified:
    webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.c
    webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.h
    webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc_skel.c
    webservices/sandesha/trunk/c/samples/rm_echo_1_0/rm_echo.c
    webservices/sandesha/trunk/c/samples/rm_echo_single_1_0/rm_echo_single.c
    webservices/sandesha/trunk/c/samples/rm_mtom_1_0/rm_mtom_1_0.c

Modified: webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.c?rev=609111&r1=609110&r2=609111&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.c 
(original)
+++ webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.c Sat 
Jan  5 01:27:27 2008
@@ -20,14 +20,16 @@
 #include <axiom_output.h>
 #include <axiom_element.h>
 
-axiom_node_t *
-build_echo_om(
-    const axutil_env_t *env, 
-    const axis2_char_t *text);
+axiom_node_t *build_response1(
+    const axutil_env_t * env,
+    axis2_char_t * text);
+
+axiom_node_t *build_response2(
+    const axutil_env_t *env,
+    axiom_data_handler_t *data_handler);
 
-/* Builds the response content */
 axiom_node_t *
-build_mtom_om(
+build_echo_om(
     const axutil_env_t *env, 
     const axis2_char_t *text);
 
@@ -210,7 +212,8 @@
 axiom_node_t *
 rm_sample_svc_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;
@@ -220,63 +223,130 @@
 
     /* Expected request format is :-
      * <ns1:mtomSample xmlns:ns1="http://ws.apache.org/axis2/c/samples";>
-            <ns1:fileName>test.jpg</ns1:fileName>
-            <ns1:image>
-                 <xop:Include 
xmlns:xop="http://www.w3.org/2004/08/xop/include"; 
href="cid:[email protected]"></xop:Include>
-            </ns1:image>
-        </ns1:mtomSample>
+     <ns1:fileName>test.jpg</ns1:fileName>
+     <ns1:image>
+     <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"; 
href="cid:[email protected]"></xop:Include>
+     </ns1:image>
+     </ns1:mtomSample>
      */
-    if (!node) /* 'mtomSample' node */
+    if (!node)                  /* 'mtomSample' node */
     {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, 
AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL,
+                        AXIS2_FAILURE);
+        printf("Echo client ERROR: input parameter NULL\n");
         return NULL;
     }
 
     file_name_node = axiom_node_get_first_child(node, env);
-    if (!file_name_node) /* 'text' node */
+    if (!file_name_node)        /* 'text' node */
     {
-        AXIS2_ERROR_SET(env->error, 
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error,
+                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
+                        AXIS2_FAILURE);
+        printf("Echo client ERROR: invalid XML in request\n");
         return NULL;
     }
 
     file_text_node = axiom_node_get_first_child(file_name_node, env);
-    if (!file_text_node) /* actual text to mtom */
+    if (!file_text_node)        /* actual text to mtom */
     {
-        AXIS2_ERROR_SET(env->error, 
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error,
+                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
+                        AXIS2_FAILURE);
+        printf("Echo client ERROR: invalid XML in request\n");
         return NULL;
     }
 
     if (axiom_node_get_node_type(file_text_node, env) == AXIOM_TEXT)
     {
-        axiom_text_t *text = (axiom_text_t 
*)axiom_node_get_data_element(file_text_node, env);
-        if (text && axiom_text_get_value(text , env))
+        axiom_text_t *text =
+            (axiom_text_t *) axiom_node_get_data_element(file_text_node, env);
+        if (text && axiom_text_get_value(text, env))
         {
             axiom_node_t *image_node = NULL;
-            const axis2_char_t *text_str = axiom_text_get_value(text, env);
+            axis2_char_t *text_str =
+                (axis2_char_t *) axiom_text_get_value(text, env);
+            printf("File Name  %s \n", text_str);
 
             image_node = axiom_node_get_next_sibling(file_name_node, env);
             if (image_node)
             {
-                axiom_node_t *inc_node = NULL;
-                inc_node = axiom_node_get_first_child(image_node, env);
-                if (inc_node)
+                /* axiom_node_t *inc_node = NULL;
+                   inc_node = axiom_node_get_first_child(image_node, env);
+                   if (inc_node)
+                   { */
+                axiom_node_t *binary_node = NULL;
+                binary_node = axiom_node_get_first_child(image_node, env);
+                if (binary_node)
                 {
-                    axiom_node_t *binary_node = NULL;
-                    binary_node = axiom_node_get_first_child(inc_node, env);
-                    if (binary_node)
+                    axiom_data_handler_t *data_handler = NULL;
+                    axiom_text_t *bin_text = (axiom_text_t *)
+                        axiom_node_get_data_element(binary_node, env);
+                    data_handler = axiom_text_get_data_handler(bin_text, env);
+                    if (data_handler)
                     {
-                        axiom_data_handler_t *data_handler = NULL;
+                        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);
+                        
+                        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 if (axiom_node_get_node_type(binary_node, env) == 
AXIOM_TEXT) /* attachment has come by value, as non-optimized binary */
+                    {
+                        int plain_binary_len = 0;
+                        int ret_len = 0;
                         axiom_text_t *bin_text = (axiom_text_t *)
-                                axiom_node_get_data_element(binary_node, env);
-                        data_handler = axiom_text_get_data_handler(bin_text, 
env);
-                        if (data_handler)
-                        {
-                            axiom_data_handler_set_file_name(data_handler, 
env, 
-                                (axis2_char_t *) text_str);
-                            axiom_data_handler_write_to(data_handler, env);
-                            ret_node = build_mtom_om(env, text_str);
-                        }
+                            axiom_node_get_data_element(binary_node, env);
+                        axis2_byte_t *plain_binary = NULL;
+                        axiom_data_handler_t *data_handler = NULL;
+
+                        axis2_char_t *base64text =
+                            (axis2_char_t *) axiom_text_get_value(bin_text,
+                                                                  env);
+                        printf("base64text = %s\n", base64text);
+                        plain_binary_len = 
axutil_base64_decode_len(base64text);
+                        plain_binary = AXIS2_MALLOC(env->
+                                                    allocator,
+                                                    sizeof(unsigned char) *
+                                                    plain_binary_len);
+                        ret_len =
+                            axutil_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,
+                                                           ret_len);
+                        axiom_data_handler_write_to(data_handler, env);
+                        ret_node = build_response1(env, base64text);
+                    }
+                    else /* nothing came */
+                    {
+                        AXIS2_ERROR_SET(env->error,
+                            AXIS2_ERROR_ATTACHMENT_MISSING,
+                            AXIS2_FAILURE);
+                        printf("Echo client ERROR: attachment is missing.\n");
+                        return NULL;
                     }
+                    /* } */
                 }
             }
 
@@ -284,30 +354,61 @@
     }
     else
     {
-        AXIS2_ERROR_SET(env->error, 
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error,
+                        AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
+                        AXIS2_FAILURE);
+        printf("Echo client ERROR: invalid XML in request\n");
         return NULL;
     }
-
     return ret_node;
 }
 
-/* Builds the response content */
 axiom_node_t *
-build_mtom_om(
-    const axutil_env_t *env, 
-    const axis2_char_t *text)
+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_element_t *mtom_om_ele = NULL;
+    axiom_node_t *om_node = NULL;
+    axiom_element_t *om_ele = NULL;
+
+   
     axiom_namespace_t *ns1 = NULL;
 
-    ns1 = axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples";, 
"ns1");
+    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);
+    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/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.h
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.h?rev=609111&r1=609110&r2=609111&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.h 
(original)
+++ webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc.h Sat 
Jan  5 01:27:27 2008
@@ -37,6 +37,7 @@
 axiom_node_t *
 rm_sample_svc_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/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc_skel.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc_skel.c?rev=609111&r1=609110&r2=609111&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc_skel.c 
(original)
+++ webservices/sandesha/trunk/c/samples/RMSampleService/rm_sample_svc_skel.c 
Sat Jan  5 01:27:27 2008
@@ -122,7 +122,7 @@
                 return NULL;
             }
             if (axutil_strcmp(op_name, "mtomSample") == 0)
-                return rm_sample_svc_mtom(env, node);
+                return rm_sample_svc_mtom(env, node, msg_ctx);
         }
     }
     return NULL;

Modified: webservices/sandesha/trunk/c/samples/rm_echo_1_0/rm_echo.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo_1_0/rm_echo.c?rev=609111&r1=609110&r2=609111&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo_1_0/rm_echo.c (original)
+++ webservices/sandesha/trunk/c/samples/rm_echo_1_0/rm_echo.c Sat Jan  5 
01:27:27 2008
@@ -21,7 +21,6 @@
 #include <axis2_svc_ctx.h>
 #include <axis2_conf_ctx.h>
 #include <axis2_op_client.h>
-#include <axis2_listener_manager.h>
 #include <axis2_callback_recv.h>
 #include <axis2_svc_client.h>
 #include <sandesha2_client_constants.h>
@@ -66,7 +65,6 @@
     axis2_callback_t *callback1 = NULL;
     axis2_callback_t *callback2 = NULL;
     axutil_property_t *property = NULL;
-    axis2_listener_manager_t *listener_manager = NULL;
     axutil_string_t *soap_action = NULL;
     axis2_char_t *seq_key = NULL;
     int c;
@@ -161,11 +159,6 @@
     axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);  
     axis2_svc_client_engage_module(svc_client, env, "sandesha2");
 
-    listener_manager = axis2_listener_manager_create(env);
-    if (!listener_manager)
-    {
-        return AXIS2_FAILURE;
-    }
     seq_key = axutil_uuid_gen(env);
     property = axutil_property_create_with_args(env, 0, 0, 0, seq_key);
     if(property)

Modified: 
webservices/sandesha/trunk/c/samples/rm_echo_single_1_0/rm_echo_single.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo_single_1_0/rm_echo_single.c?rev=609111&r1=609110&r2=609111&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo_single_1_0/rm_echo_single.c 
(original)
+++ webservices/sandesha/trunk/c/samples/rm_echo_single_1_0/rm_echo_single.c 
Sat Jan  5 01:27:27 2008
@@ -155,7 +155,7 @@
         axis2_options_set_property(options, env, 
             SANDESHA2_CLIENT_OFFERED_SEQ_ID, property);
     }
-    /* RM Version 1.1 */
+    /* RM Version 1.0 */
     property = axutil_property_create_with_args(env, 3, 0, 0, 
         SANDESHA2_SPEC_VERSION_1_0);
     if(property)

Modified: webservices/sandesha/trunk/c/samples/rm_mtom_1_0/rm_mtom_1_0.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_mtom_1_0/rm_mtom_1_0.c?rev=609111&r1=609110&r2=609111&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_mtom_1_0/rm_mtom_1_0.c (original)
+++ webservices/sandesha/trunk/c/samples/rm_mtom_1_0/rm_mtom_1_0.c Sat Jan  5 
01:27:27 2008
@@ -29,11 +29,17 @@
 #include <sandesha2_client_constants.h>
 #include <ctype.h>
 
-#define SANDESHA2_MAX_COUNT 4
+#define SANDESHA2_MAX_COUNT 8
 void 
 usage(
     axis2_char_t *prog_name);
 
+axiom_node_t *build_om_programatically(
+    const axutil_env_t * env,
+    const axis2_char_t * image_name,
+    const axis2_char_t * to_save_name,
+    axis2_bool_t optimized);
+
 int main(int argc, char** argv)
 {
     const axutil_env_t *env = NULL;
@@ -41,26 +47,25 @@
     axis2_endpoint_ref_t* endpoint_ref = NULL;
     axis2_options_t *options = NULL;
     const axis2_char_t *client_home = NULL;
-    axis2_svc_ctx_t *svc_ctx = NULL;
-    axis2_conf_ctx_t *conf_ctx = NULL;
     axis2_svc_client_t* svc_client = NULL;
     axiom_node_t *payload = NULL;
     axutil_property_t *property = NULL;
-    axis2_char_t *offered_seq_id = NULL;
     axiom_node_t *result = NULL;
+    axutil_string_t *soap_action = NULL;
     int c;
     const axis2_char_t *image_name = "../resources/axis2.jpg";
+    axis2_char_t *seq_key = NULL;
+    axis2_bool_t optimized = AXIS2_TRUE;
+    axis2_char_t *offered_seq_id = NULL;
    
     /* Set up the environment */
     env = axutil_env_create_all("rm_mtom_1_0.log", 
-            AXIS2_LOG_LEVEL_TRACE);
+        AXIS2_LOG_LEVEL_TRACE);
 
     /* Set end point reference of echo service */
-    /*address = "http://127.0.0.1:9090/axis2/services/RMSampleService";*/
     address = "http://127.0.0.1:9090/axis2/services/RMSampleService";;
     while ((c = AXIS2_GETOPT(argc, argv, ":a:")) != -1)
     {
-
         switch (c)
         {
             case 'a':
@@ -92,9 +97,10 @@
     options = axis2_options_create(env);
     axis2_options_set_to(options, env, endpoint_ref);
     axis2_options_set_enable_mtom(options, env, AXIS2_TRUE); 
-    /* Seperate listner needs addressing, hence addressing stuff in options */
-    /*axis2_options_set_action(options, env,
-        "http://127.0.0.1:8080/axis2/services/RMSampleService/anonOutInOp";);*/
+
+    soap_action = axutil_string_create(env, "urn:wsrm:EchoString");
+    axis2_options_set_soap_action(options, env, soap_action);
+    axis2_options_set_action(options, env, "urn:wsrm:EchoString");
 
     /* Set up deploy folder. It is from the deploy folder, the configuration 
is 
      * picked up using the axis2.xml file.
@@ -127,10 +133,14 @@
 
     /* Offer sequence */
     offered_seq_id = axutil_uuid_gen(env);
-    property = axutil_property_create_with_args(env, 0, 0, 0, offered_seq_id);
+    property = axutil_property_create(env);
     if(property)
-        axis2_options_set_property(options, env, 
SANDESHA2_CLIENT_OFFERED_SEQ_ID,
-            property);
+    {
+        axutil_property_set_value(property, env, axutil_strdup(env, 
+            offered_seq_id));
+        axis2_options_set_property(options, env, 
+            SANDESHA2_CLIENT_OFFERED_SEQ_ID, property);
+    }
     property = axutil_property_create_with_args(env, 3, 0, 0, 
         SANDESHA2_SPEC_VERSION_1_0);
     if(property)
@@ -138,56 +148,14 @@
         axis2_options_set_property(options, env, 
             SANDESHA2_CLIENT_RM_SPEC_VERSION, property);
     }
-    svc_ctx = axis2_svc_client_get_svc_ctx(svc_client, env);
-    conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
-    property = axutil_property_create_with_args(env, 0, 0, 0, "4");
-    
-    if(property)
-    {
-        axis2_options_set_property(options, env, AXIS2_TIMEOUT_IN_SECONDS, 
-            property);
-    }
-    /*payload = build_om_payload_for_mtom(env, image_name, "test1.jpg");
-    result = axis2_svc_client_send_receive(svc_client, env, payload);
-    if(result)
-    {
-        axis2_char_t *om_str = NULL;
-        om_str = axiom_node_to_string(result, env);
-        if (om_str)
-            printf("\nReceived OM : %s\n", om_str);
-        printf("\necho client two way single channel invoke SUCCESSFUL!\n");
-
-        AXIS2_FREE(env->allocator, om_str);
-        result = NULL;
-    }
-    else
-    {
-        printf("\necho client two way single channel invoke FAILED!\n");
-    }
 
-    property = axutil_property_create_with_args(env, 0, 0, 0, "4");
+    seq_key = axutil_uuid_gen(env);
+    property = axutil_property_create_with_args(env, 0, 0, 0, seq_key);
     if(property)
     {
-        axis2_options_set_property(options, env, AXIS2_TIMEOUT_IN_SECONDS, 
+        axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY,
             property);
     }
-    payload = build_om_payload_for_mtom(env, image_name, "test2.jpg");
-    result = axis2_svc_client_send_receive(svc_client, env, payload);
-    if(result)
-    {
-        axis2_char_t *om_str = NULL;
-        om_str = axiom_node_to_string(result, env);
-        if (om_str)
-            printf("\nReceived OM : %s\n", om_str);
-        printf("\necho client two way single channel invoke SUCCESSFUL!\n");
-
-        AXIS2_FREE(env->allocator, om_str);
-        result = NULL;
-    }
-    else
-    {
-        printf("\necho client two way single channel invoke FAILED!\n");
-    }*/
 
     property = axutil_property_create_with_args(env, 0, 0, 0, "12");
     if(property)
@@ -195,7 +163,7 @@
         axis2_options_set_property(options, env, AXIS2_TIMEOUT_IN_SECONDS, 
             property);
     }
-    payload = build_om_payload_for_mtom(env, image_name, "test3.jpg");
+    payload = build_om_programatically(env, image_name, "test3.jpg", 
optimized);
     property = axutil_property_create_with_args(env, 0, 0, 0, 
AXIS2_VALUE_TRUE);
     axis2_options_set_property(options, env, "Sandesha2LastMessage", 
         property);
@@ -216,14 +184,62 @@
         printf("\necho client two way single channel invoke FAILED!\n");
     }
 
-    AXIS2_SLEEP(2 * SANDESHA2_MAX_COUNT); 
+    AXIS2_SLEEP(SANDESHA2_MAX_COUNT); 
     if (svc_client)
     {
-        /*axis2_svc_client_free(svc_client, env);*/
+        axis2_svc_client_free(svc_client, env);
         svc_client = NULL;
     }
     
     return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+    const axutil_env_t * env,
+    const axis2_char_t * image_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;
+    axiom_node_t *image_om_node = NULL;
+    axiom_element_t *image_om_ele = NULL;
+    axiom_node_t *file_om_node = NULL;
+    axiom_element_t *file_om_ele = NULL;
+    axiom_node_t *data_om_node = NULL;
+    axiom_text_t *data_text = NULL;
+    axiom_namespace_t *ns1 = NULL;
+    axis2_char_t *om_str = NULL;
+
+    axiom_data_handler_t *data_handler = NULL;
+
+    ns1 =
+        axiom_namespace_create(env, 
"http://ws.apache.org/axis2/c/samples/mtom";,
+                               "ns1");
+    mtom_om_ele =
+        axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);
+
+    file_om_ele =
+        axiom_element_create(env, mtom_om_node, "fileName", ns1, 
&file_om_node);
+    axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node);
+
+    image_om_ele =
+        axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node);
+
+    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)
+    {
+        printf("%s", om_str);
+        AXIS2_FREE(env->allocator, om_str);
+    }
+    return mtom_om_node;
 }
 
 void 



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

Reply via email to