You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID (ATTSI)" <dk...@att.com> on 2010/11/12 04:24:06 UTC
How to have an interceptor execute on an exception in an earlier interceptor?
I'm working on replacing a custom soap client. One thing the old code
did was wrap the eventual sending of the message in a "try/finally"
block so that it could do work in the try block that was guaranteed to
match with code in the finally block. The two matching blocks are very
simple, just making a single function call. With CXF, the closest
analogue is a matching "Out" and "In" interceptor. However, I'm finding
that if certain bad things happen, like a connection timeout, it appears
that the "In" interceptor in the "RECEIVE" phase is never executed. Is
there some way I can do something analogous to the old code?
RE: How to have an interceptor execute on an exception in an
earlier interceptor?
Posted by Sven Zethelius <sv...@expedia.com>.
Yes. Connection won't be open until some point in the out interceptor chain. When it fails, you'll get an exception from that interceptor, most likely wrapped in another exception due to the use of XMLStreams everywhere.
-----Original Message-----
From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
Sent: Friday, November 12, 2010 10:33 AM
To: users@cxf.apache.org
Subject: RE: How to have an interceptor execute on an exception in an earlier interceptor?
> -----Original Message-----
> From: Sven Zethelius [mailto:svenz@expedia.com]
> Sent: Friday, November 12, 2010 10:10 AM
> To: users@cxf.apache.org
> Subject: RE: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> If you put an interceptor earlier in the same chain (e.g. Phase.SETUP
> in the OUT chain), and override its handleFault with the logic you
> want, it will get called during the unwinding of the phase interceptor
> chain.
Ok, that will handle the Soap fault case, but what if the initial
connection failed with an IOException, perhaps because of a timeout?
Will it get to the "handleFault()" method?
> -----Original Message-----
> From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
> Sent: Thursday, November 11, 2010 7:24 PM
> To: users@cxf.apache.org
> Subject: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> I'm working on replacing a custom soap client. One thing the old code
> did was wrap the eventual sending of the message in a "try/finally"
> block so that it could do work in the try block that was guaranteed to
> match with code in the finally block. The two matching blocks are
very
> simple, just making a single function call. With CXF, the closest
> analogue is a matching "Out" and "In" interceptor. However, I'm
> finding
> that if certain bad things happen, like a connection timeout, it
> appears
> that the "In" interceptor in the "RECEIVE" phase is never executed.
Is
> there some way I can do something analogous to the old code?
RE: How to have an interceptor execute on an exception in an earlier interceptor?
Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: Sven Zethelius [mailto:svenz@expedia.com]
> Sent: Friday, November 12, 2010 10:10 AM
> To: users@cxf.apache.org
> Subject: RE: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> If you put an interceptor earlier in the same chain (e.g. Phase.SETUP
> in the OUT chain), and override its handleFault with the logic you
> want, it will get called during the unwinding of the phase interceptor
> chain.
Ok, that will handle the Soap fault case, but what if the initial
connection failed with an IOException, perhaps because of a timeout?
Will it get to the "handleFault()" method?
> -----Original Message-----
> From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
> Sent: Thursday, November 11, 2010 7:24 PM
> To: users@cxf.apache.org
> Subject: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> I'm working on replacing a custom soap client. One thing the old code
> did was wrap the eventual sending of the message in a "try/finally"
> block so that it could do work in the try block that was guaranteed to
> match with code in the finally block. The two matching blocks are
very
> simple, just making a single function call. With CXF, the closest
> analogue is a matching "Out" and "In" interceptor. However, I'm
> finding
> that if certain bad things happen, like a connection timeout, it
> appears
> that the "In" interceptor in the "RECEIVE" phase is never executed.
Is
> there some way I can do something analogous to the old code?
RE: How to have an interceptor execute on an exception in an
earlier interceptor?
Posted by Sven Zethelius <sv...@expedia.com>.
What I said before is only for exceptions thrown by interceptors. Received faults are not thrown until it gets back to the ClientImpl. If you want to intercept and act on those, you'll need an INFAULT interceptor, Phase.USER_LOGICAL (any phase after UNMARSHAL), that checks message.getContent(Exception.class) from its handleMessage method.
-----Original Message-----
From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
Sent: Friday, November 12, 2010 11:12 AM
To: users@cxf.apache.org
Subject: RE: How to have an interceptor execute on an exception in an earlier interceptor?
> -----Original Message-----
> From: Sven Zethelius [mailto:svenz@expedia.com]
> Sent: Friday, November 12, 2010 10:10 AM
> To: users@cxf.apache.org
> Subject: RE: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> If you put an interceptor earlier in the same chain (e.g. Phase.SETUP
> in the OUT chain), and override its handleFault with the logic you
> want, it will get called during the unwinding of the phase interceptor
> chain.
I implemented this, but the current test case I'm looking at is
returning a soap fault, but it's not hitting this "handleFault()"
method. It goes through the "In" interceptor chain, and the fault
appears to be otherwise properly processed, but it never gets to
"handleFault()". Will it only follow this path if I get a severe
connection failure?
> -----Original Message-----
> From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
> Sent: Thursday, November 11, 2010 7:24 PM
> To: users@cxf.apache.org
> Subject: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> I'm working on replacing a custom soap client. One thing the old code
> did was wrap the eventual sending of the message in a "try/finally"
> block so that it could do work in the try block that was guaranteed to
> match with code in the finally block. The two matching blocks are
very
> simple, just making a single function call. With CXF, the closest
> analogue is a matching "Out" and "In" interceptor. However, I'm
> finding
> that if certain bad things happen, like a connection timeout, it
> appears
> that the "In" interceptor in the "RECEIVE" phase is never executed.
Is
> there some way I can do something analogous to the old code?
RE: How to have an interceptor execute on an exception in an earlier interceptor?
Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: Sven Zethelius [mailto:svenz@expedia.com]
> Sent: Friday, November 12, 2010 10:10 AM
> To: users@cxf.apache.org
> Subject: RE: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> If you put an interceptor earlier in the same chain (e.g. Phase.SETUP
> in the OUT chain), and override its handleFault with the logic you
> want, it will get called during the unwinding of the phase interceptor
> chain.
I implemented this, but the current test case I'm looking at is
returning a soap fault, but it's not hitting this "handleFault()"
method. It goes through the "In" interceptor chain, and the fault
appears to be otherwise properly processed, but it never gets to
"handleFault()". Will it only follow this path if I get a severe
connection failure?
> -----Original Message-----
> From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
> Sent: Thursday, November 11, 2010 7:24 PM
> To: users@cxf.apache.org
> Subject: How to have an interceptor execute on an exception in an
> earlier interceptor?
>
> I'm working on replacing a custom soap client. One thing the old code
> did was wrap the eventual sending of the message in a "try/finally"
> block so that it could do work in the try block that was guaranteed to
> match with code in the finally block. The two matching blocks are
very
> simple, just making a single function call. With CXF, the closest
> analogue is a matching "Out" and "In" interceptor. However, I'm
> finding
> that if certain bad things happen, like a connection timeout, it
> appears
> that the "In" interceptor in the "RECEIVE" phase is never executed.
Is
> there some way I can do something analogous to the old code?
RE: How to have an interceptor execute on an exception in an
earlier interceptor?
Posted by Sven Zethelius <sv...@expedia.com>.
If you put an interceptor earlier in the same chain (e.g. Phase.SETUP in the OUT chain), and override its handleFault with the logic you want, it will get called during the unwinding of the phase interceptor chain.
-----Original Message-----
From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
Sent: Thursday, November 11, 2010 7:24 PM
To: users@cxf.apache.org
Subject: How to have an interceptor execute on an exception in an earlier interceptor?
I'm working on replacing a custom soap client. One thing the old code
did was wrap the eventual sending of the message in a "try/finally"
block so that it could do work in the try block that was guaranteed to
match with code in the finally block. The two matching blocks are very
simple, just making a single function call. With CXF, the closest
analogue is a matching "Out" and "In" interceptor. However, I'm finding
that if certain bad things happen, like a connection timeout, it appears
that the "In" interceptor in the "RECEIVE" phase is never executed. Is
there some way I can do something analogous to the old code?