Search in sources :

Example 6 with WSDL11ProcessorImpl

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);
    }
}
Also used : WSDLProcessor(org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) WSDL20ProcessorImpl(org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl) WSDL11ProcessorImpl(org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl)

Example 7 with WSDL11ProcessorImpl

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);
        }
    }
}
Also used : WSDLProcessor(org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) WSDL20ProcessorImpl(org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl) WSDL11ProcessorImpl(org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl)

Aggregations

Test (org.testng.annotations.Test)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 WSDL11ProcessorImpl (org.wso2.carbon.apimgt.impl.wsdl.WSDL11ProcessorImpl)3 WSDL20ProcessorImpl (org.wso2.carbon.apimgt.impl.wsdl.WSDL20ProcessorImpl)3 WSDLProcessor (org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor)3 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)3 WSDLProcessor (org.wso2.carbon.apimgt.core.api.WSDLProcessor)2 API (org.wso2.carbon.apimgt.core.models.API)2 Label (org.wso2.carbon.apimgt.core.models.Label)2