You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Rob Barrett <ba...@gmail.com> on 2008/02/06 22:50:49 UTC

soap fault question

Does anyone have an example of how to create a soap:fault from a
custom exception thrown by a JAX-WS service?

Cheers, Rob

Re: soap fault question

Posted by Daniel Kulp <dk...@apache.org>.
This should be fixed in the latest 2.0.6/2.1 snapshots.    If you could 
give it a quick test as a double check before I do final builds 
tomorrow, that would be GREAT.
http://people.apache.org/repo/m2-snapshot-repository/org/apache/cxf/apache-cxf/2.0.6-SNAPSHOT/
http://people.apache.org/repo/m2-snapshot-repository/org/apache/cxf/apache-cxf/2.1-SNAPSHOT/

Thanks!
Dan


On Tuesday 22 April 2008, sadhu wrote:
> David Castañeda wrote:
> > Hi, I'm still fighting with fault generation... can anybody give me
> > a pointer where to get some examples or some information about this?
> >
> > in a service that I'm exposing, I'm trying to do
> >
> >         SoapFault fault = new SoapFault(message,
> > SoapFault.FAULT_CODE_CLIENT);
> >         throw fault;
> >
> > but it always end in ...
> >
> > <soap:Envelope
> > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>
> >       <soap:Fault>
> >          <faultcode>soap:Server</faultcode>
> >          <faultstring>Message is OK</faultstring>
> >       </soap:Fault>
> >    </soap:Body>
> > </soap:Envelope>
> >
> > I'm expecting to produce a Client Fault but soap:Server is returned.
> >
> > I'm using a jaxws:endpoint
> >
> >
> > --
> > David Castañeda R.
>
> hey David .
> Did u get the solution...
> please if so post me the details also..
> i'm also struggling to solve this issues..
>
> Thanks in advance
>
>
> Regards
>
> Suzane



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: soap fault question

Posted by sadhu <sa...@gmail.com>.


David Castañeda wrote:
> 
> Hi, I'm still fighting with fault generation... can anybody give me a
> pointer where to get some examples or some information about this?
> 
> in a service that I'm exposing, I'm trying to do
> 
>         SoapFault fault = new SoapFault(message,
> SoapFault.FAULT_CODE_CLIENT);
>         throw fault;
> 
> but it always end in ...
> 
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Body>
>       <soap:Fault>
>          <faultcode>soap:Server</faultcode>
>          <faultstring>Message is OK</faultstring>
>       </soap:Fault>
>    </soap:Body>
> </soap:Envelope>
> 
> I'm expecting to produce a Client Fault but soap:Server is returned.
> 
> I'm using a jaxws:endpoint
> 
> 
> -- 
> David Castañeda R.
> 
> 



hey David .
Did u get the solution...
please if so post me the details also..
i'm also struggling to solve this issues..

Thanks in advance


Regards

Suzane
-- 
View this message in context: http://www.nabble.com/soap-fault-question-tp15322565p16825635.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: soap fault question

Posted by David Castañeda <da...@gmail.com>.
Hi, I'm still fighting with fault generation... can anybody give me a
pointer where to get some examples or some information about this?

in a service that I'm exposing, I'm trying to do

        SoapFault fault = new SoapFault(message, SoapFault.FAULT_CODE_CLIENT);
        throw fault;

but it always end in ...

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Message is OK</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

I'm expecting to produce a Client Fault but soap:Server is returned.

I'm using a jaxws:endpoint


-- 
David Castañeda R.

Re: soap fault question

Posted by David Castañeda <da...@gmail.com>.
Ready to go!...

https://issues.apache.org/jira/browse/CXF-1434

hope this help, any further help I can provide don't hesitate in asking.

-- 
David Castañeda R.

Re: soap fault question

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 13 February 2008, David Castañeda wrote:
> In a previous thread some ask for other samples projects ideas...
>
> what are the possibilities of adding a sample of fault handling (Soap
> Fault Handling, @WebFault....).
>
> I have been trying for long to implement correct fault handling, but
> :(, or maybe some more explicit documentation.. so I can create that
> sample project. If any body want me to do it... I could create a first
> template so any body with the knowledge would provide the exception
> handling missing parts.

That's a great idea!  Feel free to create a "Better Fault handling demo" 
JIRA item and start attaching things to it.   

This is good for a couple reasons:
1) It will help get you the information that you need to get your project 
working.

2) It will show us how users are expecting it to work, and not succeeding 
so hopefully we can make it work. 


-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: soap fault question

Posted by David Castañeda <da...@gmail.com>.
In a previous thread some ask for other samples projects ideas...

what are the possibilities of adding a sample of fault handling (Soap Fault
Handling, @WebFault....).

I have been trying for long to implement correct fault handling, but :(, or
maybe some more explicit documentation.. so I can create that sample
project. If any body want me to do it... I could create a first template so
any body with the knowledge would provide the exception handling missing
parts.


regards,

-- 
David Castañeda R.

Re: soap fault question

Posted by Daniel Kulp <dk...@apache.org>.
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 <gl...@verizon.net> 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 <gl...@verizon.net> 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
dkulp@apache.org
http://www.dankulp.com/blog

Re: soap fault question

Posted by Rob Barrett <ba...@gmail.com>.
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 <gl...@verizon.net> 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 <gl...@verizon.net> 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
> > >
> > >
>
>

Re: soap fault question

Posted by Glen Mazza <gl...@verizon.net>.
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 <gl...@verizon.net> 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
> >
> >


Re: soap fault question

Posted by Rob Barrett <ba...@gmail.com>.
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 <gl...@verizon.net> 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
>
>

Re: soap fault question

Posted by Glen Mazza <gl...@verizon.net>.
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