You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by ruanhuabin <ru...@gmail.com> on 2010/12/15 03:39:02 UTC

How to add custom http headers in response message In Axis2/C 1.6

Hi, all, recently I used axis2/C to develop a web system, I encounter  a problem confusing a long time, I want to add a custom http header in my response message, I write to following code hoping to achive it, but I failed,Can someone help me pointing out what's the problem in my code, thank you!

axis2_op_ctx_t *op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
axis2_msg_ctx_t *out_msg_ctx;
out_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_OUT);
axis2_char_t *header_name = "x_object_name";    /*Custom header name*/
axis2_char_t *header_value = "1234567";    /*Custom header value*/
axis2_http_header_t *http_header =  axis2_http_header_create(env, header_name, header_value);
axutil_array_list_t *http_headers_list = axutil_array_list_create(env, 1);
axutil_array_list_add(http_headers_list, env, http_header);
axis2_msg_ctx_set_http_output_headers(out_msg_ctx, env, http_headers_list);  /*I used this method to set my custom http header*/

2010-12-15 



ruanhuabin 

Re: How to add custom http headers in response message In Axis2/C 1.6

Posted by Damitha Kumarage <da...@wso2.com>.
Hi Ruanhuabin,
AFAIK a custom header header set in message context is not added to the 
response currently. I think this is a improvement that can easily be 
done. Please add a jira.
Thanks,
Damitha

ruanhuabin wrote:
> Hi, all, recently I used *axis2/C* to develop a web system, I 
> encounter a problem confusing a long time, I want to *add a* *custom 
> http header* in my *response message,* I write to following code 
> hoping to achive it, but I failed,Can someone help me pointing out 
> what's the problem in my code, thank you!
> axis2_op_ctx_t *op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
> axis2_msg_ctx_t *out_msg_ctx;
> out_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, 
> AXIS2_WSDL_MESSAGE_LABEL_OUT);
> axis2_char_t *header_name = "x_object_name"; /*Custom header name*/
> axis2_char_t *header_value = "1234567"; /*Custom header value*/
> axis2_http_header_t *http_header = axis2_http_header_create(env, 
> header_name, header_value);
> axutil_array_list_t *http_headers_list = axutil_array_list_create(env, 1);
> axutil_array_list_add(http_headers_list, env, http_header);
> axis2_msg_ctx_set_http_output_headers(out_msg_ctx, env, 
> http_headers_list); /*I used this method to set my custom http header*/
> 2010-12-15
> ------------------------------------------------------------------------
> ruanhuabin


-- 
__________________________________________________________________

Damitha Kumarage
Technical Lead; WSO2 Inc.
"Oxygenating the Web Service Platform; " http://www.wso2.com/

blog: " http://damithakumarage.wordpress.com/
__________________________________________________________________

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