这一系列文章展示了 WebSphere Studio V5.1.1 中的 Java Server Faces Technology Preview 的特征,本文是其中的第 5 部分。
JSF Web 服务客户端依赖于为构建页面数据而激活的 Web 服务。在页面中放置 Web 服务代理组件之前,您有机会测试 Web 服务。
构建 JSF Web 服务客户端 现在,我们可以构建 JSF Web 服务客户端。
首先,创建一个新的 Faces JSP 页面:
在 Application Developer 中,在 WebContent 目录下创建一个新的 Faces JSP 页面,并将其命名为 companyInfoWS.jsp (图 11)。
图 11. 创建 Faces JSP 文件

请记住在工作区中选择现有的 User-Defined Page Template(图 12)。
图 12. Page Template File Selection

现在,JSP 页面会在编辑器中打开。
要在页面数据中添加 Web 服务代理,请执行以下操作:
在 Page Data 对话框中,右键单击 JSP scripting,然后选择 New => Web Service Proxy (图 13)。
图 13. Page Data

在 Add Web Service Proxy Bean 对话框中,选择 New。
图 14. Add Web Service Proxy Bean

Web Service Discovery Home 屏幕将显示(图 15)。这里,您可以通过 Internet 或在您自己的正在运行 UTE 服务器的工作区中调用任何兼容的 Web 服务。选择 Web Services from your workspace。
图 15. Web Service Directory Home

如果服务器正在运行,则会显示到公司信息 Web 服务的链接(图 16)。单击该链接。
图 16. Web Services Information 显示

选择 StockFacade 端口,然后单击 Details 按钮。
图 17. Web Services 信息列表

WebSphere Studio Web Service Explorer 将启动。请选择 getCompanyInfo 链接(图 18)。
图 18. WSDL Binding Details

在 symbol 中键入 IBM ,然后选择 Go。
图 19. Invoke a WSDL Operation

在底部框架中,您会看到调用的结果(图 20)。也可以检查 SOAP 信封来检验 Web 服务是否真正在工作。完成时,关闭 Web Service Explorer。
图 20. 调用结果

查看本文来源