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 {
if (wsdlURL != null) {
definition = wsdlReader.readWSDL(wsdlURL.toString());
} else if (wsdlLocator != null) {
definition = wsdlReader.readWSDL(wsdlLocator);
} else {
throw new DeploymentException("unknown");
}
} catch (WSDLException e) {
throw new DeploymentException("Failed to read wsdl document", e);
} catch (RuntimeException e) {
throw new DeploymentException(e.getMessage(), e);
}
verifyPortComponentList(definition);
Map 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 = (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 wsdlPortMap = service.getPorts();
for (Iterator iterator = wsdlPortMap.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String portName = (String) entry.getKey();
Port 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());
}
boolean mtomEnabled = isMTOMEnabled(portType.getQName());
EndpointInfo info = new EndpointInfo(location, credentialsName, mtomEnabled);