You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by cj91 <Jo...@argushealth.com> on 2009/09/28 18:08:18 UTC

Stuck: What interceptor unmarshals qnames back into java objects?

I'm attempting to write my first interceptor, but having trouble getting of
the ground. It's basically a custom logger that takes attributes from the
request/response and writes them to a database our DBA's have created for
me.

I chose the interceptor route because it is easily enabled/disabled in the
Spring config, and we want to use it across many of our webservices without
changing the webservice code.

These are SOAP services over Http.

First, my interceptor class declaration:
public class SimpleUsageTrackingCXFInterceptor implements
PhaseInterceptor<Message>

public void handleMessage(Message soapMessage) throws Fault {
....
}

soapMessage has a ton of methods. I need to get a handle to the Java objects
the XML represents. if I call Message.getValues() I get a bunch of QName
objects. Is there a better method to use to get the unmarshalled objects? 

I've read through the mailing list that where I insert my interceptor in the
chain has a lot to do with this... I've tried setting breakpoints in
PhaseInterceptorChain but It's really not clicking. Is there a particular
interceptor I should insert my interceptor after?

I'm not asking for someone to write my code, just a stern shove in the
correct direction. Thanks for any help guys!
-- 
View this message in context: http://www.nabble.com/Stuck%3A-What-interceptor-unmarshals-qnames-back-into-java-objects--tp25646299p25646299.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Stuck: What interceptor unmarshals qnames back into java objects?

Posted by "Fisher, Jonathan" <Jo...@argushealth.com>.
Thanks! I think this will get me where I need to go!


-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Monday, September 28, 2009 12:27 PM
To: users@cxf.apache.org
Cc: Fisher, Jonathan
Subject: Re: Stuck: What interceptor unmarshals qnames back into java
objects?



It would be one of the subclasses of AbstractInDatabindingInterceptor.

USUALLY that would be DocLiteralInInterceptor, but it could also be the 
RPCInInterceptor or others.

In anycase, to get the List of params, you would normally do:
MessageContentsList lst = MessageContentsList.getContentsList(message);
(which really just does msg.getContent(List.class) and double checks the
class 
and such)

However, what's in there could also depend on where in the chain your 
interceptor lives and whether you use jaxws or not.      If you put it 
immediately after the DocLiteralInInterceptor  (unmarshal phase), it
would 
probably have a single object in it being the wrapper object.   If you
move 
your interceptor to POST_LOGICAL and after the
WrapperClassInInterceptor, the 
list would have the individual parts.

Dan



On Mon September 28 2009 12:08:18 pm cj91 wrote:
> I'm attempting to write my first interceptor, but having trouble
getting of
> the ground. It's basically a custom logger that takes attributes from
the
> request/response and writes them to a database our DBA's have created
for
> me.
> 
> I chose the interceptor route because it is easily enabled/disabled in
the
> Spring config, and we want to use it across many of our webservices
without
> changing the webservice code.
> 
> These are SOAP services over Http.
> 
> First, my interceptor class declaration:
> public class SimpleUsageTrackingCXFInterceptor implements
> PhaseInterceptor<Message>
> 
> public void handleMessage(Message soapMessage) throws Fault {
> ....
> }
> 
> soapMessage has a ton of methods. I need to get a handle to the Java
>  objects the XML represents. if I call Message.getValues() I get a
bunch of
>  QName objects. Is there a better method to use to get the
unmarshalled
>  objects?
> 
> I've read through the mailing list that where I insert my interceptor
in
>  the chain has a lot to do with this... I've tried setting breakpoints
in
>  PhaseInterceptorChain but It's really not clicking. Is there a
particular
>  interceptor I should insert my interceptor after?
> 
> I'm not asking for someone to write my code, just a stern shove in the
> correct direction. Thanks for any help guys!
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

PRIVILEGED AND CONFIDENTIAL
This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  If the reader of the email is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any use, dissemination or copying of this email transmission is strictly prohibited by the sender.  If you have received this transmission in error, please delete the email and immediately notify the sender via the email return address or mailto:postmaster@argushealth.com.  Thank you.





Re: Stuck: What interceptor unmarshals qnames back into java objects?

Posted by Daniel Kulp <dk...@apache.org>.

It would be one of the subclasses of AbstractInDatabindingInterceptor.   
USUALLY that would be DocLiteralInInterceptor, but it could also be the 
RPCInInterceptor or others.

In anycase, to get the List of params, you would normally do:
MessageContentsList lst = MessageContentsList.getContentsList(message);
(which really just does msg.getContent(List.class) and double checks the class 
and such)

However, what's in there could also depend on where in the chain your 
interceptor lives and whether you use jaxws or not.      If you put it 
immediately after the DocLiteralInInterceptor  (unmarshal phase), it would 
probably have a single object in it being the wrapper object.   If you move 
your interceptor to POST_LOGICAL and after the WrapperClassInInterceptor, the 
list would have the individual parts.

Dan



On Mon September 28 2009 12:08:18 pm cj91 wrote:
> I'm attempting to write my first interceptor, but having trouble getting of
> the ground. It's basically a custom logger that takes attributes from the
> request/response and writes them to a database our DBA's have created for
> me.
> 
> I chose the interceptor route because it is easily enabled/disabled in the
> Spring config, and we want to use it across many of our webservices without
> changing the webservice code.
> 
> These are SOAP services over Http.
> 
> First, my interceptor class declaration:
> public class SimpleUsageTrackingCXFInterceptor implements
> PhaseInterceptor<Message>
> 
> public void handleMessage(Message soapMessage) throws Fault {
> ....
> }
> 
> soapMessage has a ton of methods. I need to get a handle to the Java
>  objects the XML represents. if I call Message.getValues() I get a bunch of
>  QName objects. Is there a better method to use to get the unmarshalled
>  objects?
> 
> I've read through the mailing list that where I insert my interceptor in
>  the chain has a lot to do with this... I've tried setting breakpoints in
>  PhaseInterceptorChain but It's really not clicking. Is there a particular
>  interceptor I should insert my interceptor after?
> 
> I'm not asking for someone to write my code, just a stern shove in the
> correct direction. Thanks for any help guys!
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog