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/03/01 10:55:53 UTC
svn commit: r381969 - in /webservices/axis2/trunk/c: include/
modules/core/transport/http/ modules/core/transport/http/receiver/
modules/util/
Author: sahan
Date: Wed Mar 1 01:55:49 2006
New Revision: 381969
URL: http://svn.apache.org/viewcvs?rev=381969&view=rev
Log:
Fixed a bug in creating epr using a relative address.
Modified:
webservices/axis2/trunk/c/include/axis2_http_worker.h
webservices/axis2/trunk/c/include/axis2_network_handler.h
webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h
webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c
webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c
webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c
webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
webservices/axis2/trunk/c/modules/util/network_handler.c
Modified: webservices/axis2/trunk/c/include/axis2_http_worker.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_http_worker.h?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_worker.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_worker.h Wed Mar 1 01:55:49 2006
@@ -30,7 +30,6 @@
#include <axis2_http_simple_response.h>
#include <axis2_http_simple_request.h>
#include <axis2_conf_ctx.h>
-#include <axis2_http_worker.h>
#ifdef __cplusplus
@@ -57,7 +56,11 @@
axis2_env_t **env,
axis2_simple_http_svr_conn_t *svr_conn,
axis2_http_simple_request_t *simple_request);
-
+
+ axis2_status_t (AXIS2_CALL *set_svr_port)
+ (axis2_http_worker_t *http_worker,
+ axis2_env_t **env,
+ int port);
axis2_status_t (AXIS2_CALL *free)
(axis2_http_worker_t *http_worker,
axis2_env_t **env);
@@ -82,6 +85,8 @@
#define AXIS2_HTTP_WORKER_PROCESS_REQUEST(http_worker, env, svr_conn,\
simple_request) ((http_worker)->ops->process_request(\
http_worker, env, svr_conn, simple_request))
+#define AXIS2_HTTP_WORKER_SET_SVR_PORT(http_worker, env, port) \
+ ((http_worker)->ops->set_svr_port(http_worker, env, port))
#define AXIS2_HTTP_WORKER_FREE(http_worker, env) \
((http_worker)->ops->free(http_worker, env))
Modified: webservices/axis2/trunk/c/include/axis2_network_handler.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_network_handler.h?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_network_handler.h (original)
+++ webservices/axis2/trunk/c/include/axis2_network_handler.h Wed Mar 1 01:55:49 2006
@@ -21,6 +21,7 @@
#include <axis2_defines.h>
#include <axis2_env.h>
#include <sys/types.h>
+#include <axis2_platform_auto_sense.h>
@@ -78,6 +79,14 @@
*/
AXIS2_DECLARE(int)
axis2_network_handler_svr_socket_accept(axis2_env_t **env, int socket);
+
+/**
+ * Returns the ip address of the server associated with the socket
+ * @param socket valid socket (obtained by accept() or similar call)
+ * @return ip address asoociated with the socket or NULL
+ */
+AXIS2_DECLARE(axis2_char_t *)
+axis2_network_handler_get_svr_ip(axis2_env_t **env, axis2_socket_t socket);
/** @} */
#ifdef __cplusplus
Modified: webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h (original)
+++ webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h Wed Mar 1 01:55:49 2006
@@ -79,6 +79,9 @@
axis2_status_t (AXIS2_CALL *set_snd_timeout)
(axis2_simple_http_svr_conn_t *svr_conn,
axis2_env_t **env, int timeout);
+ axis2_char_t* (AXIS2_CALL *get_svr_ip)
+ (axis2_simple_http_svr_conn_t *svr_conn,
+ axis2_env_t **env);
axis2_status_t (AXIS2_CALL *free)
(axis2_simple_http_svr_conn_t *svr_conn,
axis2_env_t **env);
@@ -120,6 +123,8 @@
((svr_conn)->ops->set_snd_timeout(svr_conn, env, timeout))
#define AXIS2_SIMPLE_HTTP_SVR_CONN_SET_RCV_TIMEOUT(svr_conn, env, timeout) \
((svr_conn)->ops->set_rcv_timeout(svr_conn, env, timeout))
+#define AXIS2_SIMPLE_HTTP_SVR_CONN_GET_SVR_IP(svr_conn, env) \
+ ((svr_conn)->ops->get_svr_ip(svr_conn, env))
#define AXIS2_SIMPLE_HTTP_SVR_CONN_FREE(svr_conn, env) \
((svr_conn)->ops->free(svr_conn, env))
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=381969&r1=381968&r2=381969&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 Wed Mar 1 01:55:49 2006
@@ -294,7 +294,7 @@
soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope,
env);
- if (!soap_body)
+ if (NULL == soap_body)
return AXIS2_FAILURE;
if(AXIS2_TRUE == AXIS2_SOAP_BODY_HAS_FAULT(soap_body, env))
@@ -913,7 +913,6 @@
return NULL;
}
soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder, env);
- /* TODO have to free the buider, xml reader and om builder */
return soap_envelope;
}
/**
Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c Wed Mar 1 01:55:49 2006
@@ -26,6 +26,7 @@
#include <axis2_op_ctx.h>
#include <axis2_engine.h>
#include <axis2_uuid_gen.h>
+#include <axis2_url.h>
/**
* @brief HTTP Worker struct impl
@@ -37,6 +38,7 @@
{
axis2_http_worker_t http_worker;
axis2_conf_ctx_t *conf_ctx;
+ int svr_port;
};
#define AXIS2_INTF_TO_IMPL(http_worker) ((axis2_http_worker_impl_t *)\
@@ -68,6 +70,9 @@
axis2_http_worker_get_headers(axis2_http_worker_t *http_worker,
axis2_env_t **env,
axis2_http_simple_request_t *request);
+
+axis2_status_t axis2_http_worker_set_svr_port(axis2_http_worker_t *worker,
+ axis2_env_t **env, int port);
axis2_status_t AXIS2_CALL
axis2_http_worker_free(axis2_http_worker_t *http_worker,
@@ -89,6 +94,7 @@
return NULL;
}
http_worker_impl->conf_ctx = conf_ctx;
+ http_worker_impl->svr_port = 9090; /* default - must set later*/
http_worker_impl->http_worker.ops = AXIS2_MALLOC((*env)->allocator,
sizeof(axis2_http_worker_ops_t));
@@ -100,7 +106,9 @@
}
http_worker_impl->http_worker.ops->process_request =
- axis2_http_worker_process_request;
+ axis2_http_worker_process_request;
+ http_worker_impl->http_worker.ops->set_svr_port =
+ axis2_http_worker_set_svr_port;
http_worker_impl->http_worker.ops->free = axis2_http_worker_free;
return &(http_worker_impl->http_worker);
@@ -144,6 +152,8 @@
axis2_http_header_t *encoding_header = NULL;
axis2_char_t *encoding_header_value = NULL;
axis2_op_ctx_t *op_ctx = NULL;
+ axis2_char_t *svr_ip = NULL;
+ axis2_url_t *request_url = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK((*env)->error, svr_conn, AXIS2_FAILURE);
@@ -218,6 +228,12 @@
axis2_http_worker_set_transport_out_config(http_worker, env, conf_ctx,
response);
}
+ svr_ip = AXIS2_SIMPLE_HTTP_SVR_CONN_GET_SVR_IP(svr_conn, env);
+ request_url = axis2_url_create(env, "http", svr_ip,
+ http_worker_impl->svr_port,
+ AXIS2_HTTP_REQUEST_LINE_GET_URI(
+ AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
+ simple_request, env), env));
AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_OUT, out_stream,
AXIS2_FALSE);
AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_HEADERS,
@@ -243,9 +259,7 @@
(env, msg_ctx, request_body, out_stream,
AXIS2_HTTP_SIMPLE_REQUEST_GET_CONTENT_TYPE(
simple_request, env) ,soap_action,
- AXIS2_HTTP_REQUEST_LINE_GET_URI(
- AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
- simple_request, env), env),
+ AXIS2_URL_TO_EXTERNAL_FORM(request_url, env),
conf_ctx,
axis2_http_transport_utils_get_request_params(env,
AXIS2_HTTP_REQUEST_LINE_GET_URI(
@@ -287,9 +301,7 @@
(env, msg_ctx, request_body, out_stream,
AXIS2_HTTP_SIMPLE_REQUEST_GET_CONTENT_TYPE(
simple_request, env) , content_length, soap_action,
- AXIS2_HTTP_REQUEST_LINE_GET_URI
- (AXIS2_HTTP_SIMPLE_REQUEST_GET_REQUEST_LINE(
- simple_request, env), env));
+ AXIS2_URL_TO_EXTERNAL_FORM(request_url, env));
if(status == AXIS2_FAILURE)
{
axis2_msg_ctx_t *fault_ctx = NULL;
@@ -521,4 +533,12 @@
AXIS2_HASH_KEY_STRING, tmp_hdr);
}
return header_map;
+}
+
+axis2_status_t axis2_http_worker_set_svr_port(axis2_http_worker_t *worker,
+ axis2_env_t **env, int port)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_INTF_TO_IMPL(worker)->svr_port = port;
+ return AXIS2_SUCCESS;
}
Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_server.c Wed Mar 1 01:55:49 2006
@@ -180,6 +180,7 @@
return AXIS2_FAILURE;
}
worker = axis2_http_worker_create(env, server_impl->conf_ctx);
+ AXIS2_HTTP_WORKER_SET_SVR_PORT(worker, env, server_impl->port);
if(NULL == worker)
{
AXIS2_HTTP_SVR_THREAD_FREE(server_impl->svr_thread, env);
Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c Wed Mar 1 01:55:49 2006
@@ -195,8 +195,8 @@
arg_list->socket = socket;
arg_list->worker = svr_thread_impl->worker;
#ifdef AXIS2_SVR_MULTI_THREADED
- worker_thread = AXIS2_THREAD_POOL_GET_THREAD((*env)->thread_pool, worker_func,
- (void*)arg_list);
+ worker_thread = AXIS2_THREAD_POOL_GET_THREAD((*env)->thread_pool,
+ worker_func, (void*)arg_list);
if(NULL == worker_thread)
{
AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "Thread creation failed"
Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c?rev=381969&r1=381968&r2=381969&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 Wed Mar 1 01:55:49 2006
@@ -89,6 +89,10 @@
axis2_simple_http_svr_conn_read_request_body
(axis2_simple_http_svr_conn_t *svr_conn,
axis2_env_t **env, axis2_char_t *buffer, int size);
+
+axis2_char_t *axis2_simple_http_svr_conn_get_svr_ip
+ (axis2_simple_http_svr_conn_t *svr_conn,
+ axis2_env_t **env);
axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_free(axis2_simple_http_svr_conn_t *svr_conn,
@@ -152,6 +156,8 @@
axis2_simple_http_svr_conn_set_rcv_timeout;
svr_conn_impl->svr_conn.ops->set_snd_timeout =
axis2_simple_http_svr_conn_set_snd_timeout;
+ svr_conn_impl->svr_conn.ops->get_svr_ip =
+ axis2_simple_http_svr_conn_get_svr_ip;
svr_conn_impl->svr_conn.ops->free = axis2_simple_http_svr_conn_free;
return &(svr_conn_impl->svr_conn);
}
@@ -474,4 +480,13 @@
return axis2_network_handler_set_sock_option(env,
AXIS2_INTF_TO_IMPL(svr_conn)->socket, SO_SNDTIMEO,
timeout);
+}
+
+axis2_char_t *axis2_simple_http_svr_conn_get_svr_ip(
+ axis2_simple_http_svr_conn_t *svr_conn,
+ axis2_env_t **env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ return axis2_network_handler_get_svr_ip(env,
+ AXIS2_INTF_TO_IMPL(svr_conn)->socket);
}
Modified: webservices/axis2/trunk/c/modules/util/network_handler.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/network_handler.c?rev=381969&r1=381968&r2=381969&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/network_handler.c (original)
+++ webservices/axis2/trunk/c/modules/util/network_handler.c Wed Mar 1 01:55:49 2006
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <axis2_network_handler.h>
#include <fcntl.h>
-#include <axis2_platform_auto_sense.h>
#if defined(WIN32)
@@ -238,3 +237,19 @@
return 1;
}
#endif
+
+
+axis2_char_t* axis2_network_handler_get_svr_ip(axis2_env_t **env,
+ axis2_socket_t socket)
+{
+ struct sockaddr_in addr;
+ socklen_t len = sizeof(addr);
+ char *ret = NULL;
+ memset(&addr, 0, sizeof(addr));
+ if(getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
+ {
+ return NULL;
+ }
+ ret = inet_ntoa(addr.sin_addr);
+ return ret;
+}