public ServiceRegistrationResponse registerBusinessService(QName serviceQName, String portName, URL serviceUrl, Definition wsdlDefinition) throws RemoteException, ConfigurationException, TransportException, WSDLException, MalformedURLException {
String genericWSDLURL = wsdlDefinition.getDocumentBaseURI(); //TODO maybe point to repository version
ServiceRegistrationResponse response = new ServiceRegistrationResponse();
String serviceKey = UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart());
BusinessService businessService = lookupService(serviceKey);
if (businessService == null) {
List<TModel> tModels = new ArrayList<TModel>();
// Create the PortType tModels
Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
tModels.addAll(createWSDLPortTypeTModels(genericWSDLURL, portTypes));
// Create the Binding tModels
Map<QName, Binding> bindings = (Map<QName, Binding>) wsdlDefinition.getAllBindings();
tModels.addAll(createWSDLBindingTModels(genericWSDLURL, bindings));
// Register these tModels
for (TModel tModel : tModels) {
clerk.register(tModel);
}
// Service
businessService = createBusinessService(serviceQName, wsdlDefinition);
// Register this Service
clerk.register(businessService);
}
//Add the BindingTemplate to this Service
BindingTemplate binding = createWSDLBinding(serviceQName, portName, serviceUrl, wsdlDefinition);
// Register BindingTemplate
if (binding.getAccessPoint() != null) {
clerk.register(binding);
if (businessService.getBindingTemplates() == null) {
businessService.setBindingTemplates(new BindingTemplates());
}
businessService.getBindingTemplates().getBindingTemplate().add(binding);
response.setBindingKey(binding.getBindingKey());
}
response.setBusinessService(businessService);
return response;
}