use of javax.wsdl.Definition in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testMultipleBindings.
@Test
public void testMultipleBindings() throws Exception {
String fileName = getClass().getResource("/wsdl/multiplePortTypes.wsdl").toString();
generator.setWsdlFile(fileName);
generator.setAllBindings(true);
Definition model = generator.generateCORBABinding();
assertEquals("All bindings should be generated.", 2, model.getAllBindings().size());
}
use of javax.wsdl.Definition in project cxf by apache.
the class AegisTest method testAegisBasic.
@Test
public void testAegisBasic() throws Exception {
final String sei = org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName();
File wsdlFile = new File(folder.getRoot(), "aegis.wsdl");
String[] args = new String[] { "-wsdl", "-o", wsdlFile.toString(), "-verbose", "-d", folder.getRoot().toString(), "-s", folder.getRoot().toString(), "-frontend", "jaxws", "-databinding", "aegis", "-client", "-server", sei };
JavaToWS.main(args);
assertTrue("wsdl is not generated", wsdlFile.exists());
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
reader.setFeature("javax.wsdl.verbose", false);
Definition def = reader.readWSDL(wsdlFile.toURI().toURL().toString());
Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
assertValid("//xsd:element[@type='ns0:Something']", wsdl);
}
use of javax.wsdl.Definition in project cxf by apache.
the class ServiceWSDLBuilder method build.
/**
* Create the WSDL Definition object and return it. This function respects the
* setting of {@link #setUseSchemaImports(boolean)}.
* @param imports A set of schema imports to either reference as imports or read and
* then inline.
* @return the WSDL definition
* @throws WSDLException
*/
public Definition build(Map<String, SchemaInfo> imports) throws WSDLException {
Definition definition = null;
try {
definition = services.get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
} catch (ClassCastException e) {
// ignore
}
if (definition == null) {
ServiceInfo si = services.get(0);
definition = newDefinition(si.getName(), si.getTargetNamespace());
addNamespace(WSDLConstants.CONVENTIONAL_TNS_PREFIX, si.getTargetNamespace(), definition);
addExtensibilityElements(definition, definition, getWSDL11Extensors(si.getDescription()));
Collection<PortType> portTypes = new HashSet<>();
for (ServiceInfo service : services) {
Definition portTypeDef = definition;
Definition orig = definition;
if (!isSameTNS(service)) {
portTypeDef = newDefinition(service.getInterface().getName(), service.getInterface().getName().getNamespaceURI());
Import wsdlImport = definition.createImport();
String tns = service.getInterface().getName().getNamespaceURI();
wsdlImport.setDefinition(portTypeDef);
wsdlImport.setNamespaceURI(tns);
wsdlImport.setLocationURI(service.getInterface().getName().getLocalPart() + ".wsdl");
definition.addImport(wsdlImport);
addNamespace(getPrefix(tns), tns, definition);
}
portTypes.add(buildPortType(service.getInterface(), portTypeDef));
if (service.getSchemas() != null && service.getSchemas().size() > 0) {
if (!useSchemaImports) {
buildTypes(service.getSchemas(), imports, portTypeDef);
} else {
buildTypesWithSchemaImports(service.getSchemas(), imports, portTypeDef);
}
}
definition = orig;
}
for (ServiceInfo service : services) {
buildBinding(definition, service.getBindings(), portTypes);
buildService(service, definition);
}
}
return definition;
}
use of javax.wsdl.Definition in project cxf by apache.
the class SchemaUtil method getSchemas.
public void getSchemas(final Definition def, final SchemaCollection schemaCol, List<SchemaInfo> schemas) {
List<Definition> defList = new ArrayList<>();
parseImports(def, defList);
extractSchema(def, schemaCol, schemas);
// added
getSchemaList(def);
Map<Definition, Definition> done = new IdentityHashMap<>();
done.put(def, def);
for (Definition def2 : defList) {
if (!done.containsKey(def2)) {
extractSchema(def2, schemaCol, schemas);
// added
getSchemaList(def2);
done.put(def2, def2);
}
}
}
use of javax.wsdl.Definition in project cxf by apache.
the class FailoverTest method updateWsdlExtensors.
/**
* Exchange the port number in all service addresses on the bus.
* @param port1 current port
* @param port2 new port
*/
private void updateWsdlExtensors(String port1, String port2) {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation);
Map<?, ?> map = def.getAllServices();
for (Object o : map.values()) {
Service service = (Service) o;
Map<?, ?> ports = service.getPorts();
for (Object p : ports.values()) {
Port port = (Port) p;
List<?> l = port.getExtensibilityElements();
for (Object e : l) {
if (e instanceof SOAPAddress) {
String add = ((SOAPAddress) e).getLocationURI();
int idx = add.indexOf(":" + port1);
if (idx != -1) {
add = add.substring(0, idx) + ":" + port2 + add.substring(idx + port1.length() + 1);
((SOAPAddress) e).setLocationURI(add);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations