Skip to main content

Trapping a SOAP Fault on the Web Service Client

Web Service client code must be prepared to handle SOAP faults returned by Web Service producers. Caché Web Service clients can use standard Caché error trapping techniques.

Add the following method to your ContactApplication.SOAPServiceSoap. The method uses Caché error trapping to handle any SOAP faults returned by the SOAPTutorial.SOAPService GetContact method.


ClassMethod Demo(id As %Integer)
{
 Try{
  set service = ##class(ContactApplication.SOAPServiceSoap).%New()
  set person = service.GetContact(id)
  write person.Name
 }
 Catch ex {
  if service.SoapFault '=""{
    write service.SoapFault.AsString()
  }
  else{
    do $System.Status.DisplayError(ex.AsStatus())
  }
 }
 quit 1
}
Note:

To learn more about Web Service error handling, read SOAP Fault Handling in Creating Web Services and Web Clients in Caché.

FeedbackOpens in a new tab