Great that you got it working, you welcome :)

Andrei.

From: Al Eridani [mailto:[email protected]]
Sent: Donnerstag, 13. Februar 2014 20:24
To: Andrei Shakirin
Subject: Re: Automatic exception conversion?

Thank you, Andrei, that was very helpful.


On Wed, Feb 12, 2014 at 6:36 AM, Andrei Shakirin 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

The interceptor should looks like:

public class ClientSoapFaultInterceptor extends 
AbstractPhaseInterceptor<SoapMessage> {

        public ClientSoapFaultInterceptor() {
                super(Phase.PRE_LOGICAL);
        }

        @Override
        public void handleMessage(SoapMessage message) throws Fault {
                Exception e = message.getContent(Exception.class);
                if (e != null) {
                        message.setContent(Exception.class, new 
IllegalArgumentException("my test"));
                }
        }
}

Instead new IllegalArgumentException("my test") you can put your own exception.

Configuration of interceptor using spring will be the following:

        <jaxws:client id="customerService"
                serviceName="customer:CustomerServiceService"
                endpointName="customer:CustomerServiceEndpoint"
                address="http://localhost:9090/CustomerServicePort";
                serviceClass="com.example.customerservice.CustomerService">

               <jaxws:inFaultInterceptors>
                  <bean 
class="com.example.customerservice.client.ClientSoapFaultInterceptor"/>
              </jaxws:inFaultInterceptors>

        </jaxws:client>

Regards,
Andrei.

> -----Original Message-----
> From: Al Eridani [mailto:[email protected]<mailto:[email protected]>]
> Sent: Dienstag, 11. Februar 2014 18:50
> To: [email protected]<mailto:[email protected]>
> Subject: Re: Automatic exception conversion?
>
> Thank you for your reply, Andrei.
> This is for JAX-WS. Do  you have any pointers to documentation or examples
> about how do I write my own interceptor and how to I place it in the fault
> chain?
> Regards,
>
>
>
> On Mon, Feb 10, 2014 at 10:41 PM, Andrei Shakirin
> <[email protected]<mailto:[email protected]>>wrote:
>
> > Hi,
> >
> > Do you speak about JAX-RS or JAX-WS service?
> > In former case it is possible to achieve that with Exception Mapper.
> > For JAX-WS you likely need to write own interceptor and put it into fault
> chain.
> >
> > Regards,
> > Andrei.
> >
> > > -----Original Message-----
> > > From: Al Eridani 
> > > [mailto:[email protected]<mailto:[email protected]>]
> > > Sent: Montag, 10. Februar 2014 19:49
> > > To: [email protected]<mailto:[email protected]>
> > > Subject: Automatic exception conversion?
> > >
> > > Hello, all my web service methods follow the same pattern:
> > >
> > > public ... someMethod() throws MyWebServicesFault {
> > >     try {
> > >       ...
> > >     } catch (Exception e) {
> > >       throw new MyWebServicesFault(e);
> > >     }
> > >   }
> > >
> > > Is it possible to simplify them by eliminating the try/catch and
> > > somehow
> > tell the
> > > CXF framework to catch any exception thrown and to wrap it into my
> > > custom MyWebServicesFault?
> > >
> > > I'm using 2.6.2, if it matters.
> > >
> > > Thanks!
> >

Reply via email to