Search in sources :

Example 1 with PopulatedExtensionRegistry

use of com.ibm.wsdl.extensions.PopulatedExtensionRegistry 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

PopulatedExtensionRegistry (com.ibm.wsdl.extensions.PopulatedExtensionRegistry)1 Definition (javax.wsdl.Definition)1 WSDLException (javax.wsdl.WSDLException)1 ExtensionRegistry (javax.wsdl.extensions.ExtensionRegistry)1 WSDLFactory (javax.wsdl.factory.WSDLFactory)1 WSDLReader (javax.wsdl.xml.WSDLReader)1 OpenEJBException (org.apache.openejb.OpenEJBException)1 ServerRuntimeException (org.apache.openejb.server.ServerRuntimeException)1