Search in sources :

Example 31 with WSDLException

use of javax.wsdl.WSDLException in project iaf by ibissource.

the class SchemaLocation method setWsdl.

@IbisDoc({ "the wsdl to read the xsd's from", " " })
public void setWsdl(String wsdl) throws ConfigurationException {
    this.wsdl = wsdl;
    WSDLReader reader = FACTORY.newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    reader.setFeature("javax.wsdl.importDocuments", true);
    ClassLoaderWSDLLocator wsdlLocator = new ClassLoaderWSDLLocator(this, wsdl);
    URL url = wsdlLocator.getUrl();
    if (wsdlLocator.getUrl() == null) {
        throw new ConfigurationException("Could not find WSDL: " + wsdl);
    }
    try {
        definition = reader.readWSDL(wsdlLocator);
    } catch (WSDLException e) {
        throw new ConfigurationException("WSDLException reading WSDL or import from url: " + url, e);
    }
    if (wsdlLocator.getIOException() != null) {
        throw new ConfigurationException("IOException reading WSDL or import from url: " + url, wsdlLocator.getIOException());
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) WSDLException(javax.wsdl.WSDLException) WSDLReader(javax.wsdl.xml.WSDLReader) URL(java.net.URL) IbisDoc(nl.nn.adapterframework.doc.IbisDoc)

Example 32 with WSDLException

use of javax.wsdl.WSDLException in project Activiti by Activiti.

the class WSDLImporter method importFrom.

public void importFrom(String url) {
    this.wsServices.clear();
    this.wsOperations.clear();
    this.structures.clear();
    this.wsdlLocation = url;
    try {
        Definition definition = this.parseWSDLDefinition();
        this.importServicesAndOperations(definition);
        this.importTypes(definition.getTypes());
    } catch (WSDLException e) {
        throw new ActivitiException(e.getMessage(), e);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) WSDLException(javax.wsdl.WSDLException) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) Definition(javax.wsdl.Definition)

Example 33 with WSDLException

use of javax.wsdl.WSDLException in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getWSDLByteArrayOutputStream.

/**
 * Retrieves a {@link ByteArrayOutputStream} for provided {@link Definition}.
 *
 * @param definition WSDL Definition
 * @return A {@link ByteArrayOutputStream} for provided {@link Definition}
 * @throws APIMgtWSDLException If an error occurs while creating {@link ByteArrayOutputStream}
 */
private ByteArrayOutputStream getWSDLByteArrayOutputStream(Definition definition) throws APIMgtWSDLException {
    WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try {
        writer.writeWSDL(definition, byteArrayOutputStream);
    } catch (WSDLException e) {
        throw new APIMgtWSDLException("Error while stringifying WSDL definition", e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
    }
    return byteArrayOutputStream;
}
Also used : APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) WSDLException(javax.wsdl.WSDLException) WSDLWriter(javax.wsdl.xml.WSDLWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 34 with WSDLException

use of javax.wsdl.WSDLException in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getUpdatedWSDLPath.

/**
 * Updates the endpoints of all the WSDL files in the path based on the provided API (context) and Label (host).
 *
 * @param api   Provided API object
 * @param label Provided label object
 * @return Updated WSDL file path
 * @throws APIMgtWSDLException Error while updating WSDL files
 */
@Override
public String getUpdatedWSDLPath(API api, Label label) throws APIMgtWSDLException {
    if (label != null) {
        for (Map.Entry<String, Definition> entry : pathToDefinitionMap.entrySet()) {
            Definition definition = entry.getValue();
            if (log.isDebugEnabled()) {
                log.debug("Updating endpoints of WSDL: " + entry.getKey());
            }
            updateEndpoints(label.getAccessUrls(), api, definition);
            if (log.isDebugEnabled()) {
                log.debug("Successfully updated endpoints of WSDL: " + entry.getKey());
            }
            try (FileOutputStream wsdlFileOutputStream = new FileOutputStream(new File(entry.getKey()))) {
                WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
                writer.writeWSDL(definition, wsdlFileOutputStream);
            } catch (IOException | WSDLException e) {
                throw new APIMgtWSDLException("Failed to create WSDL archive for API:" + api.getName() + ":" + api.getVersion() + " for label " + label.getName(), ExceptionCodes.ERROR_WHILE_CREATING_WSDL_ARCHIVE);
            }
        }
    }
    return wsdlArchiveExtractedPath;
}
Also used : APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) WSDLException(javax.wsdl.WSDLException) FileOutputStream(java.io.FileOutputStream) Definition(javax.wsdl.Definition) WSDLWriter(javax.wsdl.xml.WSDLWriter) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) File(java.io.File)

Example 35 with WSDLException

use of javax.wsdl.WSDLException in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method initPath.

/**
 * {@inheritDoc}
 * Will return true if all the provided WSDL files in the initialized path is of 1.1 and can be successfully
 * parsed by WSDL4J.
 */
@Override
public boolean initPath(String path) throws APIMgtWSDLException {
    pathToDefinitionMap = new HashMap<>();
    wsdlArchiveExtractedPath = path;
    WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
    // switch off the verbose mode
    wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
    wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);
    try {
        File folderToImport = new File(path);
        Collection<File> foundWSDLFiles = APIFileUtils.searchFilesWithMatchingExtension(folderToImport, "wsdl");
        if (log.isDebugEnabled()) {
            log.debug("Found " + foundWSDLFiles.size() + " WSDL file(s) in path " + path);
        }
        for (File file : foundWSDLFiles) {
            String absWSDLPath = file.getAbsolutePath();
            if (log.isDebugEnabled()) {
                log.debug("Processing WSDL file: " + absWSDLPath);
            }
            Definition definition = wsdlReader.readWSDL(null, absWSDLPath);
            pathToDefinitionMap.put(absWSDLPath, definition);
        }
        if (foundWSDLFiles.size() > 0) {
            canProcess = true;
        }
        if (log.isDebugEnabled()) {
            log.debug("Successfully processed all WSDL files in path " + path);
        }
    } catch (WSDLException e) {
        // This implementation class cannot process the WSDL.
        log.debug("Cannot process the WSDL by " + this.getClass().getName(), e);
        canProcess = false;
    }
    return canProcess;
}
Also used : APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) WSDLException(javax.wsdl.WSDLException) Definition(javax.wsdl.Definition) File(java.io.File) WSDLReader(javax.wsdl.xml.WSDLReader)

Aggregations

WSDLException (javax.wsdl.WSDLException)56 ToolException (org.apache.cxf.tools.common.ToolException)18 WSDLReader (javax.wsdl.xml.WSDLReader)14 IOException (java.io.IOException)13 Definition (javax.wsdl.Definition)12 Message (org.apache.cxf.common.i18n.Message)12 QName (javax.xml.namespace.QName)11 WSDLWriter (javax.wsdl.xml.WSDLWriter)10 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)7 File (java.io.File)6 Writer (java.io.Writer)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)6 Document (org.w3c.dom.Document)6 URL (java.net.URL)5 WSDLManager (org.apache.cxf.wsdl.WSDLManager)5 XMLStreamException (javax.xml.stream.XMLStreamException)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3