axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clifford THOMPSON" <cthom...@mdacorporation.com>
Subject RE: [AXIS2C] Questions regarding proper use of code generated by WSDL2C
Date Wed, 12 Dec 2007 23:43:53 GMT
Hello Dimuthu,
 
Thank you for your comments. After further examination, I think my
problems stems from the use of custom headers (lines 76-83 in my
original post). Since the calls to "axis2_stub_get_svc_client"(line 58)
in both "FirstOperation" and "SecondOperation" return the same value, ie
"svc_client", my code will keep adding headers to "svc_client" without
cleaning up the previous headers. I added a call to
"axis2_svc_client_remove_all_headers" before line 76 to clean up the
headers, but I may have encountered a bug in the
"axis2_svc_client_remove_all_headers" function. The call to
"axutil_array_list_remove" (line 108) is where the problem stems from:
 
98      for (i = 0; i < size; i++)
99      {
100         /*axiom_node_t *node = NULL;
101            node = axutil_array_list_get(svc_client->headers, env,
i);
102
103            if (node)
104            {
105            axiom_node_free_tree(node, env);
106            node = NULL;
107            } */
108         axutil_array_list_remove(svc_client->headers, env, i);
109     }


110 AXIS2_EXTERN void *AXIS2_CALL
111 axutil_array_list_remove(
112     struct axutil_array_list *array_list,
113     const axutil_env_t * env,
114     int index)
115 {
116     void *result = NULL;
117     int i = 0;
118     AXIS2_PARAM_CHECK (env->error, array_list, AXIS2_FAILURE);
119
120     if (axutil_array_list_check_bound_exclusive(array_list, env,
index))
121     {
122         result = array_list->data[index];
123         for (i = index; i < array_list->size - 1; i++)
124             array_list->data[i] = array_list->data[i + 1];
125         array_list->size--;
126     }
127
128     return result;
129 }

Since the for-loop (line 98) is incrementing, and the value of
"array_list->size" (line 125) is decrementing, eventually line 120 will
fail, and some of the headers will not be cleared out. So the call to
axutil_array_list_remove should be decrementing (line 108 is a possible
solution):

98      for (i = 0; i < size; i--)
99      {
100         /*axiom_node_t *node = NULL;
101            node = axutil_array_list_get(svc_client->headers, env,
i);
102
103            if (node)
104            {
105            axiom_node_free_tree(node, env);
106            node = NULL;
107            } */
108         axutil_array_list_remove(svc_client->headers, env, (size -
i) - 1);
109     }

Cheers,
Cliff
________________________________

From: Dimuthu Gamage [mailto:dimuthuc@gmail.com] 
Sent: December 11, 2007 17:57
To: Apache AXIS C User List
Subject: Re: [AXIS2C] Questions regarding proper use of code generated
by WSDL2C


Hi Clifford,

Yea, I think this is a problem in the service client API in axis2/c, We
should be able to set soap_action in operation wise, but now we have to
call axis2_option_set_action before each operation call. 

