WSDL2UDDI { public Set<TModel> createWSDLBindingTModels(String wsdlURL, Map<QName, Binding> bindings) throws WSDLException { Set<TModel> tModels = new HashSet<TModel>(); for (QName qName : bindings.keySet()) { String localpart = qName.getLocalPart(); String namespace = qName.getNamespaceURI(); TModel tModel = new TModel(); tModel.setTModelKey(keyDomainURI + localpart); Name name = new Name(); name.setLang(lang); name.setValue(localpart); tModel.setName(name); OverviewURL overviewURL = new OverviewURL(); overviewURL.setUseType(AccessPointType.WSDL_DEPLOYMENT.toString()); overviewURL.setValue(wsdlURL); OverviewDoc overviewDoc = new OverviewDoc(); overviewDoc.setOverviewURL(overviewURL); tModel.getOverviewDoc().add(overviewDoc); CategoryBag categoryBag = new CategoryBag(); if (namespace != null && !"".equals(namespace)) { KeyedReference namespaceReference = newKeyedReference( "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", namespace); categoryBag.getKeyedReference().add(namespaceReference); } KeyedReference typesReference = newKeyedReference( "uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "binding"); categoryBag.getKeyedReference().add(typesReference); Binding binding = bindings.get(qName); String portTypeKey = keyDomainURI + binding.getPortType().getQName().getLocalPart(); KeyedReference namespaceReference = newKeyedReference( "uddi:uddi.org:wsdl:porttypereference", "uddi-org:wsdl:portTypeReference", portTypeKey); categoryBag.getKeyedReference().add(namespaceReference); KeyedReference typesReferenceBackwardsCompatible = newKeyedReference( "uddi:uddi.org:categorization:types", "uddi-org:types", "wsdlSpec"); categoryBag.getKeyedReference().add(typesReferenceBackwardsCompatible); for (Object object : binding.getExtensibilityElements()) { SOAPBinding sb = null; SOAP12Binding sb12 = null; HTTPBinding hb = null; try { hb = (HTTPBinding) object; } catch (Exception x) { } try { sb = (SOAPBinding) object; } catch (Exception x) { } try { sb12 = (SOAP12Binding) object; } catch (Exception x) { } if (sb != null) { SOAPBinding soapBinding = sb; KeyedReference soapProtocol = newKeyedReference( "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap"); categoryBag.getKeyedReference().add(soapProtocol); if ("http: KeyedReference httpTransport = newKeyedReference( "uddi:uddi.org:wsdl:categorization:transport", "uddi-org:http", "uddi:uddi.org:transport:http"); categoryBag.getKeyedReference().add(httpTransport); } else if (soapBinding.getTransportURI() != null) { log.warn("not implemented, binding transport is " + soapBinding.getTransportURI()); } } else if (hb != null) { KeyedReference soapProtocol = newKeyedReference( "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:http", "uddi:uddi.org:protocol:http"); categoryBag.getKeyedReference().add(soapProtocol); } else if (sb12 != null) { KeyedReference soapProtocol = newKeyedReference( "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap"); categoryBag.getKeyedReference().add(soapProtocol); if ("http: KeyedReference httpTransport = newKeyedReference( "uddi:uddi.org:wsdl:categorization:transport", "uddi-org:http", "uddi:uddi.org:transport:http"); categoryBag.getKeyedReference().add(httpTransport); } else if (sb12.getTransportURI() != null) { log.warn("not implemented, binding transport is " + sb12.getTransportURI()); } } else { log.warn("Unrecongnized binding type: " + object.getClass().getCanonicalName() + ". Generated" + "binding tModel may be missing the required (according to WSDL2UDDI spec) " + "uddi:uddi.org:wsdl:categorization:protocol keyedReference."); } } tModel.setCategoryBag(categoryBag); tModels.add(tModel); } return tModels; } WSDL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties); BusinessServices registerBusinessServices(Definition wsdlDefinition); @SuppressWarnings("unchecked") ServiceRegistrationResponse registerBusinessService(QName serviceQName, String portName, URL serviceUrl, Definition wsdlDefinition); String[] unRegisterBusinessServices(Definition wsdlDefinition); String unRegisterBusinessService(QName serviceName, String portName, URL serviceUrl); String getKeyDomainURI(); void setKeyDomain(String keyDomainURI); String getLang(); void setLang(String lang); Set<TModel> createWSDLBindingTModels(String wsdlURL, Map<QName, Binding> bindings); Set<TModel> createWSDLPortTypeTModels(String wsdlURL, Map<QName, PortType> portTypes); static FindTModel createFindBindingTModelForPortType(String portType, String namespace); static FindTModel createFindPortTypeTModelForPortType(String portTypeName, String namespace); BusinessServices createBusinessServices(Definition wsdlDefinition);  }
@Test public void testWSDLBindingModel() throws WSDLException, JAXBException, ConfigurationException, Exception { Definition wsdlDefinition = rw.readWSDL("wsdl/HelloWorld.wsdl"); String wsdlURL = wsdlDefinition.getDocumentBaseURI(); Properties properties = new Properties(); properties.put("keyDomain", "juddi.apache.org"); WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties); Set<TModel> tModels = new HashSet<TModel>(); @SuppressWarnings("unchecked") Map<QName,Binding> bindings= (Map<QName,Binding>) wsdlDefinition.getAllBindings(); Set<TModel> bindingTModels = wsdl2UDDI.createWSDLBindingTModels(wsdlURL, bindings); tModels.addAll(bindingTModels); for (TModel tModel : tModels) { System.out.println("UDDI Binding TModel " + tModel.getName().getValue()); if (serialize) System.out.println(pTModel.print(tModel)); } Assert.assertEquals(1,tModels.size()); }