use of org.apache.woden.WSDLSource in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method init.
/**
* {@inheritDoc}
* Will return true if the provided WSDL is of 2.0 and can be successfully parsed by woden library.
*/
@Override
public boolean init(byte[] wsdlContent) throws APIMgtWSDLException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
reader.setFeature(WSDLReader.FEATURE_VALIDATION, false);
Document dom = builder.parse(new ByteArrayInputStream(wsdlContent));
Element domElement = dom.getDocumentElement();
WSDLSource wsdlSource = reader.createWSDLSource();
wsdlSource.setSource(domElement);
wsdlDescription = reader.readWSDL(wsdlSource);
canProcess = true;
if (log.isDebugEnabled()) {
log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
}
} catch (WSDLException | ParserConfigurationException | SAXException | IOException e) {
// This implementation class cannot process the WSDL.
log.debug("Cannot process the WSDL by " + this.getClass().getName(), e);
canProcess = false;
}
return canProcess;
}
Aggregations