JAX-RPC Web Service |
|
|
![]() |
|
配置和运行 | 技术说明 | Javadoc | 使用 Ant 构建 |
配置样本 |
运行样本 |
存在两个 AddressBook 客户机,Java 2 Standard Edition(J2SE)版本和 Java 2 Enterprise Edition(J2EE)容器管理的版本。如果您要充分利用 J2EE 容器服务的功能,请运行 J2EE 版本。
要完成此样本的配置,请在服务器上部署 JAX-RPC Web Service 样本应用程序。如果尚未部署样本应用程序,请参阅重建和部署 WebServicesSamples.ear 文件的指示信息。
验证在客户机运行前服务器是否已启动。
存在两个 AddressBook 客户机,J2SE 外部版本和 Java 2 Enterprise Edition(J2EE)容器管理的版本。每个客户机都访遍服务器中部署的 AddressBook Web Service bean 的四个变体中的每一个。AddressBook Web Service bean 返回固定值,并且不需要运行因特网连接。
运行 J2SE 简单 AddressBook 客户机 |
运行 J2EE 应用程序 AddressBook 客户机 |
J2SE AddressBook 客户机演示如何查询 Web Service AddressBook bean,以从 Web Service 获取地址。您可在 profile_rootsamples/src/WebServicesSamples/Clients/simpleClients/samples/address 目录中找到它的源代码。
当您运行 AddressBookClient 时,AddressBook.wsdl 文件必须在当前目录中。从 simpleClients.jar 文件解压缩(unzip)AddressBook.wsdl 文件,并将它放入您计划运行样本的目录。可在 install_root/samples/lib/WebServicesSamples 目录中找到 simpleClients.jar 文件。
J2SE 客户机两次循环调用服务器上部署的每个 AddressBook Web Service bean。第一次循环期间,客户机调用 getPort 方法,以获取样本应用程序的每个 bean 的唯一端口。客户机在每个端口上调用 getAddressFromName 方法。 第二次循环从任一个端口开始,然后循环通过这些端口,同时将其端点地址设置为四个可能端点的每一个。客户机在每个端口上调用 getAddressFromName 方法。
要获取有关调用 WebSphere 客户机的更全面的指示信息,请参阅信息中心中有关开发瘦应用程序客户机代码的主题。
要从 WebSphere Application Server 运行 J2EE 简单 AddressBook 客户机,根据您的操作系统,执行下列步骤:
C:\>"%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> >> Get port AddressBookJ2WB >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JE/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WE/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WB/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JB/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 |
J2EE 应用程序 AddressBook 客户机类似于 J2SE 简单 AddressBook 客户机。它访问相同的 AddressBook Web Service bean,但访问操作是使用 launchClient 命令从 J2EE Application Client 容器完成的。
J2EE 客户机循环访问服务器上部署的每个 AddressBook Web Service bean。此客户机使用 Java 命名和目录接口(JNDI)lookup 命令找到 AddressBook 服务,并调用 get port,以获取四个 AddressBook bean 中每个 bean 的唯一端口。客户机在每个端口上调用 getAddressFromName 方法。
在以下步骤中,变量 install_root 表示 WebSphere 安装根目录。
要从 WebSphere Application Server 运行“J2EE 应用程序 AddressBook 客户机”,根据您的操作系统,执行下列步骤:
C:\WebSphere\AppServer\samples>\WebSphere\AppServer\bin\launchClient \WebSphere\AppServer\samples\lib\WebServicesSamples\ApplicationClients.ear -CCjar=AddressBookClient.jar IBM WebSphere Application Server, Release 7.0 J2EE Application Client Tool Copyright IBM Corp., 1997-2008 WSCL0012I: Processing command line arguments. WSCL0013I: Initializing the J2EE Application Client Environment. [3/29/06 14:47:51:062 CST] 0000000a W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=269328:O=0:CT] CWPKI0041W: One or more key stores are using the default password. WSCL0035I: Initialization of the J2EE Application Client Environment has completed. WSCL0014I: Invoking the Application Client class com.ibm.websphere.samples.webservices.addr.AddressBookClient >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 |
参阅 Address Book 技术说明和查看 Java 源代码,以了解更多的客户机和应用程序工作原理。