use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl in project carbon-apimgt by wso2.
the class APIMWSDLReader method getWSDLProcessorForUrl.
/**
* Returns the appropriate WSDL 1.1/WSDL 2.0 based on the url {@code url}.
*
* @param url WSDL url
* @return WSDL 1.1/2.0 processor for the provided content
* @throws APIManagementException If an error occurs while determining the processor
*/
public static WSDLProcessor getWSDLProcessorForUrl(URL url) throws APIManagementException {
WSDLProcessor wsdl11Processor = new WSDL11ProcessorImpl();
WSDLProcessor wsdl20Processor = new WSDL20ProcessorImpl();
try {
if (wsdl11Processor.canProcess(url)) {
wsdl11Processor.init(url);
return wsdl11Processor;
} else if (wsdl20Processor.canProcess(url)) {
wsdl20Processor.init(url);
return wsdl20Processor;
} else {
// no processors found if this line reaches
throw new APIManagementException("No WSDL processor found to process WSDL url: " + url, ExceptionCodes.URL_NOT_RECOGNIZED_AS_WSDL);
}
} catch (APIMgtWSDLException e) {
throw new APIManagementException("Error while instantiating wsdl processor class", e);
}
}
use of org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl in project carbon-apimgt by wso2.
the class APIMWSDLReader method getWSDLProcessor.
/**
* Returns the appropriate WSDL 1.1/WSDL 2.0 based on the file path {@code wsdlPath}.
*
* @param wsdlPath File path containing WSDL files and dependant files
* @return WSDL 1.1/2.0 processor for the provided content
* @throws APIManagementException If an error occurs while determining the processor
*/
public static WSDLProcessor getWSDLProcessor(String wsdlPath) throws APIManagementException {
WSDLProcessor wsdl11Processor = new WSDL11ProcessorImpl();
WSDLProcessor wsdl20Processor = new WSDL20ProcessorImpl();
byte[] wsdlContent;
APIMWSDLReader wsdlReader;
if (wsdlPath.endsWith(".wsdl") || wsdlPath.endsWith("?wsdl")) {
wsdlReader = new APIMWSDLReader(wsdlPath);
wsdlContent = wsdlReader.getWSDL();
return getWSDLProcessor(wsdlContent);
} else {
try {
if (wsdl11Processor.canProcess(wsdlPath)) {
wsdl11Processor.initPath(wsdlPath);
return wsdl11Processor;
} else if (wsdl20Processor.canProcess(wsdlPath)) {
wsdl20Processor.initPath(wsdlPath);
return wsdl20Processor;
} else {
// no processors found if this line reaches
throw new APIManagementException("No WSDL processor found to process WSDL content.", ExceptionCodes.CONTENT_NOT_RECOGNIZED_AS_WSDL);
}
} catch (APIMgtWSDLException e) {
throw new APIManagementException("Error while instantiating wsdl processor class", e);
}
}
}
Aggregations