bindingTemplate.setBindingKey(bindingKey);
}
Service service = wsdlDefinition.getService(serviceQName);
if (service != null) {
TModelInstanceDetails tModelInstanceDetails = new TModelInstanceDetails();
Port port = service.getPort(portName);
if (port != null) {
if (serviceUrl == null) {
for (Object element : port.getExtensibilityElements()) {
String location = null;
if (element instanceof SOAPAddress) {
SOAPAddress address = (SOAPAddress) element;
location = urlLocalizer.rewrite(new URL(address.getLocationURI()));
} else if (element instanceof HTTPAddress) {
HTTPAddress address = (HTTPAddress) element;
urlLocalizer.rewrite(new URL(location = address.getLocationURI()));
} else if (element instanceof SOAP12Address) {
SOAP12Address address = (SOAP12Address) element;
location = urlLocalizer.rewrite(new URL(address.getLocationURI()));
}
if (location != null) {
try {
URL locationURI = new URL(location);
AccessPoint accessPoint = new AccessPoint();
accessPoint.setUseType(AccessPointType.END_POINT.toString());
accessPoint.setValue(urlLocalizer.rewrite(locationURI));
bindingTemplate.setAccessPoint(accessPoint);
// Set Binding Key
String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceQName, portName, locationURI);
bindingTemplate.setBindingKey(bindingKey);
break;
} catch (MalformedURLException e) {
log.error(e.getMessage());
}
}
}
}
Binding binding = port.getBinding();
// Set the Binding Description
String bindingDescription = properties.getProperty(Property.BINDING_DESCRIPTION, Property.DEFAULT_BINDING_DESCRIPTION);
// Override with the service description from the WSDL if present
Element docElement = binding.getDocumentationElement();
if (docElement != null && docElement.getTextContent() != null) {
bindingDescription = docElement.getTextContent();
}
bindingTemplate.getDescription().addAll(Common2UDDI.mapDescription(bindingDescription, lang));
// reference wsdl:binding tModel
TModelInstanceInfo tModelInstanceInfoBinding = new TModelInstanceInfo();
tModelInstanceInfoBinding.setTModelKey(keyDomainURI + binding.getQName().getLocalPart());
InstanceDetails instanceDetails = new InstanceDetails();
instanceDetails.setInstanceParms(portName);
tModelInstanceInfoBinding.setInstanceDetails(instanceDetails);
tModelInstanceInfoBinding.getDescription().addAll(Common2UDDI.mapDescription("The wsdl:binding that this wsdl:port implements. " + bindingDescription
+ " The instanceParms specifies the port local name.", lang));
tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoBinding);
// reference wsdl:portType tModel
PortType portType = binding.getPortType();
TModelInstanceInfo tModelInstanceInfoPortType = new TModelInstanceInfo();
tModelInstanceInfoPortType.setTModelKey(keyDomainURI + portType.getQName().getLocalPart());
String portTypeDescription = "";
docElement = portType.getDocumentationElement();
if (docElement != null && docElement.getTextContent() != null) {
portTypeDescription = docElement.getTextContent();
}
tModelInstanceInfoPortType.getDescription().addAll(Common2UDDI.mapDescription("The wsdl:portType that this wsdl:port implements." + portTypeDescription, lang));
tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoPortType);
bindingTemplate.setTModelInstanceDetails(tModelInstanceDetails);
} else {
log.error("Could not find Port with portName: " + portName);
}