使用 UDDI JAXR 提供程序
要开始使用 Java™ API for XML Registries (JAXR) 提供程序,您可以使用样本程序。您还需要考虑类库、认证和安全性、内部分类法以及记录和消息。
关于此任务
不推荐使用的功能部件: 从 WebSphere® Application Server V8.0 起,建议不要使用针对 XML 的 Java API 注册表 (JAX-R) API。从 Java Platform, Enterprise Edition (Java EE) 6 平台开始不建议使用 JAX-R,因为它基于“统一描述、发现和集成协议”(UDDI) 2 技术,该技术与 JAX-R 无关。
如果您的应用程序使用 JAX-R,那么可以考虑使用 UDDI 3。depfeat过程
- 要获取 ConnectionFactory 实例,请创建与注册中心的连接,并在注册中心中保存组织;请参阅以下的样本程序。
使用对运行 UDDI 注册中心的特定 IBM® i 机器的引用来替换对 localhost 的所有引用。import java.net.PasswordAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Properties; import java.util.Set; import javax.xml.registry.BulkResponse; import javax.xml.registry.BusinessLifeCycleManager; import javax.xml.registry.Connection; import javax.xml.registry.ConnectionFactory; import javax.xml.registry.JAXRException; import javax.xml.registry.RegistryService; import javax.xml.registry.infomodel.Key; import javax.xml.registry.infomodel.Organization; public class JAXRSample { public static void main(String[] args) throws JAXRException { //Tell the ConnectionFactory to use the JAXR provider for UDDI System.setProperty("javax.xml.registry.ConnectionFactoryClass", "com.ibm.xml.registry.uddi.ConnectionFactoryImpl"); ConnectionFactory connectionFactory = ConnectionFactory.newInstance(); //Set the URLs for the UDDI inquiry and publish APIs. //These must be the URLs of the UDDI version 2 APIs. Properties props = new Properties(); props.setProperty("javax.xml.registry.queryManagerURL", "http://localhost:9080/uddisoap/inquiryapi"); props.setProperty("javax.xml.registry.lifeCycleManagerURL", "http://localhost:9080/uddisoap/publishapi"); connectionFactory.setProperties(props); //Create a Connection to the UDDI registry accessible at the above URLs. Connection connection = connectionFactory.createConnection(); //Set the user ID and password used to access the UDDI registry. PasswordAuthentication pa = new PasswordAuthentication("Publisher1", new char[] { 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' }); Set credentials = new HashSet(); credentials.add(pa); connection.setCredentials(credentials); //Get the javax.xml.registry.BusinessLifeCycleManager interface, //which contains methods corresponding to UDDI publish API calls. RegistryService registryService = connection.getRegistryService(); BusinessLifeCycleManager lifeCycleManager = registryService.getBusinessLifeCycleManager(); //Create an Organization (UDDI businessEntity) with name //"Organization 1". Organization org = lifeCycleManager.createOrganization("Organization 1"); //Add the Organization to a Collection, ready to be saved in the UDDI //registry. Collection orgs = new ArrayList(); orgs.add(org); //Save the Organization in the UDDI registry. BulkResponse bulkResponse = lifeCycleManager.saveOrganizations(orgs); //Obtain the Organization Key (the UDDI businessEntity //businessKey) from the response. if (bulkResponse.getExceptions() == null) { //1 Organization was saved, so 1 key will be returned in the //response collection Collection responses = bulkResponse.getCollection(); Key organizationKey = (Key)responses.iterator().next(); System.out.println("\nOrganization Key = " + organizationKey.getId()); } } } - 确保设置类路径。 UDDI JAXR 提供程序的类库位于 app_server_root/plugins 目录的 com.ibm.uddi_1.0.0.jar 文件中。从 WebSphere Application Server 下正在运行的 Java EE 应用程序使用 JAXR API 时,所有必需的类都会自动出现在类路径上。从此环境外部使用 JAXR API 时,以下 .jar 文件必须是在 Java 类路径上:
- app_server_root/lib/bootstrap.jar
- app_server_root/plugins/com.ibm.uddi_1.0.0.jar
- app_server_root/plugins/com.ibm.ws.runtime_6.1.0
- 要使用 UDDI JAXR 提供程序,您必须先指定 ConnectionFactory 实现类的名称。 将 javax.xml.registry.ConnectionFactoryClass 系统属性设置为 com.ibm.xml.registry.uddi.ConnectionFactoryImpl。
如果未设置此系统属性,那么缺省值为 com.sun.xml.registry,common.ConnectionFactoryImpl,但在调用 ConnectionFactory.newInstance() 方法时找不到此值,因此导致出现 JAXRException 异常。
UDDI JAXR 提供程序不支持使用 Java 命名和目录接口 (JNDI) 来查找 ConnectionFactory。
- 要指定特定于连接的属性,请在获取连接前,在 JAXR ConnectionFactory 上设置 java.util.Properties 对象。 JAXR 规范中有这些属性的完整列表。下表列出三个最重要的属性及其值,这些值是使用 UDDI JAXR 提供程序访问 UDDI 注册中心时采用的。
表 1. 使用 UDDI JAXR 提供程序来访问 UDDI 注册中心时需要的特定于连接的属性. 该表列示不同的属性以及每一个属性的描述。 属性 描述 javax.xml.registry.queryManagerURL UDDI V2 的 UDDI 注册中心的查询 API URL。通常,此属性采用以下格式:http://hostname:port/uddisoap/inquiryapi。此属性是必需的。 javax.xml.registry.lifeCycleManagerURL UDDI V2 的 UDDI 注册中心的发布 API URL。通常,此属性采用以下格式:http://hostname:port/uddisoap/publishapi。 如果未指定此属性,那么缺省值为 javax.xml.registry.queryManagerURL 属性的值。但是,UDDI 注册中心的查询和发布 API 的 URL 通常不同,因此建议指定这两个属性。
javax.xml.registry.authenticationMethod 在注册中心中认证时使用的认证方法。这可以采用下列两个值之一:UDDI_GET_AUTHTOKEN 和 HTTP_BASIC。如果未指定值,那么缺省值为 UDDI_GET_AUTHTOKEN。请参阅以下步骤,以了解更多信息。 唯一的必需连接属性为 javax.xml.registry.queryManagerURL。但是,建议设置 javax.xml.registry.lifeCycleManagerURL,并了解 javax.xml.registry.security.authenticationMethod 的缺省值。JAXR 规范中所定义的其他连接属性是可选的,并且其值不特定于 UDDI 注册中心。UDDI JAXR 提供程序不定义任何其他特定于提供程序的属性。
- 要确定 JAXR 提供程序用于在 UDDI 注册中心中认证的方法,请设置 javax.xml.registry.authenticationMethod 连接属性。 javax.xml.registry.authenticationMethod 连接属性确定 JAXR 提供程序用于在 UDDI 注册中心中认证的方法。支持此属性的以下两个值:
- UDDI_GET_AUTHTOKEN
JAXR 提供程序使用 UDDI V2 get_authToken API 在注册中心中认证。如果已设置连接凭证,那么 JAXR 提供程序会自动进行 get_authToken 调用。JAXR 提供程序会保存调用所返回的 UDDI V2 authToken,以在后续 UDDI 发布 API 调用上使用。
- HTTP_BASIC
JAXR 提供程序使用 HTTP 基本认证在注册中心中认证。如果安全性处于已启用状态,那么 WebSphere Application Server 支持 HTTP 基本认证。JAXR 提供程序不进行 get_authToken 调用。相反地,每当进行 UDDI API 调用(查询和发布)时,会使用 HTTP 基本认证在 HTTP 头中发送用户名和密码。如果 UDDI 注册中心不需要 HTTP 基本认证,那么将忽略凭证。
如果未设置此属性,那么缺省认证方法是 UDDI_GET_AUTHTOKEN。
- UDDI_GET_AUTHTOKEN
- 要使用安全套接字层 (SSL) 对 UDDI JAXR 提供程序和 UDDI 注册中心之间的 HTTP 流量进行加密,请参阅将 SSL 与 UDDI JAXR 提供程序配合使用。
- 要提供定制内部分类法,请参阅为 JAXR 提供程序创建定制内部分类法。
- 要切换至 UDDI4J 记录,请设置 org.uddi4j.logEnabled 系统属性为 True。 UDDI JAXR 提供程序使用 UDDI4J V2 与 UDDI 注册中心进行通信,并且 UDDI4J 具有它自己的记录。
子主题
![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
UDDI Java API for XML Registries (JAXR) 提供程序
Java API for XML Registries (JAXR) 是一种 Java 客户机 API,用于访问 UDDI(仅限 V2)和 ebXML 注册中心。 它是 Java Platform, Enterprise Edition (Java EE) 规范中的一部分。![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
将 SSL 与 UDDI JAXR 提供程序配合使用
您可以使用安全套接字层 (SSL) 对 UDDI Java API for XML Registries (JAXR) 提供程序和 UDDI 注册中心之间的 HTTP 流量进行加密。![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
为 JAXR 提供程序创建定制内部分类法
您可以创建定制内部分类法,并将其提供给 Java API for XML Registries (JAXR) 提供程序。![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
符合 UDDI 内部分类法的 JAXR 提供程序
UDDI 的 Java API for XML Registries (JAXR) 提供程序提供很多内部分类法。![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
JAXR 提供程序记录和消息
UDDI 的 Java API for XML Registries (JAXR) 提供程序使用 UDDI4J 记录、通用记录和一些标准消息。
任务主题
最近一次更新时间: last_datehttp://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-base-dist&topic=twsu_jaxr
文件名:twsu_jaxr.html