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 Luís Bilo <lp...@gmail.com> on 2008/10/28 16:52:01 UTC

Rest enhancements

Hi,

I've been also working on some enhancements for axis in order to
support some required features to our project.  We are using axis2/c
module for apache instead of the standalone server, changes are  not
tested for the standalone.

#1 Adds http headers to msg_ctx when using axis2/c module for apache
I noticed however this functionality were only implemented for the
standalone server. When using the axis module for apache  http headers
were not added to the msg_ctx so they were not accessible @ the inflow
handlers level for instance.

#2 Adds forbidden definition tags for http forbidden code which is
missing in standard release

     #define AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL 403
     #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN_CODE_NAME "Forbidden"
     #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN "403 Forbidden"

#3 Adds support to specify feedback for REST requests, when a module
failure occurs.

This issue is related to the difference between soap and rest
requests. When an inflow handler fails two things can happen depending
on the request type:

- For SOAP requests, the inflow handler chain is broken, and all the
outflow fault handlers are invoked. The response soap envelope
response containing a default fault is built by axis in between these
phases, so we can edit the fault accordingly @ the outflow fault
handlers.
- For REST requests, the inflow handler chain is also broken, but the
outflow fault handlers are not invoked. This is not a problem, and is
probably intended, since unlike soap there is no need to create a soap
envelope. The thing is when this happens it always returned 202
ACCEPTED, which is not enough to provide any feedback to the user who
made the request.

@ the inflow handler is now possible to set the desired status code
desired for the response, extra http headers, and/or http content. It
was already possible before, changes just weren't propagated to the
actual response.

inflow handler example with the patch:
..
	// For REST requests
	if (doing_rest && AXIS2_FAILURE == result)
	{

		axis2_msg_ctx_set_status_code(msg_ctx, env,
AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL);
		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[Inflow][authentication_in]
HTTP status code unauthorized");
			
		axutil_stream_t *stream = axutil_stream_create_basic(env);
		axis2_char_t *http_content = axutil_strcat(env,
AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED, "\n", NULL);
		axutil_stream_write(stream, env, http_content, axutil_strlen(http_content));
		axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, stream);		
	}
	
    return result;
}

I think these features may also be of interest for axis2/c users, at
least for us they seemed important, and would be nice to to have to
patch these to each new release of axis. The diff's follow in
attachment.

Regards,
Lu�s Bilo

Re: Rest enhancements

Posted by Uthaiyashankar <sh...@wso2.com>.
Uthaiyashankar wrote:
> Hi,
>
> Thank you very much for the patch. Can you please create a jira in [1] 
> and attach the patch file? Then it would be easy to manage and track it.
> When attaching the file, remember to select "Grant license to ASF for 
> inclusion in ASF works (as per the Apache License 
> <http://www.apache.org/licenses/LICENSE-2.0> §5) " option.
>
> Regards,
> Shankar.

[1] https://issues.apache.org/jira/browse/AXIS2C

>
> Luís Bilo wrote:
>> Hi,
>>
>> I've been also working on some enhancements for axis in order to
>> support some required features to our project.  We are using axis2/c
>> module for apache instead of the standalone server, changes are  not
>> tested for the standalone.
>>
>> #1 Adds http headers to msg_ctx when using axis2/c module for apache
>> I noticed however this functionality were only implemented for the
>> standalone server. When using the axis module for apache  http headers
>> were not added to the msg_ctx so they were not accessible @ the inflow
>> handlers level for instance.
>>
>> #2 Adds forbidden definition tags for http forbidden code which is
>> missing in standard release
>>
>>      #define AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL 403
>>      #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN_CODE_NAME "Forbidden"
>>      #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN "403 Forbidden"
>>
>> #3 Adds support to specify feedback for REST requests, when a module
>> failure occurs.
>>
>> This issue is related to the difference between soap and rest
>> requests. When an inflow handler fails two things can happen depending
>> on the request type:
>>
>> - For SOAP requests, the inflow handler chain is broken, and all the
>> outflow fault handlers are invoked. The response soap envelope
>> response containing a default fault is built by axis in between these
>> phases, so we can edit the fault accordingly @ the outflow fault
>> handlers.
>> - For REST requests, the inflow handler chain is also broken, but the
>> outflow fault handlers are not invoked. This is not a problem, and is
>> probably intended, since unlike soap there is no need to create a soap
>> envelope. The thing is when this happens it always returned 202
>> ACCEPTED, which is not enough to provide any feedback to the user who
>> made the request.
>>
>> @ the inflow handler is now possible to set the desired status code
>> desired for the response, extra http headers, and/or http content. It
>> was already possible before, changes just weren't propagated to the
>> actual response.
>>
>> inflow handler example with the patch:
>> ..
>>     // For REST requests
>>     if (doing_rest && AXIS2_FAILURE == result)
>>     {
>>
>>         axis2_msg_ctx_set_status_code(msg_ctx, env,
>> AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL);
>>         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
>> "[Inflow][authentication_in]
>> HTTP status code unauthorized");
>>            
>>         axutil_stream_t *stream = axutil_stream_create_basic(env);
>>         axis2_char_t *http_content = axutil_strcat(env,
>> AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED, "\n", NULL);
>>         axutil_stream_write(stream, env, http_content, 
>> axutil_strlen(http_content));
>>         axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, 
>> stream);       
>>     }
>>     
>>     return result;
>> }
>>
>> I think these features may also be of interest for axis2/c users, at
>> least for us they seemed important, and would be nice to to have to
>> patch these to each new release of axis. The diff's follow in
>> attachment.
>>
>> Regards,
>> Luís Bilo
>>   
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>
>


