⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jaxr3.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>Implementing a JAXR Client</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="JAXR2.html" />    <link rel="Next" href="JAXR4.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="JAXR2.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="JAXR4.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp88034"> </a><h2 class="pHeading1">Implementing a JAXR Client</h2><a name="wp64083"> </a><p class="pBody">This section describes the basic steps to follow in order to implement a JAXR client that can perform queries and updates to a UDDI registry. A JAXR client is a client program that can access registries using the JAXR API. It covers the following topics:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp98867"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp64057">Establishing a Connection</a></li></div><a name="wp98871"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp65842">Querying a Registry</a></li></div><a name="wp98876"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp66325">Managing Registry Data</a></li></div><a name="wp98880"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp85263">Using Taxonomies in JAXR Clients</a></li></div></ul></div><a name="wp92972"> </a><p class="pBody">This tutorial does not describe how to implement a JAXR provider. A JAXR provider provides an implementation of the JAXR specification that allows access to an existing registry provider, such as a UDDI or ebXML registry. The implementation of JAXR in the J2EE Application Server itself is an example of a JAXR provider. </p><a name="wp150440"> </a><p class="pBody">The J2EE 1.4 Application Server provides JAXR in the form of a resource adapter using the J2EE Connector Architecture. The resource adapter is in the directory <code class="cCode">&lt;</code><code class="cVariable">J2EE_HOME</code><code class="cCode">&gt;/lib/install/applications/jaxr-ra</code>. (<code class="cCode">&lt;</code><code class="cVariable">J2EE_HOME</code><code class="cCode">&gt;</code> is the directory where the J2EE Application Server is installed.)</p><a name="wp67773"> </a><p class="pBody">This tutorial includes several client examples, which are described in <a  href="JAXR4.html#wp64170">Running the Client Examples</a>, and a J2EE application example, described in <a  href="JAXR5.html#wp150745">Using JAXR Clients in J2EE Applications</a>. The examples are in the directory <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/jaxr/</code>.  (<code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;</code> is the directory where you installed the tutorial bundle.) Each example directory has a <code class="cCode">build.xml</code> file that refers to a <code class="cCode">targets.xml</code> file and a <code class="cCode">build.properties</code> file in the directory <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/jaxr/common/</code>.</p><a name="wp64057"> </a><h3 class="pHeading2">Establishing a Connection</h3><a name="wp64093"> </a><p class="pBody">The first task a JAXR client must complete is to establish a connection to a registry. Establishing a connection involves the following tasks:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp98885"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp64094">Preliminaries: Getting Access to a Registry</a></li></div><a name="wp98889"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp75995">Creating or Looking Up a Connection Factory</a></li></div><a name="wp98894"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp64104">Creating a Connection</a></li></div><a name="wp98903"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp80737">Setting Connection Properties</a></li></div><a name="wp115416"> </a><div class="pSmartList1"><li><a  href="JAXR3.html#wp84847">Obtaining and Using a RegistryService Object</a></li></div></ul></div><a name="wp64094"> </a><h4 class="pHeading3">Preliminaries: Getting Access to a Registry</h4><a name="wp64098"> </a><p class="pBody">Any user of a JAXR client may perform queries on a registry. In order to add data to the registry or to update registry data, however, a user must obtain permission from the registry to access it. To register with one of the public UDDI version 2 registries, go to one of the following Web sites and follow the instructions:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp71284"> </a><div class="pSmartList1"><li><code class="cCode"><a  href="http://test.uddi.microsoft.com/" target="_blank">http://test.uddi.microsoft.com/</a></code> (Microsoft)</li></div><a name="wp71293"> </a><div class="pSmartList1"><li><code class="cCode"><a  href="http://uddi.ibm.com/testregistry/registry.html" target="_blank">http://uddi.ibm.com/testregistry/registry.html</a></code> (IBM)</li></div><a name="wp87410"> </a><div class="pSmartList1"><li><code class="cCode"><a  href="http://udditest.sap.com/" target="_blank">http://udditest.sap.com/</a></code> (SAP)</li></div></ul></div><a name="wp106065"> </a><p class="pBody">These UDDI version 2 registries are intended for testing purposes. When you register, you will obtain a user name and password. You will specify this user name and password for some of the JAXR client example programs.</p><a name="wp89709"> </a><p class="pBody">You do not have to register with the Java WSDP Registry Server in order to add or update data. You can use the default user name and password, <code class="cCode">testuser</code> and <code class="cCode">testuser</code>.</p><hr><a name="wp87710"> </a><p class="pNote">Note: The JAXR API has been tested with the Microsoft and IBM registries and with the Java WSDP Registry Server, but not with the SAP registry.</p><hr><a name="wp75995"> </a><h4 class="pHeading3">Creating or Looking Up a Connection Factory</h4><a name="wp64103"> </a><p class="pBody">A client creates a connection from a connection factory. A JAXR provider may supply one or more preconfigured connection factories that clients can obtain by looking them up using the Java Naming and Directory Interface (JNDI) API. </p><a name="wp150468"> </a><p class="pBody">At this release of the J2EE Application Server, JAXR supplies a connection factory through the JAXR RA, but you need to create a connector resource whose JNDI API name (&quot;JNDI name&quot;) is <code class="cCode">eis/JAXR</code> to access this connection factory from a J2EE application. To look up this connection factory in a J2EE component, use code like the following:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">import javax.xml.registry.*;import javax.naming.*;...&nbsp;&nbsp;Context context = new InitialContext();&nbsp;&nbsp;ConnectionFactory connFactory = (ConnectionFactory) &nbsp;&nbsp;&nbsp;&nbsp;context.lookup(&quot;java:comp/env/eis/JAXR&quot;);<a name="wp150469"> </a></pre></div><a name="wp151716"> </a><p class="pBody">You will learn how to create this connector resource later in this chapter.</p><a name="wp95079"> </a><p class="pBody">To use JAXR in a standalone client program, you must create an instance of the abstract class <code class="cCode">ConnectionFactory</code>:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">import javax.xml.registry.*;...ConnectionFactory connFactory = &nbsp;&nbsp;ConnectionFactory.newInstance();<a name="wp95080"> </a></pre></div><a name="wp64104"> </a><h4 class="pHeading3">Creating a Connection</h4><a name="wp86116"> </a><p class="pBody">To create a connection, a client first creates a set of properties that specify the URL or URLs of the registry or registries being accessed. For example, the following code provides the URLs of the query service and publishing service for the IBM test registry. (There should be no line break in the strings.)</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">Properties props = new Properties();props.setProperty(&quot;javax.xml.registry.queryManagerURL&quot;,&nbsp;&nbsp;&quot;http://uddi.ibm.com/testregistry/inquiryapi&quot;);props.setProperty(&quot;javax.xml.registry.lifeCycleManagerURL&quot;,&nbsp;&nbsp;&quot;https://uddi.ibm.com/testregistry/publishapi&quot;);<a name="wp89749"> </a></pre></div><a name="wp79330"> </a><p class="pBody">With the J2EE Application Server implementation of JAXR, if the client is accessing a registry that is outside a firewall, it must also specify proxy host and port information for the network on which it is running. For queries it may need to specify only the HTTP proxy host and port; for updates it must specify the HTTPS proxy host and port.</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">props.setProperty(&quot;com.sun.xml.registry.http.proxyHost&quot;, &nbsp;&nbsp;&quot;myhost.mydomain&quot;);props.setProperty(&quot;com.sun.xml.registry.http.proxyPort&quot;, &nbsp;&nbsp;&quot;8080&quot;);props.setProperty(&quot;com.sun.xml.registry.https.proxyHost&quot;, &nbsp;&nbsp;&quot;myhost.mydomain&quot;);props.setProperty(&quot;com.sun.xml.registry.https.proxyPort&quot;, &nbsp;&nbsp;&quot;8080&quot;);<a name="wp76039"> </a></pre></div><a name="wp76002"> </a><p class="pBody">The client then sets the properties for the connection factory and creates the connection:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">connFactory.setProperties(props);Connection connection = connFactory.createConnection();<a name="wp65766"> </a></pre></div><a name="wp67837"> </a><p class="pBody">The <code class="cCode">makeConnection</code> method in the sample programs shows the steps used to create a JAXR connection.</p><a name="wp80737"> </a><h4 class="pHeading3">Setting Connection Properties</h4><a name="wp80740"> </a><p class="pBody">The implementation of JAXR in the J2EE Application Server allows you to set a number of properties on a JAXR connection. Some of these are standard properties defined in the JAXR specification. Other properties are specific to the implementation of JAXR in the J2EE Application Server. <a  href="JAXR3.html#wp82242">Table 10-1</a> and <a  href="JAXR3.html#wp82441">Table 10-2</a> list and describe these properties. </p><div align="left"><table border="1" summary="Standard JAXR Connection Properties" id="wp82242">  <caption><a name="wp82242"> </a><div class="pTableTitle">Table 10-1   Standard JAXR Connection Properties</div></caption>  <tr align="center">    <th><a name="wp82248"> </a><div class="pCellHeading">Property Name and Description</div></th>    <th><a name="wp82250"> </a><div class="pCellHeading">Data Type</div></th>    <th><a name="wp82252"> </a><div class="pCellHeading">Default Value</div></th></tr>  <tr align="left">    <td><a name="wp82254"> </a><div class="pCellBody"><code class="cCode">javax.xml.registry.queryManagerURL</code></div><a name="wp82255"> </a><div class="pCellBody">&#160;</div><a name="wp82256"> </a><div class="pCellBody">Specifies the URL of the query manager service within the target registry provider</div></td>    <td><a name="wp82258"> </a><div class="pCellBody">String</div></td>    <td><a name="wp82260"> </a><div class="pCellBody">None</div></td></tr>  <tr align="left">    <td><a name="wp82262"> </a><div class="pCellBody"><code class="cCode">javax.xml.registry.lifeCycleManagerURL</code></div><a name="wp82263"> </a><div class="pCellBody">&#160;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -