Search in sources :

Example 1 with CatalogWSDLLocator

use of org.apache.cxf.wsdl11.CatalogWSDLLocator in project cxf by apache.

the class WSDLGenerationTester method writeDefinition.

public File writeDefinition(File targetDir, File defnFile) throws Exception {
    WSDLManager wm = BusFactory.getThreadDefaultBus().getExtension(WSDLManager.class);
    WSDLFactory factory = WSDLFactory.newInstance("org.apache.cxf.tools.corba.utils.TestWSDLCorbaFactoryImpl");
    WSDLReader reader = factory.newWSDLReader();
    reader.setFeature("javax.wsdl.importDocuments", false);
    reader.setExtensionRegistry(wm.getExtensionRegistry());
    final String url = defnFile.toString();
    CatalogWSDLLocator locator = new CatalogWSDLLocator(url, (Bus) null);
    Definition wsdlDefn = reader.readWSDL(locator);
    File bkFile = new File(targetDir, "bk_" + defnFile.getName());
    try (Writer writer = Files.newBufferedWriter(bkFile.toPath())) {
        factory.newWSDLWriter().writeWSDL(wsdlDefn, writer);
    }
    return bkFile;
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) Definition(javax.wsdl.Definition) WSDLManager(org.apache.cxf.wsdl.WSDLManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) File(java.io.File) WSDLReader(javax.wsdl.xml.WSDLReader) Writer(java.io.Writer)

Example 2 with CatalogWSDLLocator

use of org.apache.cxf.wsdl11.CatalogWSDLLocator in project cxf by apache.

the class JaxWsServiceConfigurationTest method getMockedServiceModel.

private ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    Service service = null;
    for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof Service) {
            service = (Service) obj;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
    return serviceInfo;
}
Also used : IMocksControl(org.easymock.IMocksControl) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Definition(javax.wsdl.Definition) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) WebService(javax.jws.WebService) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 3 with CatalogWSDLLocator

use of org.apache.cxf.wsdl11.CatalogWSDLLocator in project cxf by apache.

the class OASISCatalogTest method testWSDLLocatorWithDefaultCatalog.

@Test
public void testWSDLLocatorWithDefaultCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), OASISCatalogManager.getCatalogManager(null));
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    wsdlReader.readWSDL(wsdlLocator);
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 4 with CatalogWSDLLocator

use of org.apache.cxf.wsdl11.CatalogWSDLLocator in project cxf by apache.

the class OASISCatalogTest method testWSDLLocatorWithoutCatalog.

@Test
public void testWSDLLocatorWithoutCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    OASISCatalogManager catalog = new OASISCatalogManager();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), catalog);
    try {
        wsdlReader.readWSDL(wsdlLocator);
        fail("Test did not fail as expected");
    } catch (WSDLException e) {
    // ignore
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) OASISCatalogManager(org.apache.cxf.catalog.OASISCatalogManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Aggregations

WSDLReader (javax.wsdl.xml.WSDLReader)4 CatalogWSDLLocator (org.apache.cxf.wsdl11.CatalogWSDLLocator)4 WSDLFactory (javax.wsdl.factory.WSDLFactory)3 URL (java.net.URL)2 Definition (javax.wsdl.Definition)2 Test (org.junit.Test)2 File (java.io.File)1 Writer (java.io.Writer)1 WebService (javax.jws.WebService)1 Service (javax.wsdl.Service)1 WSDLException (javax.wsdl.WSDLException)1 Bus (org.apache.cxf.Bus)1 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)1 OASISCatalogManager (org.apache.cxf.catalog.OASISCatalogManager)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)1 WSDLManager (org.apache.cxf.wsdl.WSDLManager)1 WSDLServiceBuilder (org.apache.cxf.wsdl11.WSDLServiceBuilder)1 IMocksControl (org.easymock.IMocksControl)1