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

📄 jaxr3.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 5 页
字号:
&nbsp;&nbsp;System.out.println(&quot;Organization saved&quot;);&nbsp;&nbsp;Collection keys = response.getCollection();&nbsp;&nbsp;Iterator keyIter = keys.iterator();&nbsp;&nbsp;if (keyIter.hasNext()) {&nbsp;&nbsp;&nbsp;&nbsp;javax.xml.registry.infomodel.Key orgKey = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(javax.xml.registry.infomodel.Key) keyIter.next();&nbsp;&nbsp;&nbsp;&nbsp;String id = orgKey.getId();&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Organization key is &quot; + id);&nbsp;&nbsp;}}<a name="wp68765"> </a></pre></div><a name="wp140680"> </a><h4 class="pHeading3">Publishing a Specification Concept</h4><a name="wp148295"> </a><p class="pBody">A service binding may have a technical specification that describes how to access the service. An example of such a specification is a WSDL document. To publish the location of a service's specification (if the specification is a WSDL document), you create a <code class="cCode">Concept</code> object and then add the URL of the WSDL document to the <code class="cCode">Concept</code> object as an <code class="cCode">ExternalLink</code> object. The following code fragment shows how to create a concept for the WSDL document associated with the simple web service example in <a  href="JAXRPC4.html#wp115211">Creating a Web Service with JAX-RPC</a>. First, you call the <code class="cCode">createConcept</code> method to create a concept named HelloConcept. After setting the description of the concept, you create an external link to the URL of the Hello service's WSDL document, then add the external link to the concept.</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">Concept specConcept = &nbsp;&nbsp;blcm.createConcept(null, &quot;HelloConcept&quot;, &quot;&quot;);InternationalString s =&nbsp;&nbsp;blcm.createInternationalString(&nbsp;&nbsp;&nbsp;&nbsp;&quot;Concept for Hello Service&quot;);specConcept.setDescription(s);ExternalLink wsdlLink = &nbsp;&nbsp;blcm.createExternalLink(&nbsp;&nbsp;&nbsp;&nbsp;&quot;http://localhost:8080/hello-jaxrpc/hello?WSDL&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&quot;Hello WSDL document&quot;);specConcept.addExternalLink(wsdlLink);<a name="wp140696"> </a></pre></div><a name="wp140693"> </a><p class="pBody">Next, you classify the <code class="cCode">Concept</code> object as a WSDL document. To do this for a UDDI registry, you search the registry for the well-known classification scheme <code class="cCode">uddi-org:types</code>. (The UDDI term for a classification scheme is <code class="cCode">tModel</code>.) Then you create a classification using the name and value <code class="cCode">wsdlSpec</code>. Finally, you add the classification to the concept.</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">String schemeName = &quot;uddi-org:types&quot;;ClassificationScheme uddiOrgTypes =&nbsp;&nbsp;bqm.findClassificationSchemeByName(null, schemeName);Classification wsdlSpecClassification = &nbsp;&nbsp;&nbsp;&nbsp;blcm.createClassification(uddiOrgTypes, &nbsp;&nbsp;&nbsp;&nbsp;&quot;wsdlSpec&quot;, &quot;wsdlSpec&quot;);specConcept.addClassification(wsdlSpecClassification);<a name="wp140860"> </a></pre></div><a name="wp140994"> </a><p class="pBody">Finally, you save the concept using the <code class="cCode">saveConcepts</code> method, similarly to the way you save an organization:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">Collection concepts = new ArrayList();concepts.add(specConcept);BulkResponse concResponse = blcm.saveConcepts(concepts);<a name="wp140981"> </a></pre></div><a name="wp142372"> </a><p class="pBody">Once you have published the concept, you normally add the concept for the WSDL document to a service binding. To do this, you could retrieve the key for the concept from the response returned by the <code class="cCode">saveConcepts</code> method, using a code sequence very similar to that of finding the key for a saved organization.</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">String conceptKeyId = null;Collection concExceptions = concResponse.getExceptions();javax.xml.registry.infomodel.Key concKey = null;if (concExceptions == null) {&nbsp;&nbsp;System.out.println(&quot;WSDL Specification Concept saved&quot;);&nbsp;&nbsp;Collection keys = concResponse.getCollection();&nbsp;&nbsp;Iterator keyIter = keys.iterator();&nbsp;&nbsp;if (keyIter.hasNext()) {&nbsp;&nbsp;&nbsp;&nbsp;concKey = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(javax.xml.registry.infomodel.Key) keyIter.next();&nbsp;&nbsp;&nbsp;&nbsp;conceptKeyId = concKey.getId();&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Concept key is &quot; + id);&nbsp;&nbsp;}}<a name="wp142653"> </a></pre></div><a name="wp142379"> </a><p class="pBody">Then you could call the <code class="cCode">getRegistryObject</code> method to retrieve the concept from the registry:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">Concept specConcept = &nbsp;&nbsp;(Concept) bqm.getRegistryObject(conceptKeyId, &nbsp;&nbsp;&nbsp;&nbsp;LifeCycleManager.CONCEPT);<a name="wp142897"> </a></pre></div><a name="wp142382"> </a><p class="pBody">Next, you create a <code class="cCode">SpecificationLink</code> object for the service binding and set the concept as the value of its <code class="cCode">SpecificationObject</code>:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">SpecificationLink specLink = &nbsp;&nbsp;blcm.createSpecificationLink();specLink.setSpecificationObject(specConcept);binding.addSpecificationLink(specLink);<a name="wp142944"> </a></pre></div><a name="wp143047"> </a><p class="pBody">Now when you publish the organization with its service and service bindings, you have also published a link to the WSDL document, so that the organization can be found in queries like those described in <a  href="JAXR3.html#wp66170">Finding Organizations by Classification</a>.</p><a name="wp143685"> </a><p class="pBody">If the concept was published by someone else and you don't have access to the key, you can find it using its name and classification. The code would look very similar to the code used to search for a WSDL document in <a  href="JAXR3.html#wp66170">Finding Organizations by Classification</a>, except that you would also create a collection of name patterns and include that in your search. For example:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">// Define name patternCollection namePatterns = new ArrayList();namePatterns.add(&quot;HelloConcept&quot;);BulkResponse br = bqm.findConcepts(null, namePatterns, &nbsp;&nbsp;classifications, null, null);<a name="wp143691"> </a></pre></div><a name="wp64166"> </a><h4 class="pHeading3">Removing Data from the Registry</h4><a name="wp69113"> </a><p class="pBody">A registry allows you to remove from the registry any data that you have submitted to it. You use the key returned by the registry as an argument to one of the <code class="cCode">BusinessLifeCycleManager</code> delete methods: <code class="cCode">deleteOrganizations</code>, <code class="cCode">deleteServices</code>, <code class="cCode">deleteServiceBindings</code>, <code class="cCode">deleteConcepts</code>, and others.</p><a name="wp69125"> </a><p class="pBody">The <code class="cCode">JAXRDelete</code> sample program deletes the organization created by the <code class="cCode">JAXRPublish</code> program. It deletes the organization that corresponds to a specified key string and then displays the key again so that the user can confirm that it has deleted the correct one.</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">String id = key.getId();System.out.println(&quot;Deleting organization with id &quot; + id);Collection keys = new ArrayList();keys.add(key);BulkResponse response = blcm.deleteOrganizations(keys);Collection exceptions = response.getException();if (exceptions == null) {    System.out.println(&quot;Organization deleted&quot;);    Collection retKeys = response.getCollection();    Iterator keyIter = retKeys.iterator();    javax.xml.registry.infomodel.Key orgKey = null;    if (keyIter.hasNext()) {        orgKey =             (javax.xml.registry.infomodel.Key) keyIter.next();        id = orgKey.getId();        System.out.println(&quot;Organization key was &quot; + id);    }}<a name="wp69132"> </a></pre></div><a name="wp69471"> </a><p class="pBody">A client can use a similar mechanism to delete concepts, services, and service bindings.</p><a name="wp85263"> </a><h3 class="pHeading2">Using Taxonomies in JAXR Clients</h3><a name="wp85264"> </a><p class="pBody">In the JAXR API, a taxonomy is represented by a <code class="cCode">ClassificationScheme</code> object.</p><a name="wp85265"> </a><p class="pBody">This section describes how to use the implementation of JAXR in the J2EE Application Server: </p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp85266"> </a><div class="pSmartList1"><li>To define your own taxonomies </li></div><a name="wp85267"> </a><div class="pSmartList1"><li>To specify postal addresses for an organization</li></div></ul></div><a name="wp85269"> </a><h4 class="pHeading3">Defining a Taxonomy</h4><a name="wp85270"> </a><p class="pBody">The JAXR specification requires a JAXR provider to be able to add user-defined taxonomies for use by JAXR clients. The mechanisms clients use to add and administer these taxonomies are implementation-specific. </p><a name="wp85271"> </a><p class="pBody">The implementation of JAXR in the J2EE Application Server uses a simple file-based approach to provide taxonomies to the JAXR client. These files are read at run time, when the JAXR provider starts up. </p><a name="wp93617"> </a><p class="pBody">The taxonomy structure for the J2EE Application Server is defined by the JAXR Predefined Concepts DTD, which is declared both in the file <code class="cCode">jaxrconcepts.dtd</code> and, in XML schema form, in the file <code class="cCode">jaxrconcepts.xsd</code>. The file <code class="cCode">jaxrconcepts.xml</code> contains the taxonomies for the implementation of JAXR in the J2EE Application Server. All these files are contained in the <code class="cCode">&lt;</code><code class="cVariable">J2EE_HOME</code><code class="cCode">&gt;/share/lib/jaxr-impl.jar</code> file. This JAR file also includes files that define the well-known taxonomies that the implementation of JAXR in the J2EE Application Server uses: <code class="cCode">naics.xml</code>, <code class="cCode">iso3166.xml</code>, and <code class="cCode">unspsc.xml</code>.</p><a name="wp89582"> </a><p class="pBody">The entries in the <code class="cCode">jaxrconcepts.xml</code> file look like this: </p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">&lt;PredefinedConcepts&gt;&lt;JAXRClassificationScheme id=&quot;<code class="cVariable">schId</code>&quot; name=&quot;<code class="cVariable">schName</code>&quot;&gt;&lt;JAXRConcept id=&quot;<code class="cVariable">schId</code>/<code class="cVariable">conCode</code>&quot; name=&quot;<code class="cVariable">conName</code>&quot; parent=&quot;<code class="cVariable">parentId</code>&quot; code=&quot;<code class="cVariable">conCode</code>&quot;&gt;&lt;/JAXRConcept&gt;...&lt;/JAXRClassificationScheme&gt;&lt;/PredefinedConcepts&gt;<a name="wp85274"> </a></pre></div><a name="wp85275"> </a><p class="pBody">The taxonomy structure is a containment-based structure. The element <code class="cCode">PredefinedConcepts</code> is the root of the structure and must be present. The <code class="cCode">JAXRClassificationScheme</code> element is the parent of the structure, and the <code class="cCode">JAXRConcept</code> elements are children and grandchildren. A <code class="cCode">JAXRConcept</code> element may have children, but it is not required to do so. </p><a name="wp85276"> </a><p class="pBody">In all element definitions, attribute order and case are significant. </p><a name="wp85277"> </a><p class="pBody">To add a user-defined taxonomy, follow these steps. </p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp89200"> </a><div class="pSmartList1"><li>Publish the <code class="cCode">JAXRClassificationScheme</code> element for the taxonomy as a <code class="cCode">ClassificationScheme</code> object in the registry that you will be accessing. For example, you can publish the <code class="cCode">ClassificationScheme</code> object to the Java WSDP Registry Server. In order to publish a <code class="cCode">ClassificationScheme</code> object, you must set its name. You also give the scheme a classification within a known classification scheme such as <code class="cCode">uddi-org:types</code>. In the following code fragment, the name is the first argument of the <code class="cCode">LifeCycleManager.createClassificationScheme</code> method call. </li></div><a name="wp89202"> </a><p class="pBodyRelative"><code class="cCode">ClassificationScheme cScheme = <br />&nbsp;&nbsp;blcm.createClassificationScheme(&quot;MyScheme&quot;, <br />&nbsp;&nbsp;&nbsp;&nbsp;&quot;A Classification Scheme&quot;);<br />ClassificationScheme uddiOrgTypes = <br />&nbsp;&nbsp;bqm.findClassificationSchemeByName(null, <br />&nbsp;&nbsp;&nbsp;&nbsp;&quot;uddi-org:types&quot;); <br />if (uddiOrgTypes != null) {<br />&nbsp;&nbsp;Classification classification = <br />&nbsp;&nbsp;&nbsp;&nbsp;blcm.createClassification(uddiOrgTypes,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;postalAddress&quot;, &quot;categorization&quot; );<br />&nbsp;&nbsp;postalScheme.addClassification(classification);<br />&nbsp;&nbsp;ExternalLink externalLink = <br />&nbsp;&nbsp;blcm.createExternalLink(<br />&nbsp;&nbsp;&nbsp;&nbsp;&quot;http://www.mycom.com/myscheme.html&quot;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&quot;My Scheme&quot;);<br />&nbsp;&nbsp;postalScheme.addExternalLink(externalLink);<br />&nbsp;&nbsp;Collection schemes = new ArrayList();<br />&nbsp;&nbsp;schemes.add(cScheme);<br />&nbsp;&nbsp;BulkResponse br = <br />&nbsp;&nbsp;&nbsp;&nbsp;blcm.saveClassificationSchemes(schemes);<br />}</code></p><a name="wp86798"> </a><p class="pBodyRelative">The <code class="cCode">BulkResponse</code> object returned by the <code class="cCode">saveClassificationSchemes</code> method contains the key for the classification scheme, which you need to retrieve:</p><a name="wp87653"> </a><p class="pBodyRelative"><code class="cCode">if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {<br />&nbsp;&nbsp;System.out.println(&quot;Saved ClassificationScheme&quot;);<br />&nbsp;&nbsp;Collection schemeKeys = br.getCollection();<br />&nbsp;&nbsp;Iterator keysIter = schemeKeys.iterator();<br />&nbsp;&nbsp;while (keysIter.hasNext()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;javax.xml.registry.infomodel.Key key =<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(javax.xml.registry.infomodel.Key)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keysIter.next();<br />&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;The postalScheme key is &quot; +<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key.getId());<br />&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Use this key as the scheme&quot; +<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot; uuid in the taxonomy file&quot;);<br />&nbsp;&nbsp;}<br />}</code></p><a name="wp85280"> </a><div class="pSmartList1"><li>In an XML file, define a taxonomy structure that is compliant with the JAXR Predefined Concepts DTD. Enter the <code class="cCode">ClassificationScheme</code> element in your taxonomy XML file by specifying the returned key ID value as the <code class="cCode">id</code> attribute and the name as the <code class="cCode">name</code> attribute. For the code fragment above, for example, the opening tag for the <code class="cCode">JAXRClassificationScheme</code> element looks something like this (all on one line):</li></div><a name="wp85281"> </a><p class="pBodyRelative"><code class="cCode">&lt;JAXRClassificationScheme <br />id=&quot;uuid:nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn&quot; <br />name=&quot;MyScheme&quot;&gt;</code></p><a name="wp85282"> </a><p class="pBodyRelative">The <code class="cCode">ClassificationScheme</code> <code class="cCode">id</code> must be a UUID.</p><a name="wp85283"> </a><div class="pSmartList1"><li>Enter each <code class="cCode">JAXRConcept</code> element in your taxonomy XML file by specifying the following four attributes, in this order:</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp85284"> </a><div class="pSmartList2"><li><code class="cCode">id</code> is the <code class="cCode">JAXRClassificationScheme</code> <code class="cCode">id</code> value, followed by a <code class="cCode">/</code> separator, followed by the code of the <code class="cCode">JAXRConcept</code> element</li></div><a name="wp85285"> </a><div class="pSmartList2"><li><code class="cCode">name</code> is the name of the <code class="cCode">JAXRConcept</code> element</li></div><a name="wp85286"> </a><div class="pSmartList2"><li><code class="cCode">parent</code> is the immediate parent <code class="cCode">id</code> (either the <code class="cCode">ClassificationScheme</code> <code class="cCode">id</code> or that of the parent <code class="cCode">JAXRConcept</code>)</li></div><a name="wp85287"> </a><div class="pSmartList2"><li><code class="cCode">code</code> is the <code class="cCode">JAXRConcept</code> element code value</li></div><a name="wp85288"> </a><p class="pBodyRelative">The first <code class="cCode">JAXRConcept</code> element in the <code class="cCode">naics.xml</code> file looks like this (all on one line):</p><a name="wp85289"> </a><p class="pBodyRelative"><code class="cCode">&lt;JAXRConcept <br />id=&quot;uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2/11&quot; <br />name=&quot;Agriculture, Forestry, Fishing and Hunting&quot; <br />parent=&quot;uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2&quot; <br />code=&quot;11&quot;&gt;&lt;/JAXRConcept&gt;</code></p></ol></div><a name="wp85290"> </a><div class="pSmartList1"><li>To add the user-defined taxonomy structure to the JAXR provider, specify the system property <code class="cCode">com.sun.xml.registry.userTaxonomyFilenames</code> when you run your client program. The command line (all on one line) would look like this. A vertical bar (<code class="cCode">|</code>) is the file separator.</li></di

⌨️ 快捷键说明

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