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 sa...@apache.org on 2006/07/14 15:46:58 UTC

svn commit: r421907 - in /webservices/axis2/trunk/c: axiom/src/attachments/ include/ modules/core/transport/http/ modules/core/transport/http/receiver/ modules/core/transport/http/sender/

Author: samisa
Date: Fri Jul 14 06:46:58 2006
New Revision: 421907

URL: http://svn.apache.org/viewvc?rev=421907&view=rev
Log:
Fixes to get MTOM working from server to client

Modified:
    webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
    webservices/axis2/trunk/c/include/axis2_op_client.h
    webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c

Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c?rev=421907&r1=421906&r2=421907&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c Fri Jul 14 06:46:58 2006
@@ -17,6 +17,7 @@
 #include <axiom_mime_parser.h>
 #include <axis2_string.h>
 #include <axiom_data_handler.h>
+#include <stdio.h>
 
 typedef struct axiom_mime_parser_impl
 {
@@ -431,6 +432,16 @@
                         }
                     }
                 }
+            }
+            else
+            {
+                axis2_char_t temp_boundry[1024];
+                sprintf(temp_boundry, "%s", "--");
+                sprintf(temp_boundry, "%s", mime_boundary);
+                sprintf(temp_boundry, "%s", "--");
+                if (AXIS2_STRSTR(body_mime, temp_boundry))
+                    break;
+                
             }
             
             body_mime = temp_body_mime;

Modified: webservices/axis2/trunk/c/include/axis2_op_client.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_op_client.h?rev=421907&r1=421906&r2=421907&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_op_client.h (original)
+++ webservices/axis2/trunk/c/include/axis2_op_client.h Fri Jul 14 06:46:58 2006
@@ -43,7 +43,6 @@
 
 /**
  * @file axis2_op_client.h
- * @brief axis2 operation client interface
  */
 
 #include <axis2_defines.h>

Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c?rev=421907&r1=421906&r2=421907&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c Fri Jul 14 06:46:58 2006
@@ -540,9 +540,9 @@
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);    
 
     param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, env, AXIS2_ENABLE_MTOM);
-    /*if(NULL != param)
+    if(NULL != param)
         value = AXIS2_PARAM_GET_VALUE(param, env);
-    */
+    
     property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env,
         AXIS2_ENABLE_MTOM, AXIS2_FALSE);
     if(NULL != property)
@@ -936,6 +936,8 @@
     axis2_char_t *trans_enc = NULL;
     int *content_length = NULL;
     axis2_property_t *property = NULL;
+    axis2_hash_t *binary_data_map = NULL;
+
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
     AXIS2_PARAM_CHECK(env->error, soap_ns_uri, NULL);
@@ -1028,11 +1030,47 @@
     if(NULL != content_type)
     {
         AXIS2_MSG_CTX_SET_DOING_MTOM(msg_ctx, env, AXIS2_TRUE);
+        /* get mime boundry */
+        axis2_char_t *mime_boundary = 
+            axis2_http_transport_utils_get_value_from_content_type(env, 
+                content_type, AXIS2_HTTP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);
+
+        if (mime_boundary)
+        {
+            axiom_mime_parser_t *mime_parser = NULL;
+            axis2_stream_t *stream = NULL;
+            int soap_body_len = 0;
+            axis2_char_t* soap_body_str = NULL;
+            
+            mime_parser = axiom_mime_parser_create(env);
+            if (mime_parser)
+            {
+                binary_data_map = AXIOM_MIME_PARSER_PARSE(mime_parser, env, 
+                    axis2_http_transport_utils_on_data_request, 
+                    (void*)callback_ctx, mime_boundary);
+                
+                soap_body_len = AXIOM_MIME_PARSER_GET_SOAP_BODY_LENGTH(
+                    mime_parser, env);
+                soap_body_str = AXIOM_MIME_PARSER_GET_SOAP_BODY_STR(
+                    mime_parser, env);
+            }
+            
+            stream = axis2_stream_create_basic(env);
+            if (stream)
+            {
+                AXIS2_STREAM_WRITE(stream, env, soap_body_str, soap_body_len);
+                callback_ctx->in_stream = stream;
+                callback_ctx->chunked_stream = NULL;
+                callback_ctx->content_length = soap_body_len;
+                callback_ctx->unread_len = soap_body_len;
+            }
+        }
         /**
          * TODO MTOM stuff - create builder and get envelope
          */
     }
-    else if(AXIS2_TRUE != AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env))
+    
+    if(AXIS2_TRUE != AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env))
     {
         axiom_xml_reader_t *xml_reader = NULL;
         axiom_stax_builder_t *om_builder = NULL;
@@ -1064,6 +1102,13 @@
             xml_reader = NULL;
             return NULL;
         }
+        
+        if (binary_data_map)
+        {
+            AXIOM_SOAP_BUILDER_SET_MIME_BODY_PARTS(soap_builder, env, 
+                binary_data_map);
+        }
+        
         soap_envelope = AXIOM_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder, env);
         return soap_envelope;
     }
@@ -1096,6 +1141,7 @@
         om_doc = AXIOM_STAX_BUILDER_GET_DOCUMENT(om_builder, env);
         root_node = AXIOM_DOCUMENT_BUILD_ALL(om_doc, env);
         AXIOM_SOAP_BODY_ADD_CHILD(def_body, env, root_node);
+
         return soap_envelope;
     }
     return NULL;

Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c?rev=421907&r1=421906&r2=421907&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c Fri Jul 14 06:46:58 2006
@@ -466,9 +466,11 @@
             write_stat = AXIS2_HTTP_RESPONSE_WRITER_PRINTLN_STR(response_writer, 
                   env, response_body);
       else
+      {
             write_stat = AXIS2_HTTP_RESPONSE_WRITER_WRITE_BUF(response_writer,
                   env, response_body, 0, body_size);
-
+      }
+      
       if(AXIS2_SUCCESS != write_stat)
       {
          AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRITING_RESPONSE, 

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c?rev=421907&r1=421906&r2=421907&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c Fri Jul 14 06:46:58 2006
@@ -162,6 +162,11 @@
     axis2_bool_t do_mtom;
     axis2_property_t *property = NULL;
     axiom_node_t *data_out = NULL;
+    axis2_byte_t *output_stream = NULL;
+    int buffer_size = 0;
+
+    
+
    
    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
@@ -203,6 +208,7 @@
    do_mtom = axis2_http_transport_utils_do_write_mtom(env,
                      msg_ctx);
    AXIS2_MSG_CTX_SET_DOING_MTOM(msg_ctx, env, do_mtom);
+   /*do_mtom = AXIS2_MSG_CTX_GET_DOING_MTOM(msg_ctx, env);*/
    /*AXIS2_MSG_CTX_SET_DOING_REST(msg_ctx, 
                      env, axis2_http_transport_utils_is_doing_rest(env, 
                      msg_ctx));*/
@@ -368,11 +374,29 @@
             }
             else
             {
+                AXIOM_OUTPUT_SET_DO_OPTIMIZE(om_output, env,
+                               do_mtom);
                 AXIOM_SOAP_ENVELOPE_SERIALIZE (soap_data_out, env, om_output, 
                             AXIS2_FALSE);
-                buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env);
+                if (do_mtom)
+                {
+                    axis2_char_t *content_type = NULL;
+                    AXIOM_OUTPUT_FLUSH(om_output, env, &output_stream,
+                                    &buffer_size);
+                    content_type = (axis2_char_t *)AXIOM_OUTPUT_GET_CONTENT_TYPE(
+                            om_output,
+                            env);
+                    AXIS2_HTTP_OUT_TRANSPORT_INFO_SET_CONTENT_TYPE(out_info, 
+                        env, content_type);
+                    buffer = output_stream;
+                }
+                else
+                {
+                    buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env);
+                    buffer_size = AXIS2_STRLEN(buffer);
+                }
             }
-         AXIS2_STREAM_WRITE(out_stream, env, buffer, AXIS2_STRLEN(buffer));            
+         AXIS2_STREAM_WRITE(out_stream, env, buffer, buffer_size);            
          AXIS2_FREE(env->allocator, buffer);
    
             op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env);



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