-- 
S.Uthaiyashankar
Software Architect
WSO2 Inc. 
http://wso2.com/ - "The Open Source SOA Company" 


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


Re: Rest enhancements

Posted by Uthaiyashankar <sh...@wso2.com>.
Hi,

Thank you very much for the patch. Can you please create a jira in [1] 
and attach the patch file? Then it would be easy to manage and track it.
When attaching the file, remember to select "Grant license to ASF for 
inclusion in ASF works (as per the Apache License 
<http://www.apache.org/licenses/LICENSE-2.0> §5) " option.

Regards,
Shankar.

Luís Bilo wrote:
> Hi,
>
> I've been also working on some enhancements for axis in order to
> support some required features to our project.  We are using axis2/c
> module for apache instead of the standalone server, changes are  not
> tested for the standalone.
>
> #1 Adds http headers to msg_ctx when using axis2/c module for apache
> I noticed however this functionality were only implemented for the
> standalone server. When using the axis module for apache  http headers
> were not added to the msg_ctx so they were not accessible @ the inflow
> handlers level for instance.
>
> #2 Adds forbidden definition tags for http forbidden code which is
> missing in standard release
>
>      #define AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL 403
>      #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN_CODE_NAME "Forbidden"
>      #define AXIS2_HTTP_RESPONSE_HTTP_FORBIDDEN "403 Forbidden"
>
> #3 Adds support to specify feedback for REST requests, when a module
> failure occurs.
>
> This issue is related to the difference between soap and rest
> requests. When an inflow handler fails two things can happen depending
> on the request type:
>
> - For SOAP requests, the inflow handler chain is broken, and all the
> outflow fault handlers are invoked. The response soap envelope
> response containing a default fault is built by axis in between these
> phases, so we can edit the fault accordingly @ the outflow fault
> handlers.
> - For REST requests, the inflow handler chain is also broken, but the
> outflow fault handlers are not invoked. This is not a problem, and is
> probably intended, since unlike soap there is no need to create a soap
> envelope. The thing is when this happens it always returned 202
> ACCEPTED, which is not enough to provide any feedback to the user who
> made the request.
>
> @ the inflow handler is now possible to set the desired status code
> desired for the response, extra http headers, and/or http content. It
> was already possible before, changes just weren't propagated to the
> actual response.
>
> inflow handler example with the patch:
> ..
> 	// For REST requests
> 	if (doing_rest && AXIS2_FAILURE == result)
> 	{
>
> 		axis2_msg_ctx_set_status_code(msg_ctx, env,
> AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL);
> 		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[Inflow][authentication_in]
> HTTP status code unauthorized");
> 			
> 		axutil_stream_t *stream = axutil_stream_create_basic(env);
> 		axis2_char_t *http_content = axutil_strcat(env,
> AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED, "\n", NULL);
> 		axutil_stream_write(stream, env, http_content, axutil_strlen(http_content));
> 		axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, stream);		
> 	}
> 	
>     return result;
> }
>
> I think these features may also be of interest for axis2/c users, at
> least for us they seemed important, and would be nice to to have to
> patch these to each new release of axis. The diff's follow in
> attachment.
>
> Regards,
> Luís Bilo
>   
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org


-- 
S.Uthaiyashankar
Software Architect
WSO2 Inc. 
http://wso2.com/ - "The Open Source SOA Company" 


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