use of javax.wsdl.factory.WSDLFactory 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;
}
use of javax.wsdl.factory.WSDLFactory 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;
}
Aggregations