Monday, September 15, 2008

Sending WS-Addressing reference Parameters with Axis2/C

After fixing some bugs I was able to send WS-Addressing reference parameters from Axis2/C. Problem was in the receiving end where it just ignores the reference parameters. You can send reference parameters now targeting the endpoint address or something you want in the reply message.

/*First create the axiom_node,*/

axiom_node_t *ref_param = your_ref_param_node_creation_func(env);

/*To send a ref_param targeting the endpoint*/

axis2_endpoint_ref_add_ref_param(to_epr, env, ref_param);

/*To send a ref_param inside reply_to header */
axis2_endpoint_ref_add_ref_param(reply_to_epr, env, ref_param);

In the latter case you will see the ref_param in the reply as a top level addressing header.

1 comment:

Unknown said...

Hi - Thanks for the informative post. As you describe, I have sent some reference parameters in my client code. But how do I read them in the service code?

You mention a problem in the receiving end. That is what I am having. The service does not see any reference parameters.

I tried the following in the invoke method in my service:

//Get message context
in_msg_ctx = axis2_op_ctx_get_msg_ctx(operation_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);

//get message header
axis2_msg_info_headers_t * msg_info_headers =
axis2_msg_ctx_get_msg_info_headers(in_msg_ctx, env);

//get TO endpoint reference from message header
axis2_endpoint_ref_t * ToEPRfromHeaders =
axis2_msg_info_headers_get_to(msg_info_headers, env);

//get TO endpoint reference from message context
axis2_endpoint_ref_t * ToEPRfromCtx =
axis2_msg_ctx_get_to(in_msg_ctx, env);

/*Get list of reference parameters*/
axutil_array_list_t * refParamList_FromToFromHeader =
axis2_endpoint_ref_get_ref_param_list(ToEPRfromHeaders, env);

axutil_array_list_t * refParamList_FromToFromCtx =
axis2_endpoint_ref_get_ref_param_list(ToEPRfromCtx, env);

axutil_array_list_t * refParamList_FromHeader =
axis2_msg_info_headers_get_all_ref_params(msg_info_headers, env);

Calling axutil_array_list_size on the lists returns 0. Calling axutil_array_list_get to get the first element in the lists returns NULL.