String portName = gerPort.getPortName().trim();
URL location = getLocation(gerPort);
String credentialsName = getCredentialsName(gerPort);
List<WebServiceFeatureInfo> webServiceFeatureInfos = getWebServiceFeatureInfos(portName);
Map<String, Object> props = getProperties(gerPort);
EndpointInfo info = new EndpointInfo(location, credentialsName, props, webServiceFeatureInfos);
this.portInfoMap.put(portName, info);
}
}
return;
} else {
// Generated Service class specified.
// Get the wsdl and service qname from the WebServiceClient annotation
// of the generated Service class
WebServiceClient webServiceClient =
(WebServiceClient) this.serviceClass.getAnnotation(WebServiceClient.class);
if (webServiceClient != null) {
this.wsdlURI = getWSDLLocation(webServiceClient);
this.serviceQName = getServiceQName(webServiceClient);
}
// wsdl really shouldn't be null at this point
if (this.wsdlURI == null) {
return;
}
}
}
Catalog catalog = loadCatalog();
WSDLLocator wsdlLocator = null;
if (isURL(this.wsdlURI.toString())) {
wsdlLocator = new CatalogWSDLLocator(this.wsdlURI.toString(), catalog);
} else {
wsdlLocator = new CatalogJarWSDLLocator(this.module.getModuleFile(), this.wsdlURI, catalog);
}
Definition definition;
WSDLFactory wsdlFactory;
try {
wsdlFactory = WSDLFactory.newInstance();
} catch (WSDLException e) {
throw new DeploymentException("Could not create WSDLFactory", e);
}
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.importDocuments", true);
wsdlReader.setFeature("javax.wsdl.verbose", false);
try {
definition = wsdlReader.readWSDL(wsdlLocator);
} catch (WSDLException e) {
throw new DeploymentException("Failed to read wsdl document", e);
} catch (RuntimeException e) {
throw new DeploymentException(e.getMessage(), e);
}
verifyPortComponentList(definition);
Map<QName, Service> services = definition.getServices();
if (services.size() == 0) {
// partial wsdl, return as is
if (this.serviceRefType != null && this.serviceRefType.isSetServiceCompletion()) {
LOG.warn("Service completion is not supported with partial wsdl");
}
} else {
// full wsdl
if (this.serviceRefType != null && this.serviceRefType.isSetServiceCompletion()) {
throw new DeploymentException("Full wsdl, but service completion supplied");
}
Service service = null;
if (this.serviceQName != null) {
service = definition.getService(this.serviceQName);
if (service == null) {
throw new DeploymentException(
"No service wsdl for supplied service qname "
+ this.serviceQName);
}
} else if (services.size() == 1) {
service = services.values().iterator().next();
this.serviceQName = service.getQName();
} else {
throw new DeploymentException(
"No service qname supplied, and there are "
+ services.size() + " services");
}
// organize the extra port info
Map<String, GerPortType> portMap = new HashMap<String, GerPortType>();
if (serviceRefType != null) {
GerPortType[] ports = serviceRefType.getPortArray();
for (int i = 0; i < ports.length; i++) {
GerPortType port = ports[i];
String portName = port.getPortName().trim();
portMap.put(portName, port);
}
}
Map<String, Port> wsdlPortMap = service.getPorts();
for (Map.Entry<String, Port> entry : wsdlPortMap.entrySet()) {
String portName = entry.getKey();
Port port = entry.getValue();
GerPortType gerPort = portMap.get(portName);
URL location = (gerPort == null) ? getAddressLocation(port) : getLocation(gerPort);
// skip non-soap ports
if (location == null) {
continue;
}
String credentialsName = (gerPort == null) ? null : getCredentialsName(gerPort);
Binding binding = port.getBinding();
if (binding == null) {
throw new DeploymentException("No binding for port: " + portName);
}
PortType portType = binding.getPortType();
if (portType == null) {
throw new DeploymentException("No portType for binding: " + binding.getQName());
}
Map<String, Object> props = getProperties(gerPort);
List<WebServiceFeatureInfo> webServiceFeatureInfo = getWebServiceFeatureInfos(portType.getQName());
EndpointInfo info = new EndpointInfo(location, credentialsName, props, webServiceFeatureInfo);
this.portInfoMap.put(portName, info);
// prefer first binding listed in wsdl
if (!this.portInfoMap.containsKey(portType.getQName())) {
this.portInfoMap.put(portType.getQName(), info);
}