You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Vespa, Anthony J" <aj...@cbs.com> on 2007/11/19 20:55:13 UTC

Interceptors pulling values out of requests

Hello,

I'm writing a webservice with Aegis Bindings and would like to write an
interceptor to collect certain information - eg I want to look for
specific values in the incoming XML (the paramter values to the
functions in the SEI) - though I have followed some of the examples we
can't quite get at what we need.

Has anyone tried this before?

What is the best phase to use to get this info?

What objects can I grab and traverse to get me what I need?

Thanks!



RE: Interceptors pulling values out of requests

Posted by Glen Mazza <gl...@verizon.net>.
Am Dienstag, den 20.11.2007, 00:36 -0500 schrieb Liu, Jervis:
> I just updated the wiki page [1], hopefully it is more clear now how
> to write and configure user interceptors. Please let me know if there
> is anything missing or still not clear on this page. 

In the "Adding interceptors through configuration" section, we need to
know what those configuration files should be named and where they
should be placed.  Or, if that is already documented someplace else, a
link given to where that is documented.

Regards,
Glen


> [1]. http://cwiki.apache.org/confluence/display/CXF20DOC/Interceptors
> 
> Cheers,
> Jervis
> 



RE: Interceptors pulling values out of requests

Posted by "Liu, Jervis" <jl...@iona.com>.
I just updated the wiki page [1], hopefully it is more clear now how to write and configure user interceptors. Please let me know if there is anything missing or still not clear on this page. I am not sure what type of parameters you want to access through interceptors, lets presume you want to access the java parameter objects that are used to invoke the SEI operations. For example, for an operation whose signature is "String sayHi(String input)", you may want to access the value of input before sayHi is invoked. In this case, basically what you need to do is:

1. Write an interceptor according to the instruction [1]. 

2. The java parameter objects are only available after a certain interceptor. To figure out exactly what phase your interceptor need to sit in, you need to understand what happens along the interceptor chain. Basically when the request comes in, it is available as an InputStream, then a StaxReader is created in StaxInInterceptor to read this InputStream. The flow in the interceptor chain keeps moving. If the incoming request is a soap message, the soap headers will be stripped off by some intercetors, then the soap body. The content of soap body will be marshaled into java objects by either JAXB data binding or Aegis data binding by data binding interceptors. Finally the ServiceInvokerInterceptor is invoked which will in turn dispatch the request to "sayHi". 

In your case, I believe adding your interceptor before ServiceInvokerInterceptor should do the trick.

3. The java parameter objects can be accessed from Message. Eg:

public class MyInterceptor extends AbstractPhaseInterceptor<Message> {   
    
    public MyInterceptor () {
        super(Phase.INVOKE);
    }

    public void handleMessage(final Message message) {
        Object invokee = message.getContent(List.class);
        if (invokee == null) {
            invokee = message.getContent(Object.class);
        }
        .........
    }

} 

To understand more about CXF interceptor chain, I would suggest you do a quick debugging to see how the message flows along the interceptor chain. 

[1]. http://cwiki.apache.org/confluence/display/CXF20DOC/Interceptors

Cheers,
Jervis

> -----Original Message-----
> From: Vespa, Anthony J [mailto:ajvespa@cbs.com]
> Sent: 2007年11月20日 3:55
> To: cxf-user@incubator.apache.org
> Subject: Interceptors pulling values out of requests
> 
> Hello,
> 
> I'm writing a webservice with Aegis Bindings and would like to write an
> interceptor to collect certain information - eg I want to look for
> specific values in the incoming XML (the paramter values to the
> functions in the SEI) - though I have followed some of the examples we
> can't quite get at what we need.
> 
> Has anyone tried this before?
> 
> What is the best phase to use to get this info?
> 
> What objects can I grab and traverse to get me what I need?
> 
> Thanks!

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland