Hi;
A nice new feature in IceBreak WebSerices is to monitor for exeptions and forward the exeptions to the SOAP client:
Consider the following IceBreak service "divide":
<%@ language="RPGLE" pgmtype="webservice" %><%
h NOMAIN
p divide...
p B export
d PI
d number 10u 0 input
d by 10u 0 input
d chars 5 input
d result 10u 0 output
/free
setCharset('UTF-8');
result = %INT(chars) + number / by;
/end-free
P E
%>This code is rather error prone – What happens if the parameter "by" is set to zero or the "chars" were set to alphanumeric?
You would receive a "MCH1211 – Try to device by zero" or "Invalid data for numeric fields" - and this is exactly what the Client will experience now in the new IceBreak version.
The beauty is that IceBreak now support the SOAP-Fault so any error are forwarded to the client and the client code can do a "try" / "catch" around the exception:
Take a look at the following Java code (Notice the red error in the "run" tab):
See screen shot 1
Likewise in C# you will see the following (Notice the "e" exception object):
See screen shot 2
So what do I need to do to use this new feature: Just download the new IceBreak version BUILD0378 and recompiled your SOAP services.
Best regards,
Niels Liisberg
Re: Better SOAP support
Thanks for the input, Niels!
Trigger an error
Can we trigger an error like this manually?
For example if we are screen scraping and we can't find the screen we need (for an unknown reason) could we throw an error so that the soap client receives an exception?
Thanks,
Craig
RE: Trigger an error
Craig,
You can use SetStatus() to set the HTTP status code on the response:
The client will receive the error status and any text in the response can describe the error.
Regards,
David.