//Register a tModel for each portType
for (QName qName : bindings.keySet()) {
String localpart = qName.getLocalPart();
String namespace = qName.getNamespaceURI();
// Build the tModel
TModel tModel = new TModel();
// Set the Key
tModel.setTModelKey(keyDomainURI + localpart);
// Set the Name
Name name = new Name();
name.setLang(lang);
name.setValue(localpart);
tModel.setName(name);
// Set the OverviewURL
OverviewURL overviewURL = new OverviewURL();
overviewURL.setUseType(AccessPointType.WSDL_DEPLOYMENT.toString());
overviewURL.setValue(wsdlURL);
OverviewDoc overviewDoc = new OverviewDoc();
overviewDoc.setOverviewURL(overviewURL);
tModel.getOverviewDoc().add(overviewDoc);
// Set the categoryBag
CategoryBag categoryBag = new CategoryBag();
if (namespace != null && !"".equals(namespace)) {
// A keyedReference with a tModelKey of the WSDL Entity Type category system and a keyValue of "binding".
KeyedReference namespaceReference = newKeyedReference(
"uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", namespace);
categoryBag.getKeyedReference().add(namespaceReference);
}
// A keyedReference with a tModelKey of the WSDL Entity Type category system and a keyValue of "binding".
KeyedReference typesReference = newKeyedReference(
"uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "binding");
categoryBag.getKeyedReference().add(typesReference);
// A keyedReference with a tModelKey of the WSDL portType Reference category system and a keyValue
// of the tModelKey that models the wsdl:portType to which the wsdl:binding relates.
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);
// A keyedReference with a tModelKey of the UDDI Types category system and a keyValue of
// "wsdlSpec" for backward compatibility.
KeyedReference typesReferenceBackwardsCompatible = newKeyedReference(
"uddi:uddi.org:categorization:types", "uddi-org:types", "wsdlSpec");
categoryBag.getKeyedReference().add(typesReferenceBackwardsCompatible);
// One or two keyedReferences as required to capture the protocol
for (Object object : binding.getExtensibilityElements()) {
if (SOAPBinding.class.isAssignableFrom(object.getClass())) {
// If the wsdl:binding contains a soap:binding extensibility element from the
// 'http://schemas.xmlsoap.org/wsdl/soap/' namespace then the categoryBag MUST
//include a keyedReference with a tModelKey of the Protocol Categorization
// category system and a keyValue of the tModelKey of the SOAP Protocol tModel.
SOAPBinding soapBinding = (SOAPBinding) object;
KeyedReference soapProtocol = newKeyedReference(
"uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap");
categoryBag.getKeyedReference().add(soapProtocol);
// If the value of the transport attribute of the soap:binding element
// is 'http://schemas.xmlsoap.org/soap/http' then the categoryBag MUST
// include a keyedReference with a tModelKey of the Transport Categorization
// category system and a keyValue of the tModelKey of the HTTP Transport tModel.
if ("http://schemas.xmlsoap.org/soap/http".equals(soapBinding.getTransportURI())) {
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) {
// TODO If the value of the transport attribute is anything else,
// then the bindingTemplate MUST include an additional keyedReference with a tModelKey
// of the Transport Categorization category system and a keyValue of the tModelKey of
// an appropriate transport tModel.
log.warn("not implemented");
}
} else if (object.getClass().isInstance(HTTPBinding.class)) {
// If the wsdl:binding contains an http:binding extensibility element from the
// http://schemas.xmlsoap.org/wsdl/http/ namespace then the categoryBag MUST
// include a keyedReference with a tModelKey of the Protocol Categorization
// category system and a keyValue of the tModelKey of the HTTP Protocol tModel.
KeyedReference soapProtocol = newKeyedReference(
"uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:http", "uddi:uddi.org:protocol:http");
categoryBag.getKeyedReference().add(soapProtocol);
}
}
tModel.setCategoryBag(categoryBag);
tModels.add(tModel);
}
return tModels;
}