A WSDL file can contain a fault element for an operation and a message attribute that contains the fault message. Accordingly, when designing a SOAP Web service in MapForce, you can add a "Fault" component to your mapping. This will cause the Web service to throw an exception if a certain condition is satisfied.
To insert a Fault component in a mapping, a fault element must be present in the WSDL file.
You can define the failure condition inside the mapping, and you can also set the text of the error message. When the condition is satisfied, the Web service will fail as follows:
|•||In a live environment (at execution time, after the Web service is deployed to a server), the Web service will fail and return the custom-defined message to the caller.|
|•||In MapForce (at design time), the mapping execution stops, and you can view the message in the Message window.|
To add a fault component to a MapForce mapping:
|1.||On the Insert menu, click Exception. (Alternatively, click the Exception toolbar button.)|
|2.||Select Create WSDL-fault.|
|Note:||If the Create WSDL-fault option is disabled and you see the message "No faults for this operation", this means that no faults exist in the WSDL file, and, consequently, none can be added in MapForce.|
For an example of a mapping which contains a Web service fault, open the following sample MapForce project: <Documents>\Altova\MapForce2019\MapForceExamples\TimeService\TimeService.mfp. Double-click the mapping (operation) getTimeZoneTime.mfd.
In the mapping above, the exception should be triggered when n0:timezone is not equal to UTC.
|•||The equal function checks to see if timezone equals UTC, with the bool result being passed on to the filter.|
|•||If the condition is false, i.e. something other than UTC, the on-false parameter of the filter activates the Fault:errorSoapOut exception and the mapping process is halted. (Note that you can also connect the exception to the on-true parameter, if that is what you need.)|
|•||Two sets of error text are supplied by the SoapFault message.|
It is very important to note the filter placement in the example:
© 2019 Altova GmbH