Search in sources :

Example 81 with Definition

use of javax.wsdl.Definition 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 82 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToCorbaBindingTypeTest method testCorbaExceptionComplextype.

@Test
public void testCorbaExceptionComplextype() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/databaseService.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("Database");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(2, typemap.getElementsByTagName("corba:struct").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:exception").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:anonsequence").getLength());
    } finally {
        new File("databaseService-corba.wsdl").deleteOnExit();
    }
}
Also used : Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.Test)

Example 83 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToCorbaBindingTypeTest method testWsAddressingBankType.

@Test
public void testWsAddressingBankType() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/wsaddressing_account.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("Account");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(1, typemap.getElementsByTagName("corba:object").getLength());
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("AccountCORBABinding");
        idlgen.setOutputFile("wsaddressing_account.idl");
        idlgen.generateIDL(model);
        File f = new File("wsaddressing_account.idl");
        assertTrue("wsaddressing_account.idl should be generated", f.exists());
    } finally {
        new File("wsaddressing_account.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.Test)

Example 84 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToCorbaBindingTypeTest method testSetCorbaAddress.

@Test
public void testSetCorbaAddress() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/datetime.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("BasePortType");
        Definition model = generator.generateCORBABinding();
        QName name = new QName("http://schemas.apache.org/idl/datetime.idl", "BaseCORBAService", "tns");
        Service service = model.getService(name);
        Port port = service.getPort("BaseCORBAPort");
        AddressType addressType = (AddressType) port.getExtensibilityElements().get(0);
        String address = addressType.getLocation();
        assertEquals("file:./Base.ref", address);
        generator.setAddress("corbaloc::localhost:40000/hw");
        model = generator.generateCORBABinding();
        service = model.getService(name);
        port = service.getPort("BaseCORBAPort");
        addressType = (AddressType) port.getExtensibilityElements().get(0);
        address = addressType.getLocation();
        assertEquals("corbaloc::localhost:40000/hw", address);
    } finally {
        new File("datetime-corba.wsdl").deleteOnExit();
    }
}
Also used : QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) AddressType(org.apache.cxf.binding.corba.wsdl.AddressType) File(java.io.File) Test(org.junit.Test)

Example 85 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToCorbaBindingTypeTest method testNestedInterfaceTypes.

@Test
public void testNestedInterfaceTypes() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/nested_interfaces.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("C.C1");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(1, typemap.getElementsByTagName("corba:anonstring").getLength());
        assertEquals(9, typemap.getElementsByTagName("corba:struct").getLength());
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("C.C1CORBABinding");
        idlgen.setOutputFile("nested_interfaces.idl");
        idlgen.generateIDL(model);
        File f = new File("nested_interfaces.idl");
        assertTrue("nested_interfaces.idl should be generated", f.exists());
    } finally {
        new File("nested_interfaces.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.Test)

Aggregations

Definition (javax.wsdl.Definition)226 Test (org.junit.Test)113 QName (javax.xml.namespace.QName)61 File (java.io.File)52 Document (org.w3c.dom.Document)44 Element (org.w3c.dom.Element)40 HashMap (java.util.HashMap)36 WSDLReader (javax.wsdl.xml.WSDLReader)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)31 JBossWSTest (org.jboss.wsf.test.JBossWSTest)31 Service (javax.wsdl.Service)24 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)23 URL (java.net.URL)21 ArrayList (java.util.ArrayList)21 Port (javax.wsdl.Port)21 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)21 Bus (org.apache.cxf.Bus)20 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)20 WSDLManager (org.apache.cxf.wsdl.WSDLManager)20 IOException (java.io.IOException)18