Search in sources :

Example 16 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader 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)

Example 17 with APIMWSDLReader

use of org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader in project carbon-apimgt by wso2.

the class APIMWSDLReader method getWSDLSOAPOperationExtractor.

/**
 * Returns a WSDL11SOAPOperationExtractor for the url {@code url}. Only WSDL 1.1 is supported.
 *
 * @param wsdlPath File path containing WSDL files and dependant files
 * @return WSDL11SOAPOperationExtractor for the provided URL
 * @throws APIManagementException If an error occurs while determining the processor
 */
public static WSDL11SOAPOperationExtractor getWSDLSOAPOperationExtractor(String wsdlPath, APIMWSDLReader wsdlReader) throws APIManagementException {
    WSDL11SOAPOperationExtractor processor = new WSDL11SOAPOperationExtractor();
    processor.loadXSDs(wsdlReader, wsdlPath);
    processor.initPath(wsdlPath);
    return processor;
}
Also used : WSDL11SOAPOperationExtractor(org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor)

Aggregations

APIMWSDLReader (org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader)11 Test (org.junit.Test)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)6 ModelImpl (io.swagger.models.ModelImpl)4 Definition (javax.wsdl.Definition)3 API (org.wso2.carbon.apimgt.api.model.API)3 WSDL11SOAPOperationExtractor (org.wso2.carbon.apimgt.impl.wsdl.WSDL11SOAPOperationExtractor)3 Document (org.w3c.dom.Document)2 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)2 WSDLProcessor (org.wso2.carbon.apimgt.impl.wsdl.WSDLProcessor)2 WSDLSOAPOperation (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)2 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 OMElement (org.apache.axiom.om.OMElement)1