Search in sources :

Example 16 with WSDLFactory

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;
}
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 17 with WSDLFactory

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;
}
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)

Example 18 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project cxf by apache.

the class JAXBDataBindingTest method setUp.

@Before
public void setUp() throws Exception {
    jaxbDataBinding = new JAXBDataBinding();
    String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(destinationFactoryManager);
    control.replay();
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    wsdlServiceBuilder.buildServices(def, service);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader) Before(org.junit.Before)

Example 19 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project cxf by apache.

the class ServiceWSDLBuilderTest method setupWSDL.

private void setupWSDL(String wsdlPath, boolean doXsdImports) throws Exception {
    String wsdlUrl = getClass().getResource(wsdlPath).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    destinationFactory = control.createMock(DestinationFactory.class);
    wsdlServiceBuilder = new WSDLServiceBuilder(bus, false);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(new WSDLManagerImpl()).anyTimes();
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(destinationFactoryManager);
    EasyMock.expect(destinationFactoryManager.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/")).andReturn(destinationFactory);
    control.replay();
    serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, serviceInfo);
    builder.setUseSchemaImports(doXsdImports);
    builder.setBaseFileName("HelloWorld");
    newDef = builder.build(new HashMap<String, SchemaInfo>());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) HashMap(java.util.HashMap) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLManager(org.apache.cxf.wsdl.WSDLManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 20 with WSDLFactory

use of javax.wsdl.factory.WSDLFactory in project cxf by apache.

the class WSDLServiceBuilderTest method setUpDefinition.

private void setUpDefinition(String wsdl, int serviceSeq) throws Exception {
    URL url = getClass().getResource(wsdl);
    assertNotNull("could not find wsdl " + wsdl, url);
    String wsdlUrl = url.toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
    int seq = 0;
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            if (seq == serviceSeq) {
                break;
            }
            seq++;
        }
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) Service(javax.wsdl.Service) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader)

Aggregations

WSDLFactory (javax.wsdl.factory.WSDLFactory)28 WSDLReader (javax.wsdl.xml.WSDLReader)25 Definition (javax.wsdl.Definition)13 URL (java.net.URL)6 Service (javax.wsdl.Service)5 WSDLException (javax.wsdl.WSDLException)5 QName (javax.xml.namespace.QName)4 ArrayList (java.util.ArrayList)3 Port (javax.wsdl.Port)3 ExtensionRegistry (javax.wsdl.extensions.ExtensionRegistry)3 Bus (org.apache.cxf.Bus)3 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)3 WSDLManager (org.apache.cxf.wsdl.WSDLManager)3 CatalogWSDLLocator (org.apache.cxf.wsdl11.CatalogWSDLLocator)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2