Did you really mean the names of parameters or what you want to get is instead 
the value of incoming parameters? If it is the later, I would say it is only 
possible to get the parameter values after the data binding marshaling stage. 
The exact point various depending on the protocol binding (eg, SOAP binding or 
XML binding etc) and data binding being used. The safest bet to make is before 
the ServiceInvokerInterceptor. If it is the former, normally a list of 
parameter names is available as soon as the name of the method to invoke has 
been determined, as you can always get parameter names using reflection from 
the Method object. Unfortunately to know exactly when this happens is more 
complex than knowing parameter values. If you do a search for 
"put(BindingOperationInfo.class" throughout the CXF workspace, you may find 
what interceptors are responsible for determining which method to dispatch to 
based on different criteria (eg, RPC or Doc lit wrapped or REST HTTP binding..).

Cheers,
Jervis
 

> -----Original Message-----
> From: Vespa, Anthony J [mailto:[EMAIL PROTECTED]
> Sent: 2007年11月21日 22:19
> To: Liu, Jervis; cxf-user@incubator.apache.org
> Subject: RE: Interceptors pulling values out of requests
> 
> This has nudged me along, thanks. =)
> 
> The only question I have remaining is, is there a way to get a list at any 
> point
> that actually has the paramter names?  Basically a map.  Ideally I would
> like to be able to, for any present or future function call, to get the named
> paramters so I could drop those directly into the log.
> 
> Thanks for your help!
> 
> -Tony
> 
> -----Original Message-----
> From: Liu, Jervis [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 20, 2007 10:00 PM
> To: Vespa, Anthony J; cxf-user@incubator.apache.org
> Subject: RE: Interceptors pulling values out of requests
> 
> What does your SEI operation look like? Sth like "void getChannel(Session s,
> long channelD)" ? This should work. The List object you get by using "List
> body = msg.getContent(List.class)" contains Session object and the channelD,
> they are ordered, i.e., body.get(0) always return the Session object and
> body.get(1) returns whatever the second parameter of is.
> 
> If it does not work, most likely it is because you did not put your 
> interceptor
> at the right position: when your interceptor is invoked, the List has not been
> populated yet. You may want to have a quick debug to see if your
> interceptor is invoked right before ServiceInvokerInterceptor.
> 
> BTW, you get can method name using following code (take a look at
> org.apache.cxf.interceptor. ServiceInvokerInterceptor and
> org.apache.cxf.service.invoker. AbstractInvoker)
> 
> public class MyInterceptor extends AbstractPhaseInterceptor<Message> {
>   public MyInterceptor () {
>         super(Phase.INVOKE);
>         addBefore(ServiceInvokerInterceptor.class.getName());
>   }
> 
>   public void handleMessage(final Message message) {
>     final Exchange exchange = message.getExchange();
>     BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
>     MethodDispatcher md = (MethodDispatcher)
> exchange.get(Service.class).get(MethodDispatcher.class.getName());
>     Method m = md.getMethod(bop);
>     .....
>   }
> 
> }
> 
> Hope this helps,
> Jervis
> 
> 
> > -----Original Message-----
> > From: Vespa, Anthony J [mailto:[EMAIL PROTECTED]
> > Sent: 2007年11月21日 0:41
> > To: cxf-user@incubator.apache.org; Liu, Jervis
> > Subject: RE: Interceptors pulling values out of requests
> >
> >
> > Thank you for the information.  It isn't quite solving my issue though.
> >
> > What I am trying to do is to log the values in my request stream.  My
> > request looks like this:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <soap:Envelope
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
> > <soap:Body>
> > <getChannel>
> > <session>
> > <sessionUser>123</sessionUser>
> > <sessionGuid>ABC123DEF456</sessionGuid>
> > </session>
> > <channelid>1</channelid>
> > </getChannel>
> > </soap:Body>
> > </soap:Envelope>
> >
> >
> > The inputs are a custom session class I created, and a long
> >
> > I want my interceptor to get out
> >
> > -The name of the service
> > -The name of the method
> > -The session as an object
> > -The channel id as an object
> >
> > I want to be able to do this all in one interceptor, and I do not want to
> make
> > it a high
> > Impact operation as it would be done in every call and written to a log.  I
> > tried your example and the body comes through as null always.
> >
> > I have been doing this:
> >
> > List body = msg.getContent(List.class);
> > mySession sess = (mySession)body.get(0);
> >
> >
> > Which is not ideal.
> >
> > I would like to access the input generically - in so much that I want to 
> > pull
> > named parameters from a variety of different calls (some called channelId,
> > some userId, etc) and I am looking to be able to either sniff for these 
> > items
> > trivially (they are not always in there) if possible.  There will always be 
> > a
> > mySession type object that has two fields in it, but I don't know if it will
> > always be first.
> >
> > So, with this in mind, can you provide more guidence.  I am doing this
> > currently in the invoke phase.
> >
> > Thanks!
> >
> > -Tony
> >
> > -----Original Message-----
> > From: Liu, Jervis [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, November 20, 2007 12:36 AM
> > To: cxf-user@incubator.apache.org
> > Subject: RE: Interceptors pulling values out of requests
> >
> > 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:[EMAIL PROTECTED]
> > > 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
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

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

Reply via email to