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/04/26 04:16:39 UTC
svn commit: r397053 - in
/webservices/axis2/trunk/c/modules/core/transport/http:
http_simple_request.c http_transport_utils.c sender/soap_over_http_sender.c
Author: samisa
Date: Tue Apr 25 19:16:35 2006
New Revision: 397053
URL: http://svn.apache.org/viewcvs?rev=397053&view=rev
Log:
MTOM integration code added.
These changes are required to get MTOM working
Modified:
webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c
webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c?rev=397053&r1=397052&r2=397053&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_simple_request.c Tue Apr 25 19:16:35 2006
@@ -137,6 +137,20 @@
simple_request_impl->stream = content;
simple_request_impl->header_group = NULL;
simple_request_impl->owns_stream = AXIS2_FALSE;
+
+ if (!(simple_request_impl->stream))
+ {
+ simple_request_impl->stream = axis2_stream_create_basic(env);
+ if(NULL == simple_request_impl->stream)
+ {
+ axis2_http_simple_request_free((axis2_http_simple_request_t*)
+ simple_request_impl, env);
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ simple_request_impl->owns_stream = AXIS2_TRUE;
+ }
+
if(http_hdr_count > 0 && NULL != http_headers)
{
int i = 0;
Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c?rev=397053&r1=397052&r2=397053&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 Tue Apr 25 19:16:35 2006
@@ -505,9 +505,21 @@
axis2_http_transport_utils_do_write_mtom(axis2_env_t **env,
axis2_msg_ctx_t *msg_ctx)
{
- /*
- TODO implement when MTOM support is added
- */
+ axis2_property_t *property = NULL;
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+ property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env,
+ AXIS2_ENABLE_MTOM, AXIS2_FALSE);
+ if(property)
+ {
+ axis2_char_t *value = (axis2_char_t *)AXIS2_PROPERTY_GET_VALUE(property, env);
+
+ if (value)
+ {
+ return (AXIS2_STRCMP(value, AXIS2_VALUE_TRUE) == 0);
+ }
+ }
+
return AXIS2_FALSE;
}
Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c?rev=397053&r1=397052&r2=397053&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c Tue Apr 25 19:16:35 2006
@@ -186,6 +186,9 @@
axis2_http_simple_response_t *response = NULL;
axis2_char_t *content_type = NULL;
axis2_property_t *property = NULL;
+ axis2_byte_t *output_stream = NULL;
+ int output_stream_size = 0;
+ axis2_bool_t doing_mtom = AXIS2_FALSE;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
@@ -222,6 +225,8 @@
AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_HTTP_CLIENT,
property, AXIS2_TRUE);
+ doing_mtom = AXIS2_MSG_CTX_GET_DOING_MTOM(msg_ctx, env);
+
if(NULL == sender_impl->om_output)
{
AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_OM_OUTPUT,
@@ -241,14 +246,24 @@
{
char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING;
}
- /* AXIS2_OM_OUTPUT_SET_DO_OPTIMIZE(om_output, env,
- * AXIS2_MSG_CTX_GET_IS_DOING_MTOM(msg_ctx, env);
- */
+
+ AXIS2_OM_OUTPUT_SET_DO_OPTIMIZE(sender_impl->om_output, env,
+ doing_mtom);
+
AXIS2_SOAP_ENVELOPE_SERIALIZE (out, env, sender_impl->om_output,
AXIS2_FALSE);
- buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
- if(NULL == buffer)
+ if (doing_mtom)
+ {
+ AXIS2_OM_OUTPUT_FLUSH(sender_impl->om_output, env, &output_stream,
+ &output_stream_size);
+ }
+ else
+ {
+ buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
+ }
+
+ if(NULL == buffer && !doing_mtom)
{
AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "NULL xml returned"
"from xml writer");
@@ -274,7 +289,17 @@
if(AXIS2_FALSE == sender_impl->chunked)
{
axis2_char_t tmp_buf[10];
- sprintf(tmp_buf, "%d", strlen(buffer));
+ int size = 0;
+ if (buffer)
+ {
+ size = strlen(buffer);
+ }
+ else
+ {
+ size = output_stream_size;
+ }
+
+ sprintf(tmp_buf, "%d", size);
http_header = axis2_http_header_create(env,
AXIS2_HTTP_HEADER_CONTENT_LENGTH, tmp_buf);
AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
@@ -287,7 +312,11 @@
AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
}
/* TODO we need to set the content type with soap action header for soap12*/
- if(AXIS2_TRUE == AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env))
+ if (doing_mtom)
+ {
+ content_type = AXIS2_OM_OUTPUT_GET_CONTENT_TYPE(sender_impl->om_output, env);
+ }
+ else if(AXIS2_TRUE == AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env))
{
content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
content_type = AXIS2_STRACAT(content_type, ";charset=", env);
@@ -319,7 +348,20 @@
AXIS2_URL_GET_SERVER(url, env));
AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
}
- AXIS2_HTTP_SIMPLE_REQUEST_SET_BODY_STRING(request, env, buffer);
+
+ if (doing_mtom)
+ {
+ axis2_stream_t* stream = AXIS2_HTTP_SIMPLE_REQUEST_GET_BODY(request, env);
+ if (stream)
+ {
+ AXIS2_STREAM_WRITE(stream, env, output_stream, output_stream_size);
+ }
+ }
+ else
+ {
+ AXIS2_HTTP_SIMPLE_REQUEST_SET_BODY_STRING(request, env, buffer);
+ }
+
axis2_soap_over_http_sender_get_timeout_values(sender, env, msg_ctx);
AXIS2_HTTP_CLIENT_SET_TIMEOUT(sender_impl->client, env,
sender_impl->so_timeout);