public EndpointInfo buildEndpoint(ServiceInfo service, BindingInfo bi, Port port) {
List<?> elements = port.getExtensibilityElements();
String ns = null;
DestinationFactory factory = null;
EndpointInfo ei = null;
if (null != elements && elements.size() > 0) {
for (ExtensibilityElement el : CastUtils.cast(elements, ExtensibilityElement.class)) {
ns = el.getElementType().getNamespaceURI();
try {
factory = bus.getExtension(DestinationFactoryManager.class).getDestinationFactory(ns);
} catch (BusException e) {
// do nothing
}
if (factory != null) {
break;
}
}
if (factory == null) {
ns = ((ExtensibilityElement)elements.get(0)).getElementType().getNamespaceURI();
}
}
if (factory == null) { // get the transport id from bindingInfo
elements = port.getBinding().getExtensibilityElements();
if (null != elements && elements.size() > 0) {
for (ExtensibilityElement el : CastUtils.cast(elements, ExtensibilityElement.class)) {
if (el instanceof SOAPBinding) {
ns = ((SOAPBinding)el).getTransportURI();
break;
} else if (el instanceof SOAP12Binding) {
ns = ((SOAP12Binding)el).getTransportURI();
break;
// TODO: this is really ugly, but how to link between
// this binding and this transport ?
}
}
}
if (ns == null) {
if (ignoreUnknownBindings) {
return null;
}
org.apache.cxf.common.i18n.Message msg = new
org.apache.cxf.common.i18n.Message("MISSING_DESTINATION_FACTORY",
LOG,
port.getName());
throw new WSDLRuntimeException(msg);
}
try {
factory = bus.getExtension(DestinationFactoryManager.class).getDestinationFactory(ns);
} catch (BusException e) {
// do nothing
}
}
if (factory instanceof WSDLEndpointFactory) {
WSDLEndpointFactory wFactory = (WSDLEndpointFactory)factory;
ei = wFactory.createEndpointInfo(service, bi,
port.getExtensibilityElements());
}
if (ei == null) {
ei = new EndpointInfo(service, ns);
}
copyDocumentation(ei, port);
ei.setName(new QName(service.getName().getNamespaceURI(), port.getName()));
ei.setBinding(bi);
copyExtensors(ei, port.getExtensibilityElements());
copyExtensionAttributes(ei, port);
service.addEndpoint(ei);
DescriptionInfo d = service.getDescription();