List<ServiceInfo> services;
if (serviceName == null) {
try {
services = new WSDLServiceBuilder(getBus()).buildServices(definition);
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
if (services.size() == 0) {
throw new ServiceConstructionException(new Message("NO_SERVICE_EXC", LOG));
} else {
//@@TODO - this isn't good, need to return all the services
serviceName = services.get(0).getName();
//get all the service info's that match that first one.
Iterator<ServiceInfo> it = services.iterator();
while (it.hasNext()) {
if (!it.next().getName().equals(serviceName)) {
it.remove();
}
}
}
} else {
javax.wsdl.Service wsdlService = definition.getService(serviceName);
if (wsdlService == null) {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
try {
services = new WSDLServiceBuilder(getBus()).buildServices(definition,
wsdlService,
endpointName);
if (services.size() == 0) {
throw new ServiceConstructionException(
new Message("NO_SUCH_ENDPOINT_EXC", LOG, endpointName));
}
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
}
ServiceImpl service = new ServiceImpl(services);
setService(service);
return service;