Rob,

The JAX-WS spec covers this fairly extensively.   You might want to read 
through section of 3.7 of the JAX-WS spec:
https://jax-ws.dev.java.net/spec-download.html

Basically, there are three ways to deal with "Service Specific 
Exceptions" (as the spec calls them):

1) Very low level: throw a SOAPFaultException
This is the most conrollable from an exception standpoint as you control 
exactly what it looks like on the wire.   However, this won't appear in 
the wsdl/xsd at all.   It also sucks from a programmer standpoint (IMO) 
as you pretty much have to deal with all the XML stuff yourself.  Not 
fun.   I don't recommend it.   

2) JAX-WS "mimic the generated code" method:  You define the data you 
want returned to the client in it's own JAXB bean (not a subclass of 
Exception) and annotate it just like you would any other JAXB bean.   
Your exception would then just have one method:
MyFaultDetail getFaultInfo()
and a constructor like:
MyException(String message, MyFaultDetail faultInfo) {...}
You would also need to add a @WebFault annotation, but the defaults for 
everything should be OK with that.

3) JAX-WS mapping:  If you put getter/setter things for each data element 
you want returned, we just create a simple sequence for it and use it.  
Nothing elaborate and not much can be done to customize the WSDL/XSD.

In case 3, the RI requires that you run the wsgen stuff to create special 
JAXB bean objects for the exceptions that the runtime then uses by 
copying data to/from the exception to the bean.   CXF doesn't require 
that.  We'll work with the exception directly.

Basically, if you need to control how things appear in the wsdl/xsd, 
option 2 is really the best bet.   It's really  just defining a type to 
put in the schema just like you would any other jaxb type.

Dan




On Thursday 07 February 2008, Rob Barrett wrote:
> To clarify, I'm looking for an example of a soap:fault from a custom
> exception thrown by a Java service published using a  <jaxws:endpoint
> /> entry.
>
> I'm particularly interested in how to annotate the exception and how
> the annotations affect the resulting wsdl/xsd representation,
>
> I also wouldn't mind knowing if there are specific base classes that
> are intended for extension - e.g. SoapFault - or if they are just
> meant to wrap custom exception content.
>
> The cxf doco in this area seems a bit light.
>
> Cheers, Rob
>
> On Feb 7, 2008 2:51 PM, Glen Mazza <[EMAIL PROTECTED]> wrote:
> > I didn't need to annotate them, my example was WSDL-first. 
> > wsdl2java creates Java objects corresponding to those exceptions,
> > now whether it adds annotations within those objects, I didn't
> > bother to check, it doesn't matter for me.
> >
> > If you are doing Java-first, maybe the @WebFault annotation will
> > help you.  Google or wait for someone here more knowledgeable.  I
> > don't know much about that annotation.
> >
> > Glen
> >
> > Am Donnerstag, den 07.02.2008, 14:20 +1000 schrieb Rob Barrett:
> > > Thanks Glen.
> > >
> > > How did you annotate these exceptions?
> > >
> > > import org.example.wordlookup.BasicFault;
> > > import org.example.wordlookup.EntryAlreadyExistsFault;
> > > import org.example.wordlookup.EntryNotFoundFault;
> > >
> > >
> > > Cheers, Rob
> > >
> > > On Feb 7, 2008 1:11 PM, Glen Mazza <[EMAIL PROTECTED]> wrote:
> > > > http://www.jroller.com/gmazza/date/20071019 ?  Check steps #4,
> > > > #6, and #10, for the WSDL, service, and client, respectively.
> > > >
> > > > HTH,
> > > > Glen
> > > >
> > > > Am Donnerstag, den 07.02.2008, 07:50 +1000 schrieb Rob Barrett:
> > > > > Does anyone have an example of how to create a soap:fault from
> > > > > a custom exception thrown by a JAX-WS service?
> > > > >
> > > > > Cheers, Rob



-- 
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog

Reply via email to