aspose file tools*
The moose likes Web Services and the fly likes SOAPFault Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAPFault" Watch "SOAPFault" New topic
Author

SOAPFault

JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Is is specified somewhere (Spec, WS-I BP, or whatever) that a Web Service MUST return a SOAPFault when an error occurs, even if this error is due to some business process (ex : the ID of a business method is 789 while a business rule requires IDs < 123)


/ JeanLouis<br /><i>"software development has been, is, and will remain fundamentally hard" (Grady Booch)</i><br /> <br />Take a look at <a href="http://www.epfwiki.net/wikis/openup/" target="_blank" rel="nofollow">Agile OpenUP</a> in the Eclipse community
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I don't know what the "high-level" specifications say about this kind of details, but I believe the applications should be allowed to process errors as errors and exceptions as exceptions. In other words, I'm pretty confident that SOAPFault is not required for application-level validation errors.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Thanks Lasse.
What do you think about always returning SOAPFaults ?
I mean, a SOAPFault when a real error occurs, and business XML message contained in a SOAPFault (Element detail) when a business error occurs
[ April 01, 2004: Message edited by: Jean-Louis Marechaux ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Jean-Louis Marechaux:
What do you think about always returning SOAPFaults ?
I mean, a SOAPFault when a real error occurs, and business XML message contained in a SOAPFault (Element detail) when a business error occurs
Well, I'd have to see the two alternatives side-by-side since the difference here is mostly a matter of taste regarding how the error handling code is structured. In general, I'd probably be happy with either approach.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I have a question, how do I send SOAP fault message from the web service? Do I need to throw an exception so that it gets propagated as SOAP fault message? Can some one give me code sameple to send SOAP fault message.


Groovy
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I've done that once with SAAJ (I think) by simply creating an envelope object, calling addFault(mySoapFaul) on it (after first creating the SOAPFault object, of course), and sending the response envelope as usual.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Is it possible to translate the SOAP fault message to a specific Exception at the client?
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Pradeep Bhat:
I have a question, how do I send SOAP fault message from the web service? Do I need to throw an exception so that it gets propagated as SOAP fault message? Can some one give me code sameple to send SOAP fault message.


An example is available here http://cvs.apache.org/viewcvs.cgi/ws-axis/java/samples/faults/ for apache axis, which you can re-use for other implementations as well.


Spritle Software Blogs
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Pradeep Bhat:
Is it possible to translate the SOAP fault message to a specific Exception at the client?
I don't know whether there's a standard way of mapping SOAPFaults to exception classes, but the specification certainly makes it possible (the fault element in SOAP allows using custom "details" of which namespace/element name could be mapped to a Java exception class, for example).
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Balaji Loganathan:


An example is available here http://cvs.apache.org/viewcvs.cgi/ws-axis/java/samples/faults/ for apache axis, which you can re-use for other implementations as well.

Balaji
The link does not work for me.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

The link is now working fine.
How is the operation tag in deploy.wsdd different from the one in WSDL file
http://cvs.apache.org/viewcvs.cgi/ws-axis/java/samples/faults/deploy.wsdd?rev=1.1&view=markup
[ April 05, 2004: Message edited by: Pradeep Bhat ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Lasse Koskela:
I don't know whether there's a standard way of mapping SOAPFaults to exception classes, but the specification certainly makes it possible (the fault element in SOAP allows using custom "details" of which namespace/element name could be mapped to a Java exception class, for example).

Thanks Lasse!
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Why does the SOAP fault message have only one part?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Pradeep Bhat:
Why does the SOAP fault message have only one part?
My guess would be that the team who created the specification didn't think it would be necessary to allow such flexibility for SOAP faults...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SOAPFault