cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Reject Service Request based on headers
Date Wed, 20 Mar 2013 18:33:19 GMT

There's actually not an easy way to do this, partially because few (if any) clients would
actually support this use case.

Most clients (including CXF) would be blocked trying to write the attachment onto the HTTP
connection/socket.   Thus, if you don't read the attachments, they will not ever "unblock".
  Without unblocking, they would not get the response.   Instead, they would either hang forever
or more likely get some sort of socket timeout.

From your interceptor, you could grab the HTTPServletRequest object and grab the input stream
and "close" it, but even then, the client would get a socket closed exception, not any sort
of response.  

Dan


On Mar 19, 2013, at 1:34 AM, Forum User <techacct123@gmail.com> wrote:

> Hi,
> Using CXF Version 2.7.3
> I have created a Provider service which acts as a proxy for all our web
> service requests and some of the requests have attachments which are huge
> and I want to create an interceptor which will look at the soap headers and
> reject the message based on the header before the stream is processed and
> the attachment is stored in a temp file (Based on my endpoint settings).
> 
> Even when i do a chain.abort(), the attachment is streamed and the fault i
> throw in my interceptor is sent back as the response.
> My Question is:
> How do I prevent the stream to be processed?
> 
> Here is my Interceptor. For ease of reading, i removed all the unnecessary
> code. Lets assume, in all cases, the interceptor throws a fault. So, when
> my client is streaming 200 MB attachment (using MTOM), the response should
> be received in milliseconds but it takes the same amount of time if i were
> to process the message. Please advice. BTW, My interceptor is called, 'coz
> i get the fault with the same exception code as below.
> 
> public class ValidateHeadersInterceptor extends AbstractPhaseInterceptor {
> 
>    public ValidateHeadersInterceptor(){
>        super(Phase.RECEIVE);
> 
>    }
> 
>    @Override
>    public void handleMessage(Message message) throws Fault {
> 
>        Fault fault = new Fault(new Exception("Error processing request.
> Invalid Header"));
>        fault.setFaultCode(new QName("Client"));
>        InterceptorChain chain = message.getInterceptorChain();
>        chain.abort();
>        throw fault;
>    }
> }
> Thanks,
> Sam

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
View raw message