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 PBSoapClient190.pbx and PBWSClient190.pbx can also throw SoapException.

Properties

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 type RuntimeError

SetMessage

-

Sets an error message for an object of type RuntimeError


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.

string s1,s2
s1 = "abcd"
SoapConnection conn
long ret
ServiceProxy proxy

//ServiceProxy is a proxy generated by Web service 
//wizard
try
   conn = create SoapConnection
   ret = conn.CreateInstance(proxy, "ServiceProxy")
   if (ret <> 0)then
      MessageBox("Fail", "Cannot create proxy " &
        + "ServiceProxy")
      return
   end if
   s2 = proxy.EchoString(s1)
   MessageBox("Successful", "The return string is '" &
      +  s2 + "'")
catch (SoapException e1)
   MessageBox("Fail", "Can’t invoke service 'EchoString'")   
catch (PBXRuntimeError e2)
   MessageBox("Fail", "There is a runtime error when" &
      + "invoking Web service")
catch (RuntimeError e3)
   MessageBox("Fail", "There is an unknown error when"&
       + "invoking Web service")
end try

See also

GetMessage in the section called “GetMessage” in PowerScript Reference

RuntimeError object in the section called “RuntimeError object” in Objects and Controls

SetMessage in the section called “SetMessage” in PowerScript Reference