PDA

View Full Version : Locale support for faults?



res1st
Sep 21st, 2006, 05:57 AM
Hi,

if i use this method to create a fault, i can add a locale element.

soapBody().addClientOrSenderFault(myFault.getMessa ge(), Locale.ENGLISH);

But if i look into Soap1.2 spec, they support multiple reason strings with different languages:

<env:Reason>
<env:Text xml:lang="en-US">Processing error</env:Text>
<env:Text xml:lang="cs">Chyba zpracování</env:Text>
</env:Reason>
<env:Detail>...

But the javadoc of "addClientOrSenderFault" says:

Adding a fault removes the current content of the body.

This would mean, i can't add fault reasons in different languages.

Cheers,

Ingo

Arjen Poutsma
Sep 22nd, 2006, 05:42 AM
Adding a fault removes the content, but adding fault strings doesn't. So, you can add multiple message to an existing SoapFault. To do this, you must keep a reference to the SoapFault instance returned by addClientOrSenderFault. Then, you can cast this to either Soap11Fault (http://static.springframework.org/spring-ws/docs/1.0-m2/api/org/springframework/ws/soap/soap11/Soap11Fault.html), or Soap12Fault (http://static.springframework.org/spring-ws/docs/1.0-m2/api/org/springframework/ws/soap/soap12/Soap12Fault.html), and add localized messages there.

res1st
Sep 22nd, 2006, 06:12 AM
Ah,

that's good to know. :)
You are a great help.
I creating a product which will support (nearly) all european languages. Do you suggest to use the SOAP1.2 feature of lang attributes at fault reasons?
Or should i convert the error message in my application fault handler to the correct language(the preferred language of a user is stores in my database)?

Cheers,

Ingo