Anyway this is handled in the latest codegen templates.  (There inside
the generated code we set the soap_action before the operation call and
invalidate that after the operation by setting action to NULL. You cant
download the latest snapshot from
http://people.apache.org/dist/axis2/nightly

You can do it manually as you mentioned, If that is still not working,
this may due to some other cause, But better go with the generated code
with the latest tool, since it  has fixed many bugs as well.. 

Thanks
Dimuthu


On Dec 12, 2007 3:04 AM, Clifford THOMPSON <cthompso@mdacorporation.com>
wrote:


	Hello,
	
	I have a question regarding how to properly interact with the
code
	generated by WSDL2C. The problem I am running into occurs when I
try to
	execute two different web service operations in succession. I am

	developing under WinXP. My code looks something like the
following:
	
	01    env = axutil_env_create_all( "myLogFile.log",
	02                                 AXIS2_LOG_LEVEL_TRACE);
	03
	04    stub = axis2_stub_AvnEsbService_create( env, 
	05
	AXIS2_GETENV("AXIS2C_HOME"),
	06
	"http://mytestserver:8080/MyService");
	07
	08    axis2_stub_MyServer_FirstOperation_start( stub, 
	09                                              env,
	10                                              opBodyNode,
	11
opCustomHeaderNode1,
	12
opCustomHeaderNode2, 
	13
opCustomHeaderNode3
	14
	onFirstOperationResponseCb,
	15
	onFirstOperationErrorCb);
	16
	17    axis2_stub_MyServer_SecondOperation_start( stub,
	18                                               env, 
	19                                               opBodyNode,
	20
opCustomHeaderNode1,
	21
opCustomHeaderNode2,
	22
opCustomHeaderNode3 
	23
	onSecondOperationResponseCb,
	24
	onSecondOperationErrorCb);
	
	The area in the WSDL2C-generated code where things seem a bit
sinister
	is within the call to
"axis2_stub_MyServer_SecondOperation_start" on 
	line 60:
	
	25    void axis2_stub_MyServer_SecondOperation_start(
	26        const axis2_stub_t *stub,
	27        const axutil_env_t *env,
	28        axiom_node_t* opBodyNode,
	29        axiom_node_t* opCustomHeaderNode1, 
	30        axiom_node_t* opCustomHeadernode2,
	31        axiom_node_t* opCustomHeaderNode3,
	32        axis2_status_t ( AXIS2_CALL *on_complete ) (struct
	axis2_callback *, const axutil_env_t *) ,
	33        axis2_status_t ( AXIS2_CALL *on_error ) (struct
axis2_callback 
	*, const axutil_env_t *, int ) )
	34    {
	35
	36        axis2_callback_t *callback = NULL;
	37
	38        axis2_svc_client_t *svc_client = NULL;
	39        axis2_options_t *options = NULL;
	40
	41        const axis2_char_t *soap_action = NULL; 
	42        axiom_node_t *payload = NULL;
	43
	44
	45        axutil_string_t *soap_act = NULL;
	46        axis2_status_t status;
	47
	48        payload = opBodyNode;
	49
	50        options = axis2_stub_get_options( stub, env); 
	51        if ( NULL == options )
	52        {
	53            AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "options
is null
	in stub: Error code:"
	54                             " %d :: %s",
env->error->error_number, 
	55
AXIS2_ERROR_GET_MESSAGE(env->error));
	56            return;
	57        }
	58        svc_client = axis2_stub_get_svc_client (stub, env );
	59        soap_action =axis2_options_get_action ( options, env
); 
	60        if ( NULL == soap_action )
	61        {
	62            soap_action =
	"http://www.mydeployedserver.com/services/SecondOperation
<http://www.mydeployedserver.com/services/SecondOperation> ";
	63
	64            soap_act = axutil_string_create(env,
	"http://www.mydeployedserver.com/services/SecondOperation ");
	65            axis2_options_set_soap_action(options, env,
soap_act);
	66
	67            axis2_options_set_action( options, env,
soap_action );
	68        }
	69
	70        axis2_options_set_soap_version(options, env,
AXIOM_SOAP11 ); 
	71
	72        /***************************************************/
	73        /* START NON-AUTOGEN CODE - add our custom headers */
	74        /***************************************************/
	75
	76        status = 
	axis2_svc_client_add_header(svc_client,env,opCustomHeaderNode1);
	77        assert(AXIS2_SUCCESS == status);
	78
	79        status =
	axis2_svc_client_add_header(svc_client,env,opCustomHeaderNode2);
	80        assert(AXIS2_SUCCESS == status); 
	81
	82        status =
	axis2_svc_client_add_header(svc_client,env,opCustomHeaderNode3);
	83        assert(AXIS2_SUCCESS == status);
	84
	85        /************************/
	86        /* END NON_AUTOGEN CODE */ 
	87        /************************/
	88
	89        callback = axis2_callback_create(env);
	90        /* Set our on_complete fucntion pointer to the
callback object
	*/
	91        axis2_callback_set_on_complete(callback, on_complete);

	92        /* Set our on_error function pointer to the callback
object */
	93        axis2_callback_set_on_error(callback, on_error);
	94
	95        /* Send request */
	96        axis2_svc_client_send_receive_non_blocking(svc_client,
env, 
	payload, callback);
	97    }
	
	On line 60, "soap_action" is not NULL (which it was for the call
to
	"FirstOperation"), and it contains the value from the previous
call to
	"FirstOperation", ie 
	"http://www.mydeployedserver.com/services/FirstOperation", which
of
	course make sense, but I get an access violation later in the
function 
	(from within the call stack of
	"axis2_svc_client_send_receive_non_blocking"). My question is,
is there
	some kind of 'housekeeping' I need to do in between calls to
different
	operations? I have tried setting "soap_action" to NULL using 
	"axis2_stub_get_options" and "axis2_options_set_action" after
the call
	to "axis2_stub_MyServer_FirstOperation_start", but this seems to
cause
	similar problems.
	
	Cheers,
	Cliff 
	
	
---------------------------------------------------------------------
	To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
	For additional commands, e-mail: axis-c-user-help@ws.apache.org
	
	



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


Mime
View raw message