Catching a non-SOAP exception error condition

In this sample you will use a regular expression to search for a particular pattern in the return value of a Web method call. The Web method will be used as a target and will simulate adding Orders to a system.

There are two business rules enforced by the Web Method:

If both of those conditions are met, the method will return an XML message indicating success. If one of those conditions is not met, the method will return an XML message indicating failure. Note that this Web Method, unlike the Logon method, does not throw an exception, but returns a string indicating pass/fail.

A sample ReturnValue would look like the following if neither rule was successful (assuming the OrderID is '1'):

<Results OrderID="1" Status="Failed">

<ValidationError Rule="Invalid CustomerId">CustomerID not recognized.</ValidationError>

ValidationError Rule="Invalid Tax Rate">The Tax Rate must be greater than 0.</ValidationError>

</Results>

Notice that each invalid rule is listed as its own ValidationError node.

The Status attribute equals either Passed or Failed. For our example, we are going to look for the Status equal to Failed and, if that is true, fail the target operation.

Note: Although the target operation fails, the Adapter for Web Services does not roll back anything. Therefore, it is possible for the Web method in question to be working while the target operation fails.

Example

  1. In the Scribe Workbench, click View > Connections. The Connection Manager appears.
  2. Click New. The Add a Connection dialog box appears.
  3. Expand Adapters.
  4. Click Web Services.
  5. Click OK. The Web Services Connection Manager dialog box appears.
  6. Select the Web Service connection to the Scribe Sample Web Service that you created in the Connecting to a Web Service as a source example.
  7. Click Edit and click the Configuration tab.
  8. In the Methods list, select the SaveOrder method, and then select the ReturnValue parameter.

    Note: In this example, the ReturnValue is an XML document similar to the above example. You assign a regular expression with this parameter.

  9. In the Value box, enter %ReturnValue .
  10. In the Failure Condition box enter Status="Failed". Be sure to include the quotes.
  11. Click Save. You return to the Web Services Connection Manager dialog box.
  12. Select the Web Service connection you just edited and click Connect. The Login To Web Service Window appears.
  13. Click OK. The Connection Settings dialog box appears.
  14. Click OK. The Connection Manager
  15. On the Connection Manager, click Close.

run a DTS file to catch the non-SOAP exception

  1. In the Scribe Workbench, on the Target menu, click Configure Steps. The Configure Steps dialog box appears.
  2. From the drop-down list of connections, select the connection that represents the Web Service.
  3. Expand Adapter Objects and select SaveOrder.
  4. Click Add Execute Step.
  5. Click Close. The Configure Steps window closes.
  6. Set up a connection to the Scribe Sample database and configure it as your source, using ORDER_HEADER as the source table.
  7. Create the following mappings:
  8. Save and run the DTS file.

    All rows display as having failed the target operation. The Transaction ErrorsReport indicates the failure occurred because the ReturnValue satisfied the regular expression we supplied.

  9. Do the following mappings to resolve the error:
    1. Modify the formula on the Ord_CustomerID target field to use a static value of "CUST001".
    2. Modify the formula on the Ord_TaxRate target field to use a number greater than 0.

Note: With these values, no validation errors occur and the XML returned has Status="Passed", whici does not satisfy the regular expression we have defined above.

See Also

Catching unique exceptions

Using a Web Service as a target