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/05/03 11:02:34 UTC

svn commit: r399215 - in /webservices/axis2/trunk/c: modules/core/clientapi/svc_client.c samples/user_guide/clients/echo_blocking.c

Author: samisa
Date: Wed May  3 02:02:22 2006
New Revision: 399215

URL: http://svn.apache.org/viewcvs?rev=399215&view=rev
Log:
more fixes related to options to prevent segfaults

Modified:
    webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c
    webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c

Modified: webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c?rev=399215&r1=399214&r2=399215&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c (original)
+++ webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c Wed May  3 02:02:22 2006
@@ -225,6 +225,16 @@
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
+    
+    svc_client_impl->svc = NULL;
+    svc_client_impl->conf = NULL;
+    svc_client_impl->conf_ctx = NULL;
+	svc_client_impl->svc_ctx = NULL;
+    svc_client_impl->options = NULL;
+    svc_client_impl->override_options = NULL;
+    svc_client_impl->headers = NULL;
+	svc_client_impl->callback_recv = NULL;	
+
 
     /** initialize private data to NULL, create options */
     if (!axis2_svc_client_init_data(env, svc_client_impl))
@@ -233,11 +243,6 @@
 		return NULL;
 	}
 
-    if (!conf_ctx)
-    {
-        
-    }
-	
 	if (!axis2_svc_client_initialize_transport(env, svc_client_impl, conf_ctx, client_home))
 	{
 		axis2_svc_client_free(&(svc_client_impl->svc_client), env);
@@ -818,7 +823,7 @@
 
     svc_client_impl->svc_ctx = NULL;
 
-	svc_client_impl->options = AXIS2_MALLOC((*env)->allocator, sizeof(axis2_options_t));
+	svc_client_impl->options = axis2_options_create(env);
     if (!svc_client_impl->options)
     {
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);

Modified: webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c?rev=399215&r1=399214&r2=399215&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c (original)
+++ webservices/axis2/trunk/c/samples/user_guide/clients/echo_blocking.c Wed May  3 02:02:22 2006
@@ -26,12 +26,15 @@
 int main(int argc, char** argv)
 {
     axis2_env_t *env = NULL;
+    axis2_char_t *address = NULL;
+    axis2_endpoint_ref_t* endpoint_ref = NULL;
+    axis2_options_t *options = NULL;
     axis2_char_t *client_home = NULL;
     axis2_svc_client_t* svc_client = NULL;
 
     axis2_om_node_t *node = NULL;
     axis2_status_t status = AXIS2_FAILURE;
-    axis2_char_t *address = NULL;
+    
     axis2_char_t *wsa_action = NULL;
     axis2_om_node_t *ret_node = NULL;
     axis2_svc_t *svc = NULL;
@@ -40,13 +43,32 @@
     axis2_msg_ctx_t *msg_ctx = NULL;
     axis2_mep_client_t *mep_client = NULL;
     axis2_msg_info_headers_t *msg_info_headers = NULL;
-    axis2_endpoint_ref_t* endpoint_ref = NULL;
+    
     axis2_conf_t *conf = NULL;
     axis2_msg_ctx_t *response_ctx = NULL;
     
     /* set up the envioronment */
     env = axis2_env_create_all("echo_blocking.log", AXIS2_LOG_LEVEL_TRACE);
 
+    /* Set end point reference of echo service */
+    address = "http://localhost:9090/axis2/services/echo";
+    if (argc > 1 )
+        address = argv[1];
+    if (AXIS2_STRCMP(address, "-h") == 0)
+    {
+        printf("Usage : %s [endpoint_url]\n", argv[0]);
+        printf("use -h for help\n");
+        return 0;
+    }
+    printf ("Using endpoint : %s\n", address);
+    
+    /* create EPR with given address */
+    endpoint_ref = axis2_endpoint_ref_create(&env, address);
+
+    /* Setup options */
+    options = axis2_options_create(&env);
+    AXIS2_OPTIONS_SET_TO(options, &env, endpoint_ref);
+
     /* Set up deploy folder. It is from the deploy folder, the configuration is picked up 
      * using the axis2.xml file.
      * In this sample client_home points to the Axis2/C default deploy folder. The client_home can 
@@ -59,6 +81,7 @@
         client_home = "../../deploy";
 
     svc_client = axis2_svc_client_create(&env, client_home);
+    AXIS2_SERVICE_CLIENT_SET_OPTIONS(svc_client, &env, options);
 
     if (!svc_client)
     {
@@ -68,19 +91,6 @@
                         AXIS2_ERROR_GET_MESSAGE(env->error));
     }
     
-    /* Set end point reference of echo service */
-    address = "http://localhost:9090/axis2/services/echo";
-    wsa_action = "http://ws.apache.org/axis2/c/samples/echoString";
-    if (argc > 1 )
-        address = argv[1];
-    if (AXIS2_STRCMP(address, "-h") == 0)
-    {
-        printf("Usage : %s [endpoint_url]\n", argv[0]);
-        printf("use -h for help\n");
-        return 0;
-    }
-
-    printf ("Using endpoint : %s\n", address);
 
     /* build the SOAP request message content using OM API.*/
     node = build_om_programatically(&env);
@@ -103,8 +113,6 @@
        This can be used to manipulate SOAP header content when using WS-Addressing. */
     msg_info_headers = AXIS2_MSG_CTX_GET_MSG_INFO_HEADERS(msg_ctx, &env);
 
-    /* create an axis2_endpoint_ref_t struct with ERP assigned */
-    endpoint_ref = axis2_endpoint_ref_create(&env, address);
 
     /* Set header parameters, required for WS-Addressing. 
      * Required only if you need to make use of WS-Addressing.