Search in sources :

Example 26 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project tdi-studio-se by Talend.

the class ServiceDiscoveryHelper method init.

/**
     * Read the wsdl and schema
     * 
     * @throws javax.wsdl.WSDLException
     */
private void init() throws WSDLException, IOException {
    wsdlFactory = WSDLFactory.newInstance();
    // wsdlFactory.
    WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
    newWSDLReader.setExtensionRegistry(wsdlFactory.newPopulatedExtensionRegistry());
    // newWSDLReader.getExtensionRegistry()
    newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
    if (configuration == null) {
        definition = newWSDLReader.readWSDL(wsdlUri);
    } else {
        definition = newWSDLReader.readWSDL(configuration.createWSDLLocator(wsdlUri));
    }
    definitions = findWsdlImport(definition, null, null, null);
}
Also used : WSDLReader(javax.wsdl.xml.WSDLReader)

Example 27 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project tdi-studio-se by Talend.

the class AllTypeDialog method initSimpleType.

private void initSimpleType() throws WSDLException, URISyntaxException {
    String url = URLValue;
    XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
    newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
    URI wsdlURI = new URI(url);
    Definition definition = newWSDLReader.readWSDL(url);
    java.util.List<ExtensibilityElement> extensibilityElements = definition.getTypes().getExtensibilityElements();
    String tmpTNName = "";
    int tmpCount = 0;
    for (ExtensibilityElement el : extensibilityElements) {
        if (el instanceof Schema) {
            Schema schema = (Schema) el;
            // for bug 8674
            // set base uri for relative path in schemaLocation.
            schemaCollection.setBaseUri(schema.getDocumentBaseURI());
            if (schema.getElement().getAttributeNode("targetNamespace") == null) {
                tmpTNName = schema.getDocumentBaseURI() + "#type" + tmpCount;
                schemaCollection.read(schema.getElement(), tmpTNName);
                tmpCount++;
            } else {
                schemaCollection.read(schema.getElement());
            }
        }
    }
    Map namespaces = definition.getNamespaces();
    // System.out.println(namespaces);
    XmlSchema[] schemas = schemaCollection.getXmlSchemas();
    java.util.List<String> labelList = new ArrayList<String>();
    for (int i = 0; i < schemas.length; i++) {
        XmlSchema schema = schemas[i];
        XmlSchemaObjectTable types = schema.getSchemaTypes();
        Iterator it = types.getValues();
        while (it.hasNext()) {
            XmlSchemaType type = (XmlSchemaType) it.next();
            if (type instanceof XmlSchemaSimpleType) {
                XmlSchemaSimpleType t = (XmlSchemaSimpleType) type;
                String label = "simpletype:" + t.getName();
                if (!labelList.contains(label)) {
                    labelList.add(label);
                    labelAndNameSpaceMap.put(label, t.getQName().toString());
                }
            }
        }
    }
    allXMLSimpleTypeName = new String[labelList.size()];
    for (int i = 0; i < labelList.size(); i++) {
        allXMLSimpleTypeName[i] = labelList.get(i);
    }
}
Also used : XmlSchemaObjectTable(org.apache.ws.commons.schema.XmlSchemaObjectTable) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Schema(javax.wsdl.extensions.schema.Schema) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) URI(java.net.URI) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) WSDLFactory(javax.wsdl.factory.WSDLFactory) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 28 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project Lucee by lucee.

the class JaxWSClient method loadWSDL.

private static Definition loadWSDL(URL url) throws WSDLException {
    WSDLFactory factory = WSDLFactory.newInstance();
    // create an object to read the WSDL file
    WSDLReader reader = factory.newWSDLReader();
    // pass the URL to the reader for parsing and get back a WSDL definiton
    return reader.readWSDL(url.toExternalForm());
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 29 with WSDLReader

use of javax.wsdl.xml.WSDLReader in project cxf by apache.

the class WSDLHelper method getDefinition.

public Definition getDefinition(File wsdlFile) throws Exception {
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader reader = wsdlFactory.newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    return reader.readWSDL(wsdlFile.toURI().toURL().toString());
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 30 with WSDLReader

use of javax.wsdl.xml.WSDLReader 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

WSDLReader (javax.wsdl.xml.WSDLReader)60 Definition (javax.wsdl.Definition)35 WSDLFactory (javax.wsdl.factory.WSDLFactory)25 WSDLException (javax.wsdl.WSDLException)16 URL (java.net.URL)15 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