SoapException
Description
The SoapException class is a PBNI class that inherits from
the PowerBuilder RuntimeError class. When an exception occurs in
a Web service method call, it is converted into a SoapException
and thrown. The methods of the classes in PBSoapClient126.pbx and PBWSClient126.pbx can
also throw SoapException.
Exception property |
Data type |
Description |
---|---|---|
Text |
String |
Contains the text of the error message |
Methods
The following table defines methods inherited by a SoapException
object from the RuntimeError class.
Exception method |
Data type returned |
Description |
---|---|---|
GetMessage |
String |
Returns the error message from objects of |
SetMessage |
— |
Sets an error message for an object of type |
Usage
The following example demonstrates how to use the SoapException
class. The ServiceProxy fails to be invoked and returns the error
message. The code has three catch clauses: for SoapException, PBXRuntimeError,
and RuntimeError. PBXRuntimeError is an exception class that inherits
from RuntimeError and is thrown when a PowerBuilder extension raises
an error that is not caught by the extension.
1 |
string s1,s2<br>s1 = "abcd"<br>SoapConnection conn<br>long ret<br>ServiceProxy proxy<br> <br>//ServiceProxy is a proxy generated by Web service //wizard<br>try<br>   conn = create SoapConnection<br>   ret = conn.CreateInstance(proxy, "ServiceProxy")<br>   if (ret <> 0)then<br>      MessageBox("Fail", "Cannot create proxy " &<br>        + "ServiceProxy")<br>      return<br>   end if<br>   s2 = proxy.EchoString(s1)<br>   MessageBox("Successful", "The return string is '" &<br>      +  s2 + "'")<br>catch (SoapException e1)<br>   MessageBox("Fail", "Can't invoke service 'EchoString'") <br>catch (PBXRuntimeError e2)<br>   MessageBox("Fail", "There is a runtime error when" &<br>      + "invoking Web service")<br>catch (RuntimeError e3)<br>   MessageBox("Fail", "There is an unknown error when"&       + "invoking Web service")<br>end try |
See Also
-
GetMessage in
the PowerScript Reference -
RuntimeError object in Objects and Controls
-
SetMessage in the PowerScript
Reference