📄 jaxrpublishhelloorg.java
字号:
} else { cScheme = bqm.findClassificationSchemeByName(null, schemeName); } // Create services and service Collection services = new ArrayList(); Service service = blcm.createService(bundle.getString("wsdlorg.svc.name")); is = blcm.createInternationalString(bundle.getString( "wsdlorg.svc.description")); service.setDescription(is); // Create service bindings Collection serviceBindings = new ArrayList(); ServiceBinding binding = blcm.createServiceBinding(); is = blcm.createInternationalString(bundle.getString( "wsdlorg.svcbnd.description")); binding.setDescription(is); binding.setAccessURI(bundle.getString("wsdlorg.svcbnd.uri")); // Define name pattern Collection namePatterns = new ArrayList(); namePatterns.add(bundle.getString("concept.name")); /* * Create a classification, specifying the scheme * and the taxonomy name and value defined for WSDL * documents by the UDDI specification. */ schemeName = "uddi-org:types"; // workaround while IBM has two uddi-org:types schemes ClassificationScheme uddiOrgTypes = null; queryURL = bundle.getString("query.url"); String uuid_types = "UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4"; if (queryURL.equals("http://uddi.ibm.com/testregistry/inquiryapi")) { uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types, LifeCycleManager.CLASSIFICATION_SCHEME); } else { uddiOrgTypes = bqm.findClassificationSchemeByName(null, schemeName); } Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes, "wsdlSpec", "wsdlSpec"); // Define classifications Collection classifications = new ArrayList(); classifications.add(wsdlSpecClassification); // Find concepts named "HelloConcept" by name and classification BulkResponse br = bqm.findConcepts(null, namePatterns, classifications, null, null); Collection specConcepts = br.getCollection(); // Find the concept that matches the concept key argument Iterator iter = specConcepts.iterator(); Concept retConcept = null; if (!iter.hasNext()) { System.out.println("No WSDL specification concepts found"); } else { while (iter.hasNext()) { Concept testConcept = (Concept) iter.next(); String testId = getKey(testConcept); if (testId.equals(uuidString)) { retConcept = testConcept; } } } // If we found the concept, we can save the organization if (retConcept != null) { String name = getName(retConcept); Collection links = retConcept.getExternalLinks(); System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(retConcept)); if (links.size() > 0) { ExternalLink link = (ExternalLink) links.iterator() .next(); System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'"); } // Now set the specification link for the service binding SpecificationLink specLink = blcm.createSpecificationLink(); specLink.setSpecificationObject(retConcept); binding.addSpecificationLink(specLink); serviceBindings.add(binding); // Add service bindings to service service.addServiceBindings(serviceBindings); // Add service to services, then add services to organization services.add(service); org.addServices(services); // Add organization and submit to registry // Retrieve key if successful Collection orgs = new ArrayList(); orgs.add(org); BulkResponse response = blcm.saveOrganizations(orgs); Collection exceptions = response.getExceptions(); if (exceptions == null) { System.out.println("Organization saved"); Collection keys = response.getCollection(); Iterator keyIter = keys.iterator(); if (keyIter.hasNext()) { javax.xml.registry.infomodel.Key orgKey = (javax.xml.registry.infomodel.Key) keyIter.next(); String id = orgKey.getId(); System.out.println("Organization key is " + id); } } else { Iterator excIter = exceptions.iterator(); Exception exception = null; while (excIter.hasNext()) { exception = (Exception) excIter.next(); System.err.println("Exception on save: " + exception.toString()); } } } else { System.out.println("Specified concept not found, " + "organization not saved"); } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } } /** * Returns the name value for a registry object. * * @param ro a RegistryObject * @return the String value */ private String getName(RegistryObject ro) throws JAXRException { try { return ro.getName() .getValue(); } catch (NullPointerException npe) { return "No Name"; } } /** * Returns the description value for a registry object. * * @param ro a RegistryObject * @return the String value */ private String getDescription(RegistryObject ro) throws JAXRException { try { return ro.getDescription() .getValue(); } catch (NullPointerException npe) { return "No Description"; } } /** * Returns the key id value for a registry object. * * @param ro a RegistryObject * @return the String value */ private String getKey(RegistryObject ro) throws JAXRException { try { return ro.getKey() .getId(); } catch (NullPointerException npe) { return "No Key"; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -