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