使用 Ant 构建工具来构建 JAX-RPC Web Service 样本


J2EE 可移植性
重建此库中提供的样本
入门
确定样本构建的目录结构
重建和重新安装 WebServicesSamples.ear 文件。

J2EE 可移植性

在 J2EE 平台上开发应用程序的一个主要的优点是可移植性。样本库中的所有样本程序是在工作站上开发的,并且不需要更改一行 Java 代码就可在 z/OS 系统上运行。通过在 Intel 或 UNIX 系统上构建 J2EE 应用程序,开发者可以消除 EBCDIC 到 ASCII 或 ASCII 到 EBCDIC 文件转换的难题。开发者可使用工具在开发工作站上轻松地编写和测试企业归档(EAR)文件,然后轻松地将它安装在 z/OS 系统上。

重建此库中提供的样本

每个 WebSphere Application Server(应用程序服务器)for z/OS 客户都被授权使用多平台的 Application Server 介质。如果您将 WebSphere Application Server Base 产品和样本安装在它支持的某个平台上,那么会看到同一个库。一种例外情况是,在单击 sample_name > 使用 Ant 构建 > 平台 > 重建和安装 sample.ear 文件时得到指示信息,要求在该平台上重建 EAR 文件。因为 EAR 文件中的文本文件(XML、xmi、JavaServer Pages(JSP)文件等)的格式必须是 ASCII,所以更容易在 ASCII 机器上编辑那些文件。如果您在 ASCII 机器上更改了 EAR 文件,那么不必进行 EBCDIC 到 ASCII 转换就可以在 z/OS 平台上重新安装更改后的 EAR 文件。 

入门

在您选择的分布式平台上安装 WebSphere Application Server,并且指出也安装 Application Server 样本应用程序。

在尝试修改或重建样本之前,制作 <profile_root>/samples/src/WebServicesSamples 目录的备份副本。

确定样本构建的目录结构

样本安装在下列目录中:

<profile_root>/samples/src/WebServicesSamples 包含 AddressBook 和 Stock Quote 样本的样本源代码。
<profile_root>/samples/lib/WebServicesSamples 包含样本的 Web 归档(WAR)文件、Java 归档(JAR)文件和最终的 WebServicesSamples.ear 文件。此目录是在构建样本后创建的。
<profile_root>/samples/javadoc/WebServicesSamples 包含样本 Javadoc 文档。此目录是在构建样本后创建的。
<profile_root>/samples/bld/WebServicesSamples 包含所生成的类文件。这些类文件用于生成最终的 WebServicesSamples.ear 文件。此目录是在重建此样本后创建的。

重建和重新安装 WebServicesSamples.ear 文件。

JAX-RPC Web Service 样本企业归档(EAR)文件是在安装 WebSphere Application Server 时提供的。您无须在使用样本前构建它们。以下说明描述重建该样本的步骤,以及有关修改它们的更多信息。

执行样本构建脚本

传送重建的 WebServicesSamples.ear 文件
除去和重新安装 WebServicesSamples.ear 文件。

执行样本构建脚本

要重建该样本,请验证 <profile_root>/bin 是否在您的 PATH 环境变量中。按照下列步骤来执行样本构建脚本,它重建样本:

  1. 打开命令提示符。
  2. 在命令行上,转到 <profile_root>/samples/src/WebServicesSamples 目录。
  3. 运行样本构建脚本:
  4. 在命令行中输入 buildWebServiceSamples
    • 在 Windows 开发平台上的命令行中,输入 buildWebServiceSamples
    • 在 UNIX 和 Linux 开发平台上的命令行中,输入 buildWebServiceSamples.sh

现在样本已构建。

<profile_root>/samples/bin/WebServicesSamples 目录中的 buildWebServicesSamples.batbuildWebServicesSamples.sh 脚本设置适当的类路径信息,并执行 Ant 构建实用程序。Ant 读取描述了如何构建样本的 build.xml 文件。请参阅 Jakarta Web 站点以获取有关 Ant 的其他文档。

重要信息 在构建过程中,仅重建更改过的类文件。其他类文件重新打包到新的 EAR 文件中。

传送重建的 WebServicesSamples.ear 文件

通过使用以下指示信息,使用文件传输协议(FTP)将二进制 EAR 文件传送到 z/OS 服务器。

  1. <profile_root>/samples/lib/WebServicesSamples 目录中找到重建的 EAR 文件
  2. 从开发平台打开与 WebSphere Application Server for z/OS 的 FTP 会话
  3. 转到目录 <profile_root>/samples/lib/WebServicesSamples
  4. del WebServicesSamples.ear
  5. bin
  6. put WebServicesSamples.ear
  7. quit

除去和重新安装 WebServicesSamples.ear 文件。

缺省情况下,JAX-RPC Web Service 样本安装到 <profile_root>/installedApps/<cell name> 目录,其中 <cell name> 是安装应用程序的单元的名称。按下面描述的步骤重新安装样本:

  1. 停止应用程序服务器。
  2. 除去 JAX-RPC Web Service 样本 EAR 文件:
    1. 输入以下命令:

      cd <profile_root>\bin
      setupCmdLine

      cd <profile_root>/bin
      . ./setupCmdLine.sh

      cd <profile_root>/bin
      . ./setupCmdLine.sh

      cd <profile_root>/bin
      . ./setupCmdLine

      其中 <profile_root> 表示概要文件安装目录。
    2. 输入下列命令以卸载此应用程序(<profile_root>/bin 必须在您的 PATH 中):

      wsadmin -conntype none -lang jython -c "AdminApp.uninstall('WebServicesSamples')" 

      wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('WebServicesSamples')" 

      wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('WebServicesSamples')" 

      wsadmin -conntype none -lang jython -c "AdminApp.uninstall('WebServicesSamples')" 

  3. 重新安装样本:
    • 转到 <profile_root>/samples/lib/WebServicesSamples 目录
    • 找到 WebServicesSamples.ear 文件
    • 输入以下命令:

      wsadmin -conntype none -lang jython -c "AdminApp.install('WebServicesSamples.ear',
                  ['-appname', 'WebServicesSamples', '-usedefaultbindings', '-node', '<node>', 
                  '-server', '<server>', '-deployejb' ] )"
                
      其中 <node> 是节点的名称,<server> 是要安装样本的服务器的名称。

      wsadmin.sh -conntype none -lang jython -c "AdminApp.install('WebServicesSamples.ear',
                  ['-appname', 'WebServicesSamples', '-usedefaultbindings', '-node', '<node>', 
                  '-server', '<server>', '-deployejb' ] )"
                
      其中 <node> 是节点的名称,<server> 是要安装样本的服务器的名称。

      wsadmin.sh -conntype none -lang jython -c "AdminApp.install('WebServicesSamples.ear',
                  ['-appname', 'WebServicesSamples', '-usedefaultbindings', '-node', '<node>', 
                  '-server', '<server>', '-deployejb' ] )"
                
      其中 <node> 是节点的名称,<server> 是要安装样本的服务器的名称。
      wsadmin -conntype none -lang jython -c "AdminApp.install('WebServicesSamples.ear',
                  ['-appname', 'WebServicesSamples', '-usedefaultbindings', '-node', '<node>', 
                  '-server', '<server>', '-deployejb' ] )"
                
      其中 <node> 是节点的名称,<server> 是要安装样本的服务器的名称。
  4. 启动应用程序服务器。

现在您已重建并重新安装了 JAX-RPC Web Service 样本应用程序。您可以配置和运行 Address Book 和 Stock Quote 样本客户机了。