|
Exception handling
Errors that occur in the execution of a method of a Web service are converted to SoapException objects and thrown to the calling script. The methods of all the classes in PBSoapClient90.dll can also throw SoapException objects when, for example, connection to the server failed, or the Web service could not be located or created.
异常处理
在一个Web Service的方法执行时发生的错误将被转换为SoapException对象,并在调用的脚本中抛出。在PBSoapClient90.dll中的所有类的方法都可以抛出SoapException对象。例如连接服务器失败、Web Service不能被定位或创建。
Catching exceptions
A client application can handle communications errors in a number of ways. For example, if a client connects to a server and tries to invoke a method for an object that does not exist, the client can disconnect from the server, connect to a different server, or retry the operation. Alternatively, the client can display a message to the user and give the user the opportunity to control what happens next.
When an error occurs, if the client connects to a new server to retry the operation, it must instantiate the remote object on the new server before invoking a method of the remote object.
捕获异常
一个客户端应用程序可以通过很多方法来处理通讯错误。例如,如果一个客户端连接到一台服务器并试图调用一个并不存在的对象的方法,客户端可以从那台服务器上断开连接,并连接另一台不同的服务器,或者重新尝试那个操作。做为选择,客户端可以显示一个信息给用户或者给用户控制下步发生什么的机会。
当一个错误发生时,如果客户端将连接另一台服务器并尝试重复操作,必须在调用远程对象的一个方法之前,指明新的服务器上的远程对象。
Unhandled exceptions
If no exception handler exists, or if the existing exception handlers do not handle the exception, the SystemError event on the Application object is executed. If the SystemError event has no script, an application error occurs and the application is terminated.
未处理的异常
如果异常处理不存在,或者已经存在的异常处理并不能处理那个异常,Application对象的SystemError事件将会执行。如果SystemError事件没有写任何脚本,一个应用程序错误将发生并且应用程序将被强制终止。
Invoking the Web service method
SoapConnection is used to create the Soap_proxy object and populate the Soap connection options that you set in the SetOptions method. Once a proxy object for a Web service is created, the client application can begin accessing the Web service. To invoke a Web service method, the proxy object must contain the following information:
- End point of service, obtained from a WSDL file
- Name space definition used in the SOAP method call
- Any structure definition, when applicable
- An instance variable for each returned structure array, since all returned arrays are any
- One or more SOAP methods and corresponding alias string
调用Web Services的方法 SoapConnection用于创建Soap_proxy对象并通过你在SetOptions方法的设置来配置soap连接选项。当一个Web Service的代理对象创建后,客户端应用程序就可以开始访问Web service了。为了调用一个Web Service的方法,代理对象必须包含以下的信息:
服务的端口,从一个WSDL文件获取。 在SOAP方法中调用到的命名空间定义。 任何的使用到的结构定义。 每个被返回的结构数组的实例变量,因为所有的数组的返回值都是any类型。 一个或多个SOAP方法和相应的别名串。
Adding PBSoapClient90.pbd to the library search path
The PBSoapClient90.dll and PBSoapClient90.pbd files are installed in the Shared/PowerBuilder directory when you install PowerBuilder. When you create a Web service client application, you do not need to copy PBSoapClient90.dll to another location, but you do need to deploy it with the client executable in a directory in the application's search path.
To add PBSoapClient90.pbd to the application's search path, right-click the client target in the System Tree and select Properties from the pop-up menu. Browse to the Shared\PowerBuilder directory, select *.pbd from the Files of Type drop-down list, and select PBSoapClient90.pbd.
After you add the PBSoapClient90.pbd, the following objects display in the System Tree:
|
Object |
Description |
|
soapconnection |
Used to connect to a SOAP server |
|
soapexception |
Used to catch exceptions thrown from soapconnection |
添加PBSoapClient90.pbd到库搜索路径下
在你安装PowerBuilder时PBSoapClient90.dll 和PBSoapClient90.pbd文件被安装在PowerBuilder/Share目录下。当你创建一个Web Service客户端应用程序时,你需要复制PBSoapClient90.dll到另一个目录下,你必须在可执行的客户端中配置应用程序库搜索路径。
加入PBSoapClient90.pbd到应用程序的库搜索路径,在系统树的客户端目标上右击鼠标,在弹出的菜单中选择属性,浏览Shared\PowerBuilder文件夹,从文件类型下拉列表框中选择*.pbd,并选择PBSoapClient90.pbd。
当你添加了PBSoapClient90.pbd后,下面的对象将出现在系统树中:
|
对象 |
描述 |
|
soapconnection |
用于连接SOAP服务器 |
|
soapexception |
用于捕获soapconnection产生的异常 |
Producing a Web service
PowerBuilder provides tools for developing custom class (nonvisual) user objects and deploying them as EAServer components. You can deploy the component to an EAServer host running on Windows and UNIX operating systems. You generate a Java bean for the component using Jaguar Manager.
Using EAServer's Web Services Toolkit, you can generate a WSDL file for the EAServer component, describing your Web service and its location. You also create a client proxy for the Web service, accessible to a client application. The client proxy uses the WSDL document that describes your Web service/EAServer component. The client application can then use the Web service. For more information see the EAServer Programmer's Guide and the EAServer Web Services Toolkit User's Guide .
生成一个Web service
PowerBuilder 提供了可扩展自定义类(不可视)用户对象并配置为EAServer组件的工具。你可以在Windows或UNIX操作系统中配置这些组件到一个EAServer主机上。你可以使用Jaguar管理器来产生这些组件的Java实例。 使用EAServer的Web Service开发包,你可以产生一个EAServer组件的WSDL文件,描述你的Web Service和Web Service的所在位置。你也可以创建一个使用让客户端应用程序可理解的WSDL文档的客户端代理。客户端代理使用描述你的Web 服务/EAServer组件的WSDL文档。客户端应用程序可以因此使用Web Service。更多详细信息,请参照《EAServer 程序员指南》和《EAServer 网页服务开发包指南》。 |