SOAP features / SOAP Fault |
A Genero Web Services server can throw a SOAP fault if any processing error is encountered.
To generate a SOAP fault you need to:
For example in $FGLDIR/demo/WebServices/calculator/server/calculatorServer.4gl, the calculator server has a divide_by_zero SOAP fault. The SOAP fault is raised when you try to divide a number by zero. To generate a SOAP fault proceed as follow:
DEFINE divide_by_zero STRING ATTRIBUTES (XMLName="DividedByZero")
LET serv = com.WebService.CreateWebService("Calculator",serviceNS) CALL serv.createFault(divide_by_zero,FALSE)
LET op = com.WebOperation.CreateRPCStyle("divide","Divide",divide_in,divide_out) CALL op.addFault(divide_by_zero,NULL)
Here, the SOAP fault is added to the "divide" operation.
LET divide_by_zero = "Cannot divide "||divide_in.a||" by zero" CALL com.WebServiceEngine.SetFaultDetail(divide_by_zero)