protected void validateWsdl1(JmsSoapProviderMarshaler marshaler) throws WSDLException, IOException, DeploymentException {
Definition def = WSDLUtils.createWSDL11Reader().readWSDL(wsdl.getURL().toString());
if (validateWsdl) {
WSIBPValidator validator = new WSIBPValidator(def);
if (!validator.isValid()) {
throw new DeploymentException("WSDL is not WS-I BP compliant: " + validator.getErrors());
}
}
Service svc;
if (getService() != null) {
svc = def.getService(getService());
if (svc == null) {
throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
}
} else if (def.getServices().size() == 1) {
svc = (Service) def.getServices().values().iterator().next();
setService(svc.getQName());
} else {
throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
}
Port port;
if (getEndpoint() != null) {
port = svc.getPort(getEndpoint());
if (port == null) {
throw new DeploymentException("Cound not find port '" + getEndpoint() + "' "
+ "in wsdl for service '" + getService() + "'");
}
} else if (svc.getPorts().size() == 1) {
port = (Port) svc.getPorts().values().iterator().next();
setEndpoint(port.getName());
} else {
throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' "
+ "must contain a single port definition");
}
SOAPAddress sa11 = WSDLUtils.getExtension(port, SOAPAddress.class);
SOAP12Address sa12 = WSDLUtils.getExtension(port, SOAP12Address.class);
if (sa11 != null) {
marshaler.setBaseUrl(sa11.getLocationURI());
} else if (sa12 != null) {
marshaler.setBaseUrl(sa12.getLocationURI());
} else {
throw new DeploymentException("No SOAP address defined on port '" + port.getName() + "'");
}
description = WSDLUtils.getWSDL11Factory().newWSDLWriter().getDocument(def);
marshaler.setBinding(BindingFactory.createBinding(port));
}