Example of a Customized XML Error Message

Previous Next

This example is based on Web Service Example 3: RPC-oriented method with a complex type parameter based on a domain with allowed values.

One of the inserted column values is a maximum age. The corresponding AGE domain has four allowed values. When the request message contains 36 as value for max_age, you will get an error message, because 36 is not an allowed value. The soap error message is:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<soap:Fault>

<faultcode>soap:Server</faultcode>

<faultstring>main

Value 36 in field "max_age" not an allowed value in Domain "AGE" Cannot bind input</faultstring>

<detail>main

Value 36 in field "max_age" not an allowed value in Domain "AGE" Cannot bind input</detail>

</soap:Fault>

</soap:Body>

</soap:Envelope>

 

To change this default error for a web service method, click the Advanced button in the Web Services (Provider) window, and specify the following settings:

MR_help0095

The soap error message is now:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<soap:Fault>

<faultcode>soap:Server</faultcode>

<faultstring>main

Value 36 in field "max_age" not an allowed value in Domain "AGE" Cannot bind input</faultstring>

<detail>

<ErrorResponse xmlns="http://www.usoft.com/Solutions/USoft/Product/Messages">

<Code>USDOMALLOWED</Code>

<Message>Value 36 in field "max_age" not an allowed value in Domain "AGE"</Message>

</ErrorResponse>

</detail>

</soap:Fault>

</soap:Body>

</soap:Envelope>

 

TIP: To provide a different structure for the detail element in the soap message, or to handle more errors than USoft provides by default, either change the default XSL transformation in:

<usoft installation>\xsl\ErrorHandling\userror_wsp.xsl

OR save this file under a different name (e.g. MyErrors.xsl), change the contents as required, and change the value of the XSL Error Transformation field in the Web Service Method Errors dialog to: MyErrors.xsl.

To create a different structure, change the schema definition of the Namespace with Namespace Alias:

err

by adding a new complex type or simple type in:

<usoft installation>\xsl\ErrorHandling\userror_wsp.xsd

You can also save this file under a different name, change the contents as required, and change the value of the XSL Error Element field in the Web Service Method Errors dialog.