* @return
* @throws WSDLException
*/
private Definition readWSDL(String uri) throws WSDLException {
WSDLReader reader =
WSDLFactory.newInstance().newWSDLReader();
reader.setFeature("javax.wsdl.importDocuments", true);
File file = new File(uri);
String baseURI;
if (uri.startsWith("http://")){
baseURI = uri;
} else{
if(file.getParentFile() == null){
try {
baseURI = new File(".").getCanonicalFile().toURI().toString();
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
baseURI = file.getParentFile().toURI().toString();
}
}
Document doc;
try {
doc = XMLUtils.newDocument(uri);
} catch (ParserConfigurationException e) {
throw new WSDLException(WSDLException.PARSER_ERROR,
"Parser Configuration Error",
e);
} catch (SAXException e) {
throw new WSDLException(WSDLException.PARSER_ERROR,
"Parser SAX Error",
e);
} catch (IOException e) {
throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
}
return reader.readWSDL(baseURI, doc);
}