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

Reply via email to