try {
url = StringUtils.getURL(null, wsdlURI);
} catch (MalformedURLException e) {
String msg = getErrorReporter().getFormattedMessage(
"WSDL502", new Object[] {null, wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
String wsdlURL = url.toString();
OMElement root = null;
// perform URI Resolution here
try {
root = OMUtils.getElement(resolveURI(wsdlURL));
} catch (IOException e){
String msg = getErrorReporter().getFormattedMessage(
"WSDL503", new Object[] {wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
} catch (URISyntaxException e){
String msg = getErrorReporter().getFormattedMessage(
"WSDL502", new Object[] {null, wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
} catch (XMLStreamException e){
String msg = getErrorReporter().getFormattedMessage(
"WSDL500", new Object[] {"XML", wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
//Try to find an element the XPointer points to if a Fragment Identifier exists.
URI uri = null;
try {
uri = new URI(wsdlURI);
} catch (URISyntaxException e) {
String msg = getErrorReporter().getFormattedMessage(
"WSDL506", new Object[] {wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
String fragment = uri.getFragment();
if (fragment == null) { //No fragment identifier so just use the root element.
XMLElement descEl = createXMLElement(root);
DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
return descElem.toComponent();
} else {
XPointer xpointer;
try {
xpointer = new XPointer(fragment);
} catch(InvalidXPointerException e) {
String msg = getErrorReporter().getFormattedMessage(
"WSDL530", new Object[] {fragment, wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
OMXMLElementEvaluator evaluator = new OMXMLElementEvaluator(xpointer, root, getErrorReporter());
OMElement result = evaluator.evaluateElement();
if (result != null) { //Element from XPointer evaluation.
XMLElement descEl = createXMLElement(result);
DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
return descElem.toComponent();
} else {
String msg = getErrorReporter().getFormattedMessage(
"WSDL531", new Object[] {fragment, wsdlURI});
throw new WSDLException(WSDLException.PARSER_ERROR, msg);
}
}
}