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
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.
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
posted
0
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.
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.
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.
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.
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).
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).