You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Stefan Alexandrescu <ab...@gmail.com> on 2007/08/15 15:21:57 UTC
Handle exceptions on the client side
Hi there ,
I had a problem with handling exception on the client side . Please
someone can help me with this issue ?
I used the latest release 2.0.1 . Using the samples I made a structure
similar with "distribution/src/main/release/samples/spring_http" but I want
that a method from a server to throw an exception that will be catch on the
client side . What can be wrong ? What should I do , to be able to manage
exceptions correctly ? I will attach also the wsdl generated file
Thanks in advance ,
Stefan
So I added something like this :
package demo.spring.util;
import javax.xml.ws.WebFault;
@WebFault(name="BookNotFoundFault")
public class BookNotFoundFault extends Exception {
private BookNotFoundDetails details;
public BookNotFoundFault(BookNotFoundDetails details) {
super();
this.details = details;
}
public BookNotFoundDetails getFaultInfo() {
return details;
}
}
package demo.spring.util;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="BookNotFoundDetails" )
public class BookNotFoundDetails {
private long id;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
package demo.spring;
import demo.spring.util.BookNotFoundFault;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style= SOAPBinding.Style.RPC, use= SOAPBinding.Use.LITERAL)
public interface HelloWorld {
String sayHi(String text);
public String testEx() throws BookNotFoundFault;
}
on the server ;
public String testEx() throws BookNotFoundFault {
BookNotFoundDetails details = new BookNotFoundDetails();
details.setId(100);
throw new BookNotFoundFault(details);
}
and on the client side :
// START SNIPPET: client
ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(new String[]
{"demo/spring/client/client-beans.xml"});
HelloWorld client = (HelloWorld)context.getBean("client");
try {
client.testEx();
} catch (BookNotFoundFault bookNotFoundFault) {
System.out.println
(">>>>>>>>>>>"+bookNotFoundFault.getFaultInfo().getId());
bookNotFoundFault.printStackTrace();
}
the client-beans.xml and beans.xml are the same with samples provided with
the release .
when executing the client code the following exception is throw :
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault
occurred while processing.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:169)
at $Proxy23.testEx(Unknown Source)
at demo.spring.client.Client.main(Client.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while
processing.
at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
(Soap11FaultInInterceptor.java:69)
at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
(Soap11FaultInInterceptor.java:36)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:207)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage
(AbstractFaultChainInitiatorObserver.java:90)
at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
(ReadHeadersInterceptor.java:181)
at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
(ReadHeadersInterceptor.java:57)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:207)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:395)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse
(HTTPConduit.java:1959)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
HTTPConduit.java:1806)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:574)
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:207)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
... 7 more
Re: Handle exceptions on the client side
Posted by Daniel Kulp <dk...@apache.org>.
FYI: I've logged a bug:
https://issues.apache.org/jira/browse/CXF-926
Dan
On Monday 20 August 2007, Daniel Kulp wrote:
> Stefan,
>
> This is definitely a bug in the CXF JAXB fault details handling.
> When getting a list of expected element names, it's not using the
> information from the @XmlRootElement to determine the element names.
> It's only using the WebFault information. Unfortunately, it's not
> really using that correctly either. If the @WebFault annotation
> doesn't put the proper namespace in, it will have issues with as well.
>
> There is a semi-workaround:
> If you completely specify the @WebFault annotation (including the
> targetNamespace), and then remove the @XmlRootElement annotation on
> the details, it would work. Or, make sure the data in the @WebFault
> matches the data in the @XmlRootElement. That's definitely not an
> ideal situation though. The element names may not be exactly what
> you want that way.
>
> One more note: You need to add a constructor:
> public BookNotFoundFault(String msg, BookNotFoundDetails details) {
> super(msg);
> this.details = details;
> }
> that's the constructor the runtime is looking for.
>
>
> Dan
>
> On Friday 17 August 2007, Stefan Alexandrescu wrote:
> > Hi there ,
> > Any hints for solving this problem ?
> > Thanks in advance ,
> > Stefan
> >
> > On 8/16/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> > > Hi Dan ,
> > > I will attach all the configurations files . They are actually
> > > the same with the examples files .
> > > what else can I verify ?
> > > Thanks in advance .
> > > Stefan
> > >
> > > On 8/15/07, Dan Diephouse <da...@envoisolutions.com> wrote:
> > > > Hi Stefan,
> > > > What does your server/client xml look like? Your code looks
> > > > correct to me.
> > > >
> > > > - Dan
> > > >
> > > > On 8/15/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> > > > > Hi there ,
> > > > > I had a problem with handling exception on the client
> > > > > side .
> > > >
> > > > Please
> > > >
> > > > > someone can help me with this issue ?
> > > > > I used the latest release 2.0.1 . Using the samples I made a
> > > > > structure similar with
> > > > > "distribution/src/main/release/samples/spring_http" but
> > > >
> > > > I want
> > > >
> > > > > that a method from a server to throw an exception that will be
> > > > > catch
> > > >
> > > > on the
> > > >
> > > > > client side . What can be wrong ? What should I do , to be
> > > > > able to
> > > >
> > > > manage
> > > >
> > > > > exceptions correctly ? I will attach also the wsdl generated
> > > > > file Thanks in advance ,
> > > > > Stefan
> > > > >
> > > > > So I added something like this :
> > > > >
> > > > > package demo.spring.util;
> > > > >
> > > > > import javax.xml.ws.WebFault;
> > > > >
> > > > > @WebFault(name="BookNotFoundFault")
> > > > > public class BookNotFoundFault extends Exception {
> > > > > private BookNotFoundDetails details;
> > > > >
> > > > > public BookNotFoundFault(BookNotFoundDetails details) {
> > > > > super();
> > > > > this.details = details;
> > > > > }
> > > > >
> > > > > public BookNotFoundDetails getFaultInfo() {
> > > > > return details;
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > package demo.spring.util;
> > > > >
> > > > > import javax.xml.bind.annotation.XmlRootElement;
> > > > >
> > > > > @XmlRootElement(name="BookNotFoundDetails" )
> > > > > public class BookNotFoundDetails {
> > > > > private long id;
> > > > >
> > > > > public long getId() {
> > > > > return id;
> > > > > }
> > > > >
> > > > > public void setId(long id) {
> > > > > this.id = id;
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > package demo.spring;
> > > > >
> > > > > import demo.spring.util.BookNotFoundFault;
> > > > >
> > > > > import javax.jws.WebService ;
> > > > > import javax.jws.soap.SOAPBinding;
> > > > >
> > > > > @WebService
> > > > > @SOAPBinding(style= SOAPBinding.Style.RPC, use=
> > > >
> > > > SOAPBinding.Use.LITERAL)
> > > >
> > > > > public interface HelloWorld {
> > > > > String sayHi(String text);
> > > > >
> > > > > public String testEx() throws BookNotFoundFault;
> > > > >
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > on the server ;
> > > > >
> > > > > public String testEx() throws BookNotFoundFault {
> > > > > BookNotFoundDetails details = new
> > > > > BookNotFoundDetails(); details.setId(100);
> > > > > throw new BookNotFoundFault(details);
> > > > > }
> > > > >
> > > > >
> > > > > and on the client side :
> > > > >
> > > > >
> > > > > // START SNIPPET: client
> > > > > ClassPathXmlApplicationContext context
> > > > > = new ClassPathXmlApplicationContext(new String[]
> > > > > {"demo/spring/client/client-beans.xml"});
> > > > >
> > > > > HelloWorld client =
> > > > > (HelloWorld)context.getBean("client");
> > > > >
> > > > > try {
> > > > > client.testEx();
> > > > > } catch (BookNotFoundFault bookNotFoundFault) {
> > > > >
> > > > > System.out.println(">>>>>>>>>>>"+bookNotFoundFault.getFaultInf
> > > > >o( ).getId());
> > > > >
> > > > >
> > > > > bookNotFoundFault.printStackTrace();
> > > > >
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > the client-beans.xml and beans.xml are the same with samples
> > > > > provided
> > > >
> > > > with
> > > >
> > > > > the release .
> > > > >
> > > > > when executing the client code the following exception is
> > > > > throw
> > > > >
> > > > >
> > > > > Exception in thread "main"
> > > > > javax.xml.ws.soap.SOAPFaultException: Fault occurred while
> > > > > processing.
> > > > > at
> > > > > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.
> > > > >ja va
> > > > >
> > > > > :169)
> > > > >
> > > > > at $Proxy23.testEx(Unknown Source)
> > > > > at demo.spring.client.Client.main(Client.java:47)
> > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native
> > > > > Method) at sun.reflect.NativeMethodAccessorImpl.invoke(
> > > > > NativeMethodAccessorImpl.java:39)
> > > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke (
> > > > > DelegatingMethodAccessorImpl.java:25)
> > > > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > > > at
> > > > > com.intellij.rt.execution.application.AppMain.main(AppMain.jav
> > > > >a
> > > > >
> > > > :90)
> > > > :
> > > > > Caused by: org.apache.cxf.binding.soap.SoapFault : Fault
> > > > > occurred
> > > >
> > > > while
> > > >
> > > > > processing.
> > > > > at
> > > >
> > > > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor
> > > >.h andleMessage
> > > >
> > > > > (Soap11FaultInInterceptor.java:69)
> > > > > at
> > > >
> > > > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor
> > > >.h andleMessage(
> > > >
> > > > > Soap11FaultInInterceptor.java:36)
> > > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > > > PhaseInterceptorChain.java:207)
> > > > > at
> > > >
> > > > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.o
> > > >nM essage(
> > > >
> > > > > AbstractFaultChainInitiatorObserver.java :90)
> > > > > at
> > > >
> > > > org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.h
> > > >an dleMessage
> > > >
> > > > > (ReadHeadersInterceptor.java:181)
> > > > > at
> > > >
> > > > org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.h
> > > >an dleMessage
> > > >
> > > > > (ReadHeadersInterceptor.java :57)
> > > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > > > PhaseInterceptorChain.java:207)
> > > > > at
> > > > > org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java
> > > > >
> > > > > :395) at
> > > >
> > > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.ha
> > > >nd leResponse (
> > > >
> > > > > HTTPConduit.java:1959)
> > > > > at
> > > >
> > > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.cl
> > > >os e(
> > > >
> > > > > HTTPConduit.java:1806)
> > > > > at org.apache.cxf.transport.AbstractConduit.close(
> > > >
> > > > AbstractConduit.java
> > > >
> > > > > :66)
> > > > >
> > > > > at org.apache.cxf.transport.http.HTTPConduit.close
> > > > > (HTTPConduit.java
> > > > >
> > > > :574)
> > > > :
> > > > > at
> > > >
> > > > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSende
> > > >rE ndingInterceptor.handleMessage
> > > >
> > > > > (MessageSenderInterceptor.java:62)
> > > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > > > > PhaseInterceptorChain.java:207)
> > > > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java
> > > > >
> > > > > :254) at
> > > > >
> > > > > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
> > > > > at org.apache.cxf.frontend.ClientProxy.invokeSync
> > > > > (ClientProxy.java
> > > > >
> > > > :73)
> > > > :
> > > > > at
> > > > > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.
> > > > >ja va
> > > > >
> > > > > :135)
> > > > >
> > > > > ... 7 more
> > > >
> > > > --
> > > > Dan Diephouse
> > > > Envoi Solutions
> > > > http://envoisolutions.com | http://netzooid.com/blog
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog
Re: Handle exceptions on the client side
Posted by Daniel Kulp <dk...@apache.org>.
Stefan,
This is definitely a bug in the CXF JAXB fault details handling. When
getting a list of expected element names, it's not using the information
from the @XmlRootElement to determine the element names. It's only
using the WebFault information. Unfortunately, it's not really using
that correctly either. If the @WebFault annotation doesn't put the
proper namespace in, it will have issues with as well.
There is a semi-workaround:
If you completely specify the @WebFault annotation (including the
targetNamespace), and then remove the @XmlRootElement annotation on the
details, it would work. Or, make sure the data in the @WebFault
matches the data in the @XmlRootElement. That's definitely not an
ideal situation though. The element names may not be exactly what you
want that way.
One more note: You need to add a constructor:
public BookNotFoundFault(String msg, BookNotFoundDetails details) {
super(msg);
this.details = details;
}
that's the constructor the runtime is looking for.
Dan
On Friday 17 August 2007, Stefan Alexandrescu wrote:
> Hi there ,
> Any hints for solving this problem ?
> Thanks in advance ,
> Stefan
>
> On 8/16/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> > Hi Dan ,
> > I will attach all the configurations files . They are actually the
> > same with the examples files .
> > what else can I verify ?
> > Thanks in advance .
> > Stefan
> >
> > On 8/15/07, Dan Diephouse <da...@envoisolutions.com> wrote:
> > > Hi Stefan,
> > > What does your server/client xml look like? Your code looks
> > > correct to me.
> > >
> > > - Dan
> > >
> > > On 8/15/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> > > > Hi there ,
> > > > I had a problem with handling exception on the client side
> > > > .
> > >
> > > Please
> > >
> > > > someone can help me with this issue ?
> > > > I used the latest release 2.0.1 . Using the samples I made a
> > > > structure similar with
> > > > "distribution/src/main/release/samples/spring_http" but
> > >
> > > I want
> > >
> > > > that a method from a server to throw an exception that will be
> > > > catch
> > >
> > > on the
> > >
> > > > client side . What can be wrong ? What should I do , to be able
> > > > to
> > >
> > > manage
> > >
> > > > exceptions correctly ? I will attach also the wsdl generated
> > > > file Thanks in advance ,
> > > > Stefan
> > > >
> > > > So I added something like this :
> > > >
> > > > package demo.spring.util;
> > > >
> > > > import javax.xml.ws.WebFault;
> > > >
> > > > @WebFault(name="BookNotFoundFault")
> > > > public class BookNotFoundFault extends Exception {
> > > > private BookNotFoundDetails details;
> > > >
> > > > public BookNotFoundFault(BookNotFoundDetails details) {
> > > > super();
> > > > this.details = details;
> > > > }
> > > >
> > > > public BookNotFoundDetails getFaultInfo() {
> > > > return details;
> > > > }
> > > >
> > > > }
> > > >
> > > > package demo.spring.util;
> > > >
> > > > import javax.xml.bind.annotation.XmlRootElement;
> > > >
> > > > @XmlRootElement(name="BookNotFoundDetails" )
> > > > public class BookNotFoundDetails {
> > > > private long id;
> > > >
> > > > public long getId() {
> > > > return id;
> > > > }
> > > >
> > > > public void setId(long id) {
> > > > this.id = id;
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > package demo.spring;
> > > >
> > > > import demo.spring.util.BookNotFoundFault;
> > > >
> > > > import javax.jws.WebService ;
> > > > import javax.jws.soap.SOAPBinding;
> > > >
> > > > @WebService
> > > > @SOAPBinding(style= SOAPBinding.Style.RPC, use=
> > >
> > > SOAPBinding.Use.LITERAL)
> > >
> > > > public interface HelloWorld {
> > > > String sayHi(String text);
> > > >
> > > > public String testEx() throws BookNotFoundFault;
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > on the server ;
> > > >
> > > > public String testEx() throws BookNotFoundFault {
> > > > BookNotFoundDetails details = new BookNotFoundDetails();
> > > > details.setId(100);
> > > > throw new BookNotFoundFault(details);
> > > > }
> > > >
> > > >
> > > > and on the client side :
> > > >
> > > >
> > > > // START SNIPPET: client
> > > > ClassPathXmlApplicationContext context
> > > > = new ClassPathXmlApplicationContext(new String[]
> > > > {"demo/spring/client/client-beans.xml"});
> > > >
> > > > HelloWorld client =
> > > > (HelloWorld)context.getBean("client");
> > > >
> > > > try {
> > > > client.testEx();
> > > > } catch (BookNotFoundFault bookNotFoundFault) {
> > > >
> > > > System.out.println(">>>>>>>>>>>"+bookNotFoundFault.getFaultInfo(
> > > >).getId());
> > > >
> > > >
> > > > bookNotFoundFault.printStackTrace();
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > the client-beans.xml and beans.xml are the same with samples
> > > > provided
> > >
> > > with
> > >
> > > > the release .
> > > >
> > > > when executing the client code the following exception is throw
> > > > :
> > > >
> > > > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException:
> > > > Fault occurred while processing.
> > > > at
> > > > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.ja
> > > >va
> > > >
> > > > :169)
> > > >
> > > > at $Proxy23.testEx(Unknown Source)
> > > > at demo.spring.client.Client.main(Client.java:47)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke(
> > > > NativeMethodAccessorImpl.java:39)
> > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke (
> > > > DelegatingMethodAccessorImpl.java:25)
> > > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > > at
> > > > com.intellij.rt.execution.application.AppMain.main(AppMain.java
> > > >
> > > :90)
> > > :
> > > > Caused by: org.apache.cxf.binding.soap.SoapFault : Fault
> > > > occurred
> > >
> > > while
> > >
> > > > processing.
> > > > at
> > >
> > > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.h
> > >andleMessage
> > >
> > > > (Soap11FaultInInterceptor.java:69)
> > > > at
> > >
> > > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.h
> > >andleMessage(
> > >
> > > > Soap11FaultInInterceptor.java:36)
> > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > > PhaseInterceptorChain.java:207)
> > > > at
> > >
> > > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onM
> > >essage(
> > >
> > > > AbstractFaultChainInitiatorObserver.java :90)
> > > > at
> > >
> > > org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.han
> > >dleMessage
> > >
> > > > (ReadHeadersInterceptor.java:181)
> > > > at
> > >
> > > org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.han
> > >dleMessage
> > >
> > > > (ReadHeadersInterceptor.java :57)
> > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > > PhaseInterceptorChain.java:207)
> > > > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java
> > > > :395) at
> > >
> > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.hand
> > >leResponse (
> > >
> > > > HTTPConduit.java:1959)
> > > > at
> > >
> > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.clos
> > >e(
> > >
> > > > HTTPConduit.java:1806)
> > > > at org.apache.cxf.transport.AbstractConduit.close(
> > >
> > > AbstractConduit.java
> > >
> > > > :66)
> > > >
> > > > at org.apache.cxf.transport.http.HTTPConduit.close
> > > > (HTTPConduit.java
> > > >
> > > :574)
> > > :
> > > > at
> > >
> > > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderE
> > >ndingInterceptor.handleMessage
> > >
> > > > (MessageSenderInterceptor.java:62)
> > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > > > PhaseInterceptorChain.java:207)
> > > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java
> > > > :254) at
> > > > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
> > > > at org.apache.cxf.frontend.ClientProxy.invokeSync
> > > > (ClientProxy.java
> > > >
> > > :73)
> > > :
> > > > at
> > > > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.ja
> > > >va
> > > >
> > > > :135)
> > > >
> > > > ... 7 more
> > >
> > > --
> > > Dan Diephouse
> > > Envoi Solutions
> > > http://envoisolutions.com | http://netzooid.com/blog
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog
Re: Handle exceptions on the client side
Posted by Dan Diephouse <da...@envoisolutions.com>.
I don't quite see the issue yet... What happens you you try it in wrapped
mode instead of rpc/literal?
- Dan
On 8/17/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
>
> Hi there ,
> Any hints for solving this problem ?
> Thanks in advance ,
> Stefan
>
>
> On 8/16/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> >
> > Hi Dan ,
> > I will attach all the configurations files . They are actually the
> same
> > with the examples files .
> > what else can I verify ?
> > Thanks in advance .
> > Stefan
> >
> >
> > On 8/15/07, Dan Diephouse <da...@envoisolutions.com> wrote:
> > >
> > > Hi Stefan,
> > > What does your server/client xml look like? Your code looks correct to
> > > me.
> > >
> > > - Dan
> > >
> > > On 8/15/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> > > >
> > > > Hi there ,
> > > > I had a problem with handling exception on the client side .
> > > Please
> > > > someone can help me with this issue ?
> > > > I used the latest release 2.0.1 . Using the samples I made a
> structure
> > > > similar with
> "distribution/src/main/release/samples/spring_http" but
> > > I want
> > > > that a method from a server to throw an exception that will be catch
> > > on the
> > > > client side . What can be wrong ? What should I do , to be able to
> > > manage
> > > > exceptions correctly ? I will attach also the wsdl generated file
> > > > Thanks in advance ,
> > > > Stefan
> > > >
> > > > So I added something like this :
> > > >
> > > > package demo.spring.util;
> > > >
> > > > import javax.xml.ws.WebFault;
> > > >
> > > > @WebFault(name="BookNotFoundFault")
> > > > public class BookNotFoundFault extends Exception {
> > > > private BookNotFoundDetails details;
> > > >
> > > > public BookNotFoundFault(BookNotFoundDetails details) {
> > > > super();
> > > > this.details = details;
> > > > }
> > > >
> > > > public BookNotFoundDetails getFaultInfo() {
> > > > return details;
> > > > }
> > > >
> > > > }
> > > >
> > > > package demo.spring.util;
> > > >
> > > > import javax.xml.bind.annotation.XmlRootElement;
> > > >
> > > > @XmlRootElement(name="BookNotFoundDetails" )
> > > > public class BookNotFoundDetails {
> > > > private long id;
> > > >
> > > > public long getId() {
> > > > return id;
> > > > }
> > > >
> > > > public void setId(long id) {
> > > > this.id = id;
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > package demo.spring;
> > > >
> > > > import demo.spring.util.BookNotFoundFault;
> > > >
> > > > import javax.jws.WebService ;
> > > > import javax.jws.soap.SOAPBinding;
> > > >
> > > > @WebService
> > > > @SOAPBinding(style= SOAPBinding.Style.RPC, use=
> > > SOAPBinding.Use.LITERAL)
> > > > public interface HelloWorld {
> > > > String sayHi(String text);
> > > >
> > > > public String testEx() throws BookNotFoundFault;
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > on the server ;
> > > >
> > > > public String testEx() throws BookNotFoundFault {
> > > > BookNotFoundDetails details = new BookNotFoundDetails();
> > > > details.setId(100);
> > > > throw new BookNotFoundFault(details);
> > > > }
> > > >
> > > >
> > > > and on the client side :
> > > >
> > > >
> > > > // START SNIPPET: client
> > > > ClassPathXmlApplicationContext context
> > > > = new ClassPathXmlApplicationContext(new String[]
> > > > {"demo/spring/client/client-beans.xml"});
> > > >
> > > > HelloWorld client = (HelloWorld)context.getBean("client");
> > > >
> > > > try {
> > > > client.testEx();
> > > > } catch (BookNotFoundFault bookNotFoundFault) {
> > > > System.out.println
> (">>>>>>>>>>>"+bookNotFoundFault.getFaultInfo().getId());
> > >
> > > >
> > > > bookNotFoundFault.printStackTrace();
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > the client-beans.xml and beans.xml are the same with samples
> provided
> > > with
> > > > the release .
> > > >
> > > > when executing the client code the following exception is throw :
> > > >
> > > > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException:
> Fault
> > > > occurred while processing.
> > > > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(
> JaxWsClientProxy.java
> > > > :169)
> > > > at $Proxy23.testEx(Unknown Source)
> > > > at demo.spring.client.Client.main(Client.java:47)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke(
> > > > NativeMethodAccessorImpl.java:39)
> > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke (
> > > > DelegatingMethodAccessorImpl.java:25)
> > > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > > at com.intellij.rt.execution.application.AppMain.main(AppMain.java
> > > :90)
> > > > Caused by: org.apache.cxf.binding.soap.SoapFault : Fault occurred
> > > while
> > > > processing.
> > > > at
> > > >
> > >
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
> > > > (Soap11FaultInInterceptor.java:69)
> > > > at
> > > >
> > >
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
> (
> > > > Soap11FaultInInterceptor.java:36)
> > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > > PhaseInterceptorChain.java:207)
> > > > at
> > > >
> > >
> org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(
> > > > AbstractFaultChainInitiatorObserver.java :90)
> > > > at
> > > >
> > >
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> > > > (ReadHeadersInterceptor.java:181)
> > > > at
> > > >
> > >
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> > > > (ReadHeadersInterceptor.java :57)
> > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > > PhaseInterceptorChain.java:207)
> > > > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:395)
> > > > at
> > > >
> > >
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse
> > > (
> > > > HTTPConduit.java:1959)
> > > > at
> > > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
> > > > HTTPConduit.java:1806)
> > > > at org.apache.cxf.transport.AbstractConduit.close(
> > > AbstractConduit.java
> > > > :66)
> > > > at org.apache.cxf.transport.http.HTTPConduit.close (
> HTTPConduit.java
> > > :574)
> > > > at
> > > >
> > >
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
> > > > (MessageSenderInterceptor.java:62)
> > > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > > > PhaseInterceptorChain.java:207)
> > > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java :254)
> > > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
> > > > at org.apache.cxf.frontend.ClientProxy.invokeSync (ClientProxy.java
> > > :73)
> > > > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(
> JaxWsClientProxy.java
> > > > :135)
> > > > ... 7 more
> > > >
> > > >
> > >
> > >
> > > --
> > > Dan Diephouse
> > > Envoi Solutions
> > > http://envoisolutions.com | http://netzooid.com/blog
> > >
> >
> >
> >
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog
Re: Handle exceptions on the client side
Posted by Stefan Alexandrescu <ab...@gmail.com>.
Hi there ,
Any hints for solving this problem ?
Thanks in advance ,
Stefan
On 8/16/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
>
> Hi Dan ,
> I will attach all the configurations files . They are actually the same
> with the examples files .
> what else can I verify ?
> Thanks in advance .
> Stefan
>
>
> On 8/15/07, Dan Diephouse <da...@envoisolutions.com> wrote:
> >
> > Hi Stefan,
> > What does your server/client xml look like? Your code looks correct to
> > me.
> >
> > - Dan
> >
> > On 8/15/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> > >
> > > Hi there ,
> > > I had a problem with handling exception on the client side .
> > Please
> > > someone can help me with this issue ?
> > > I used the latest release 2.0.1 . Using the samples I made a structure
> > > similar with "distribution/src/main/release/samples/spring_http" but
> > I want
> > > that a method from a server to throw an exception that will be catch
> > on the
> > > client side . What can be wrong ? What should I do , to be able to
> > manage
> > > exceptions correctly ? I will attach also the wsdl generated file
> > > Thanks in advance ,
> > > Stefan
> > >
> > > So I added something like this :
> > >
> > > package demo.spring.util;
> > >
> > > import javax.xml.ws.WebFault;
> > >
> > > @WebFault(name="BookNotFoundFault")
> > > public class BookNotFoundFault extends Exception {
> > > private BookNotFoundDetails details;
> > >
> > > public BookNotFoundFault(BookNotFoundDetails details) {
> > > super();
> > > this.details = details;
> > > }
> > >
> > > public BookNotFoundDetails getFaultInfo() {
> > > return details;
> > > }
> > >
> > > }
> > >
> > > package demo.spring.util;
> > >
> > > import javax.xml.bind.annotation.XmlRootElement;
> > >
> > > @XmlRootElement(name="BookNotFoundDetails" )
> > > public class BookNotFoundDetails {
> > > private long id;
> > >
> > > public long getId() {
> > > return id;
> > > }
> > >
> > > public void setId(long id) {
> > > this.id = id;
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > package demo.spring;
> > >
> > > import demo.spring.util.BookNotFoundFault;
> > >
> > > import javax.jws.WebService ;
> > > import javax.jws.soap.SOAPBinding;
> > >
> > > @WebService
> > > @SOAPBinding(style= SOAPBinding.Style.RPC, use=
> > SOAPBinding.Use.LITERAL)
> > > public interface HelloWorld {
> > > String sayHi(String text);
> > >
> > > public String testEx() throws BookNotFoundFault;
> > >
> > > }
> > >
> > >
> > >
> > > on the server ;
> > >
> > > public String testEx() throws BookNotFoundFault {
> > > BookNotFoundDetails details = new BookNotFoundDetails();
> > > details.setId(100);
> > > throw new BookNotFoundFault(details);
> > > }
> > >
> > >
> > > and on the client side :
> > >
> > >
> > > // START SNIPPET: client
> > > ClassPathXmlApplicationContext context
> > > = new ClassPathXmlApplicationContext(new String[]
> > > {"demo/spring/client/client-beans.xml"});
> > >
> > > HelloWorld client = (HelloWorld)context.getBean("client");
> > >
> > > try {
> > > client.testEx();
> > > } catch (BookNotFoundFault bookNotFoundFault) {
> > > System.out.println(">>>>>>>>>>>"+bookNotFoundFault.getFaultInfo().getId());
> >
> > >
> > > bookNotFoundFault.printStackTrace();
> > >
> > > }
> > >
> > >
> > >
> > > the client-beans.xml and beans.xml are the same with samples provided
> > with
> > > the release .
> > >
> > > when executing the client code the following exception is throw :
> > >
> > > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault
> > > occurred while processing.
> > > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> > > :169)
> > > at $Proxy23.testEx(Unknown Source)
> > > at demo.spring.client.Client.main(Client.java:47)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke(
> > > NativeMethodAccessorImpl.java:39)
> > > at sun.reflect.DelegatingMethodAccessorImpl.invoke (
> > > DelegatingMethodAccessorImpl.java:25)
> > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > at com.intellij.rt.execution.application.AppMain.main(AppMain.java
> > :90)
> > > Caused by: org.apache.cxf.binding.soap.SoapFault : Fault occurred
> > while
> > > processing.
> > > at
> > >
> > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
> > > (Soap11FaultInInterceptor.java:69)
> > > at
> > >
> > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(
> > > Soap11FaultInInterceptor.java:36)
> > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > PhaseInterceptorChain.java:207)
> > > at
> > >
> > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(
> > > AbstractFaultChainInitiatorObserver.java :90)
> > > at
> > >
> > org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> > > (ReadHeadersInterceptor.java:181)
> > > at
> > >
> > org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> > > (ReadHeadersInterceptor.java :57)
> > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > > PhaseInterceptorChain.java:207)
> > > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java :395)
> > > at
> > >
> > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse
> > (
> > > HTTPConduit.java:1959)
> > > at
> > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
> > > HTTPConduit.java:1806)
> > > at org.apache.cxf.transport.AbstractConduit.close(
> > AbstractConduit.java
> > > :66)
> > > at org.apache.cxf.transport.http.HTTPConduit.close (HTTPConduit.java
> > :574)
> > > at
> > >
> > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
> > > (MessageSenderInterceptor.java:62)
> > > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > > PhaseInterceptorChain.java:207)
> > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java :254)
> > > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
> > > at org.apache.cxf.frontend.ClientProxy.invokeSync (ClientProxy.java
> > :73)
> > > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> > > :135)
> > > ... 7 more
> > >
> > >
> >
> >
> > --
> > Dan Diephouse
> > Envoi Solutions
> > http://envoisolutions.com | http://netzooid.com/blog
> >
>
>
>
Re: Handle exceptions on the client side
Posted by Stefan Alexandrescu <ab...@gmail.com>.
Hi Dan ,
I will attach all the configurations files . They are actually the same
with the examples files .
what else can I verify ?
Thanks in advance .
Stefan
On 8/15/07, Dan Diephouse <da...@envoisolutions.com> wrote:
>
> Hi Stefan,
> What does your server/client xml look like? Your code looks correct to me.
>
> - Dan
>
> On 8/15/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
> >
> > Hi there ,
> > I had a problem with handling exception on the client side . Please
> > someone can help me with this issue ?
> > I used the latest release 2.0.1 . Using the samples I made a structure
> > similar with "distribution/src/main/release/samples/spring_http" but I
> want
> > that a method from a server to throw an exception that will be catch on
> the
> > client side . What can be wrong ? What should I do , to be able to
> manage
> > exceptions correctly ? I will attach also the wsdl generated file
> > Thanks in advance ,
> > Stefan
> >
> > So I added something like this :
> >
> > package demo.spring.util;
> >
> > import javax.xml.ws.WebFault;
> >
> > @WebFault(name="BookNotFoundFault")
> > public class BookNotFoundFault extends Exception {
> > private BookNotFoundDetails details;
> >
> > public BookNotFoundFault(BookNotFoundDetails details) {
> > super();
> > this.details = details;
> > }
> >
> > public BookNotFoundDetails getFaultInfo() {
> > return details;
> > }
> >
> > }
> >
> > package demo.spring.util;
> >
> > import javax.xml.bind.annotation.XmlRootElement;
> >
> > @XmlRootElement(name="BookNotFoundDetails" )
> > public class BookNotFoundDetails {
> > private long id;
> >
> > public long getId() {
> > return id;
> > }
> >
> > public void setId(long id) {
> > this.id = id;
> > }
> >
> > }
> >
> >
> >
> > package demo.spring;
> >
> > import demo.spring.util.BookNotFoundFault;
> >
> > import javax.jws.WebService;
> > import javax.jws.soap.SOAPBinding;
> >
> > @WebService
> > @SOAPBinding(style= SOAPBinding.Style.RPC, use= SOAPBinding.Use.LITERAL)
> > public interface HelloWorld {
> > String sayHi(String text);
> >
> > public String testEx() throws BookNotFoundFault;
> >
> > }
> >
> >
> >
> > on the server ;
> >
> > public String testEx() throws BookNotFoundFault {
> > BookNotFoundDetails details = new BookNotFoundDetails();
> > details.setId(100);
> > throw new BookNotFoundFault(details);
> > }
> >
> >
> > and on the client side :
> >
> >
> > // START SNIPPET: client
> > ClassPathXmlApplicationContext context
> > = new ClassPathXmlApplicationContext(new String[]
> > {"demo/spring/client/client-beans.xml"});
> >
> > HelloWorld client = (HelloWorld)context.getBean("client");
> >
> > try {
> > client.testEx();
> > } catch (BookNotFoundFault bookNotFoundFault) {
> > System.out.println
> (">>>>>>>>>>>"+bookNotFoundFault.getFaultInfo().getId());
> >
> > bookNotFoundFault.printStackTrace();
> >
> > }
> >
> >
> >
> > the client-beans.xml and beans.xml are the same with samples provided
> with
> > the release .
> >
> > when executing the client code the following exception is throw :
> >
> > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault
> > occurred while processing.
> > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> > :169)
> > at $Proxy23.testEx(Unknown Source)
> > at demo.spring.client.Client.main(Client.java:47)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:39)
> > at sun.reflect.DelegatingMethodAccessorImpl.invoke (
> > DelegatingMethodAccessorImpl.java:25)
> > at java.lang.reflect.Method.invoke(Method.java:597)
> > at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> > Caused by: org.apache.cxf.binding.soap.SoapFault : Fault occurred while
> > processing.
> > at
> >
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
> > (Soap11FaultInInterceptor.java:69)
> > at
> >
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
> (
> > Soap11FaultInInterceptor.java:36)
> > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > PhaseInterceptorChain.java:207)
> > at
> > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage
> (
> > AbstractFaultChainInitiatorObserver.java :90)
> > at
> >
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> > (ReadHeadersInterceptor.java:181)
> > at
> >
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> > (ReadHeadersInterceptor.java :57)
> > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> > PhaseInterceptorChain.java:207)
> > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:395)
> > at
> >
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse
> (
> > HTTPConduit.java:1959)
> > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
> > HTTPConduit.java:1806)
> > at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java
> > :66)
> > at org.apache.cxf.transport.http.HTTPConduit.close (HTTPConduit.java
> :574)
> > at
> >
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
> > (MessageSenderInterceptor.java:62)
> > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> > PhaseInterceptorChain.java:207)
> > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
> > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
> > at org.apache.cxf.frontend.ClientProxy.invokeSync (ClientProxy.java:73)
> > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> > :135)
> > ... 7 more
> >
> >
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
>
Re: Handle exceptions on the client side
Posted by Dan Diephouse <da...@envoisolutions.com>.
Hi Stefan,
What does your server/client xml look like? Your code looks correct to me.
- Dan
On 8/15/07, Stefan Alexandrescu <ab...@gmail.com> wrote:
>
> Hi there ,
> I had a problem with handling exception on the client side . Please
> someone can help me with this issue ?
> I used the latest release 2.0.1 . Using the samples I made a structure
> similar with "distribution/src/main/release/samples/spring_http" but I want
> that a method from a server to throw an exception that will be catch on the
> client side . What can be wrong ? What should I do , to be able to manage
> exceptions correctly ? I will attach also the wsdl generated file
> Thanks in advance ,
> Stefan
>
> So I added something like this :
>
> package demo.spring.util;
>
> import javax.xml.ws.WebFault;
>
> @WebFault(name="BookNotFoundFault")
> public class BookNotFoundFault extends Exception {
> private BookNotFoundDetails details;
>
> public BookNotFoundFault(BookNotFoundDetails details) {
> super();
> this.details = details;
> }
>
> public BookNotFoundDetails getFaultInfo() {
> return details;
> }
>
> }
>
> package demo.spring.util;
>
> import javax.xml.bind.annotation.XmlRootElement;
>
> @XmlRootElement(name="BookNotFoundDetails" )
> public class BookNotFoundDetails {
> private long id;
>
> public long getId() {
> return id;
> }
>
> public void setId(long id) {
> this.id = id;
> }
>
> }
>
>
>
> package demo.spring;
>
> import demo.spring.util.BookNotFoundFault;
>
> import javax.jws.WebService;
> import javax.jws.soap.SOAPBinding;
>
> @WebService
> @SOAPBinding(style= SOAPBinding.Style.RPC, use= SOAPBinding.Use.LITERAL)
> public interface HelloWorld {
> String sayHi(String text);
>
> public String testEx() throws BookNotFoundFault;
>
> }
>
>
>
> on the server ;
>
> public String testEx() throws BookNotFoundFault {
> BookNotFoundDetails details = new BookNotFoundDetails();
> details.setId(100);
> throw new BookNotFoundFault(details);
> }
>
>
> and on the client side :
>
>
> // START SNIPPET: client
> ClassPathXmlApplicationContext context
> = new ClassPathXmlApplicationContext(new String[]
> {"demo/spring/client/client-beans.xml"});
>
> HelloWorld client = (HelloWorld)context.getBean("client");
>
> try {
> client.testEx();
> } catch (BookNotFoundFault bookNotFoundFault) {
> System.out.println(">>>>>>>>>>>"+bookNotFoundFault.getFaultInfo().getId());
>
> bookNotFoundFault.printStackTrace();
>
> }
>
>
>
> the client-beans.xml and beans.xml are the same with samples provided with
> the release .
>
> when executing the client code the following exception is throw :
>
> Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault
> occurred while processing.
> at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> :169)
> at $Proxy23.testEx(Unknown Source)
> at demo.spring.client.Client.main(Client.java:47)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke (
> DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> Caused by: org.apache.cxf.binding.soap.SoapFault : Fault occurred while
> processing.
> at
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage
> (Soap11FaultInInterceptor.java:69)
> at
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(
> Soap11FaultInInterceptor.java:36)
> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:207)
> at
> org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(
> AbstractFaultChainInitiatorObserver.java :90)
> at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> (ReadHeadersInterceptor.java:181)
> at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> (ReadHeadersInterceptor.java :57)
> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:207)
> at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:395)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(
> HTTPConduit.java:1959)
> at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
> HTTPConduit.java:1806)
> at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java
> :66)
> at org.apache.cxf.transport.http.HTTPConduit.close (HTTPConduit.java:574)
> at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
> (MessageSenderInterceptor.java:62)
> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (
> PhaseInterceptorChain.java:207)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
> at org.apache.cxf.frontend.ClientProxy.invokeSync (ClientProxy.java:73)
> at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java
> :135)
> ... 7 more
>
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog