Search in sources :

Example 6 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 7 with WSDLReader

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

the class WsDeployer method readWsdl.

// don't put it in ReadDescriptors to respect classloader dependencies (wsdl4j is optional)
public static Definition readWsdl(final URL url) throws OpenEJBException {
    final Definition definition;
    try {
        final WSDLFactory factory = WSDLFactory.newInstance();
        final WSDLReader reader = factory.newWSDLReader();
        reader.setFeature("javax.wsdl.verbose", true);
        reader.setFeature("javax.wsdl.importDocuments", true);
        final WsdlResolver wsdlResolver = new WsdlResolver(new URL(url, ".").toExternalForm(), new InputSource(IO.read(url)));
        definition = reader.readWSDL(wsdlResolver);
    } catch (final IOException e) {
        throw new OpenEJBException("Cannot read the wsdl file: " + url.toExternalForm(), e);
    } catch (final Exception e) {
        throw new OpenEJBException("Encountered unknown error parsing the wsdl file: " + url.toExternalForm(), e);
    }
    return definition;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) InputSource(org.xml.sax.InputSource) WSDLFactory(javax.wsdl.factory.WSDLFactory) WsdlResolver(org.apache.openejb.core.webservices.WsdlResolver) Definition(javax.wsdl.Definition) IOException(java.io.IOException) WSDLReader(javax.wsdl.xml.WSDLReader) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) OpenEJBException(org.apache.openejb.OpenEJBException) IOException(java.io.IOException)

Example 8 with WSDLReader

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

the class CommonsSchemaLoader method readWsdl.

private Definition readWsdl(URI wsdlURI) throws OpenEJBException {
    Definition definition;
    WSDLFactory wsdlFactory;
    try {
        wsdlFactory = WSDLFactory.newInstance();
    } catch (WSDLException e) {
        throw new OpenEJBException("Could not create WSDLFactory", e);
    }
    WSDLReader wsdlReaderNoImport = wsdlFactory.newWSDLReader();
    wsdlReaderNoImport.setFeature("javax.wsdl.importDocuments", false);
    ExtensionRegistry extensionRegistry = new PopulatedExtensionRegistry();
    extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_1999, UnknownExtensibilityElement.class);
    extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999, extensionRegistry.getDefaultDeserializer());
    extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999, extensionRegistry.getDefaultSerializer());
    extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2000, UnknownExtensibilityElement.class);
    extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000, extensionRegistry.getDefaultDeserializer());
    extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000, extensionRegistry.getDefaultSerializer());
    extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2001, UnknownExtensibilityElement.class);
    extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001, extensionRegistry.getDefaultDeserializer());
    extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001, extensionRegistry.getDefaultSerializer());
    wsdlReaderNoImport.setExtensionRegistry(extensionRegistry);
    JarWSDLLocator wsdlLocator = new JarWSDLLocator(wsdlURI);
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    Thread thread = Thread.currentThread();
    ClassLoader oldCl = thread.getContextClassLoader();
    thread.setContextClassLoader(this.getClass().getClassLoader());
    try {
        try {
            definition = wsdlReader.readWSDL(wsdlLocator);
        } catch (WSDLException e) {
            throw new OpenEJBException("Failed to read wsdl document", e);
        } catch (RuntimeException e) {
            throw new OpenEJBException(e.getMessage(), e);
        }
    } finally {
        thread.setContextClassLoader(oldCl);
    }
    return definition;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) PopulatedExtensionRegistry(com.ibm.wsdl.extensions.PopulatedExtensionRegistry) ServerRuntimeException(org.apache.openejb.server.ServerRuntimeException) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry) PopulatedExtensionRegistry(com.ibm.wsdl.extensions.PopulatedExtensionRegistry)

Aggregations

WSDLReader (javax.wsdl.xml.WSDLReader)8 WSDLFactory (javax.wsdl.factory.WSDLFactory)7 Definition (javax.wsdl.Definition)5 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 WSDLException (javax.wsdl.WSDLException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 PopulatedExtensionRegistry (com.ibm.wsdl.extensions.PopulatedExtensionRegistry)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Properties (java.util.Properties)1 NamingException (javax.naming.NamingException)1 RefAddr (javax.naming.RefAddr)1