Simon Fell > Its just code > Fault Codes

Monday, October 4, 2004

This one has come up on the axis-users mailing list a few times recently, and as my views seem to differ from other views there, I thought I'd throw mine out here to a wider audience. A SOAP Fault consists of a fault code QName, a faultstring and a detail element which can contain arbitrary namespaced xml. JAX-RPC likes to have you map java exceptions to structures in the detail element, whilst I'm not entirely against that, I am against using it while ignore the standard stuff, its not uncommon to see soap faults like this (envelope stuff ignored for clarity).

<faultString />
  <j:message>i don't like mondays</j:message>

uggghhh, it works, but to me its pretty hideous, if your toolkit of choice doesn't support the fault elements in WSDL and/or map the faults back to exceptions (say .NET for example), as a client programmer your left with the job of grunging around in the detail element XmlNode to get the error info, now compare it to this one.

<faultString>i don't like mondays</faultString>

Contains exactly the same amount of useful information but with the added bonus that every toolkit I've looked at will make it easy to access this info.