Search in sources :

Example 1 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project Activiti by Activiti.

the class WSDLImporter method parseWSDLDefinition.

/**
   * Parse the WSDL definition using WSDL4J.
   */
private Definition parseWSDLDefinition() throws WSDLException {
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader reader = wsdlFactory.newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    reader.setFeature("javax.wsdl.importDocuments", true);
    Definition definition = reader.readWSDL(this.wsdlLocation);
    return definition;
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 2 with WSDLReader

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

the class WSDL11ProcessorImpl method init.

/**
 * {@inheritDoc}
 * Will return true if the provided WSDL is of 1.1 and can be successfully parsed by WSDL4J.
 */
@Override
public boolean init(byte[] wsdlContent) throws APIMgtWSDLException {
    WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
    // switch off the verbose mode
    wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
    wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);
    try {
        wsdlDefinition = wsdlReader.readWSDL(null, new InputSource(new ByteArrayInputStream(wsdlContent)));
        canProcess = true;
        if (log.isDebugEnabled()) {
            log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
        }
    } 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 : InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) WSDLException(javax.wsdl.WSDLException) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 3 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project wso2-synapse by wso2.

the class ProxyServiceTest method testWSDLWithoutPublishWSDL.

/**
 * Test that a proxy service without publishWSDL will produce a meaningful WSDL.
 * This is a regression test for SYNAPSE-366.
 */
public void testWSDLWithoutPublishWSDL() throws Exception {
    // Build the proxy service
    SynapseConfiguration synCfg = new SynapseConfiguration();
    AxisConfiguration axisCfg = new AxisConfiguration();
    ProxyService proxyService = new ProxyService("Test");
    AxisService axisService = proxyService.buildAxisService(synCfg, axisCfg);
    // Serialize the WSDL
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    axisService.printWSDL(baos);
    // Check that the produced WSDL can be read by WSDL4J
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.readWSDL(null, new InputSource(new ByteArrayInputStream(baos.toByteArray())));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) AxisService(org.apache.axis2.description.AxisService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 4 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project wso2-synapse by wso2.

the class WSDL11EndpointBuilder method populateEndpointDefinitionFromWSDL.

/**
 * Creates an EndpointDefinition for WSDL endpoint from an inline WSDL supplied in the WSDL
 * endpoint configuration.
 *
 * @param endpointDefinition the endpoint definition to populate
 * @param baseUri base uri of the wsdl
 * @param wsdl    OMElement representing the inline WSDL
 * @param service Service of the endpoint
 * @param port    Port of the endpoint
 * @return EndpointDefinition containing the information retrieved from the WSDL
 */
public EndpointDefinition populateEndpointDefinitionFromWSDL(EndpointDefinition endpointDefinition, String baseUri, OMElement wsdl, String service, String port) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        wsdl.serialize(baos);
        InputStream in = new ByteArrayInputStream(baos.toByteArray());
        InputSource inputSource = new InputSource(in);
        WSDLLocator wsdlLocator = new CustomWSDLLocator(inputSource, baseUri);
        Document doc = null;
        try {
            doc = XMLUtils.newDocument(inputSource);
        } catch (ParserConfigurationException e) {
            handleException("Parser Configuration Error", e);
        } catch (SAXException e) {
            handleException("Parser SAX Error", e);
        } catch (IOException e) {
            handleException(WSDLException.INVALID_WSDL + "IO Error", e);
        }
        if (doc != null) {
            WSDLFactory fac = WSDLFactory.newInstance();
            WSDLReader reader = fac.newWSDLReader();
            Definition definition = reader.readWSDL(wsdlLocator, doc.getDocumentElement());
            return createEndpointDefinitionFromWSDL(endpointDefinition, definition, service, port);
        }
    } catch (XMLStreamException e) {
        handleException("Error retrieving the WSDL definition from the inline WSDL.", e);
    } catch (WSDLException e) {
        handleException("Error retrieving the WSDL definition from the inline WSDL.", e);
    }
    return null;
}
Also used : WSDLLocator(javax.wsdl.xml.WSDLLocator) CustomWSDLLocator(org.apache.synapse.util.resolver.CustomWSDLLocator) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) XMLStreamException(javax.xml.stream.XMLStreamException) ByteArrayInputStream(java.io.ByteArrayInputStream) WSDLFactory(javax.wsdl.factory.WSDLFactory) CustomWSDLLocator(org.apache.synapse.util.resolver.CustomWSDLLocator) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 5 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project carbon-business-process by wso2.

the class ArchiveBasedHumanTaskDeploymentUnitBuilder method readInTheWSDLFile.

/**
 * Read the WSDL file given the input stream for the WSDL source
 *
 * @param in           WSDL input stream
 * @param entryName    ZIP file entry name
 * @param fromRegistry whether the wsdl is read from registry
 * @return WSDL Definition
 * @throws javax.wsdl.WSDLException at parser error
 */
public static Definition readInTheWSDLFile(InputStream in, String entryName, boolean fromRegistry) throws WSDLException {
    WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
    // switch off the verbose mode for all usecases
    reader.setFeature(HumanTaskConstants.JAVAX_WSDL_VERBOSE_MODE_KEY, false);
    reader.setFeature("javax.wsdl.importDocuments", true);
    Definition def;
    Document doc;
    try {
        doc = XMLUtils.newDocument(in);
    } catch (ParserConfigurationException e) {
        throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Error", e);
    } catch (SAXException e) {
        throw new WSDLException(WSDLException.PARSER_ERROR, "Parser SAX Error", e);
    } catch (IOException e) {
        throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
    }
    // Log when and from where the WSDL is loaded.
    if (log.isDebugEnabled()) {
        log.debug("Reading 1.1 WSDL with base uri = " + entryName);
        log.debug("  the document base uri = " + entryName);
    }
    if (fromRegistry) {
        throw new UnsupportedOperationException("This operation is not currently " + "supported in this version of WSO2 BPS.");
    } else {
        def = reader.readWSDL(entryName, doc.getDocumentElement());
    }
    def.setDocumentBaseURI(entryName);
    return def;
}
Also used : WSDLException(javax.wsdl.WSDLException) Definition(javax.wsdl.Definition) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) HumanInteractionsDocument(org.wso2.carbon.humantask.HumanInteractionsDocument) HTDeploymentConfigDocument(org.wso2.carbon.humantask.core.deployment.config.HTDeploymentConfigDocument) Document(org.w3c.dom.Document) WSDLReader(javax.wsdl.xml.WSDLReader) SAXException(org.xml.sax.SAXException)

Aggregations

WSDLReader (javax.wsdl.xml.WSDLReader)59 Definition (javax.wsdl.Definition)35 WSDLFactory (javax.wsdl.factory.WSDLFactory)25 WSDLException (javax.wsdl.WSDLException)15 URL (java.net.URL)14 Test (org.junit.Test)13 Service (javax.wsdl.Service)8 File (java.io.File)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 JBossWSTest (org.jboss.wsf.test.JBossWSTest)7 Document (org.w3c.dom.Document)7 QName (javax.xml.namespace.QName)6 InputSource (org.xml.sax.InputSource)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Bus (org.apache.cxf.Bus)5 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)5 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4