use of javax.wsdl.Binding in project cxf by apache.
the class WSDLManagerImplTest method testBuildImportedWSDL.
@Test
public void testBuildImportedWSDL() throws Exception {
String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();
WSDLManager builder = new WSDLManagerImpl();
Definition def = builder.getDefinition(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
String serviceQName = "http://apache.org/hello_world/services";
Service service = (Service) services.get(new QName(serviceQName, "SOAPService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("SoapPort");
assertNotNull(port);
Binding binding = port.getBinding();
assertNotNull(binding);
QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
assertEquals(bindingQName, binding.getQName());
PortType portType = binding.getPortType();
assertNotNull(portType);
QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
assertEquals(portTypeQName, portType.getQName());
Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
assertNotNull(op1);
QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
assertEquals(messageQName, op1.getInput().getMessage().getQName());
Part part = op1.getInput().getMessage().getPart("in");
assertNotNull(part);
assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLASTVisitor method getCorbaBindings.
public Binding[] getCorbaBindings() {
List<Binding> result = new ArrayList<>();
Map<QName, Binding> bindings = CastUtils.cast(definition.getBindings());
for (Binding binding : bindings.values()) {
List<ExtensibilityElement> extElements = CastUtils.cast(binding.getExtensibilityElements());
for (int i = 0; i < extElements.size(); i++) {
ExtensibilityElement el = extElements.get(i);
if (el.getElementType().equals(CorbaConstants.NE_CORBA_BINDING)) {
result.add(binding);
break;
}
}
}
return result.toArray(new Binding[0]);
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLASTVisitor method getPhysicalDefinition.
// Write the physical definitions to a file.
private Definition getPhysicalDefinition(Definition logicalDef, boolean schemaOnly) throws WSDLException, JAXBException {
final Definition def;
if (schemaOnly) {
def = logicalDef;
} else {
def = manager.createWSDLDefinition(targetNamespace);
}
Collection<String> namespaces = CastUtils.cast(definition.getNamespaces().values());
for (String namespace : namespaces) {
String prefix = definition.getPrefix(namespace);
def.addNamespace(prefix, namespace);
}
Collection<Binding> bindings = CastUtils.cast(definition.getAllBindings().values());
for (Binding binding : bindings) {
def.addBinding(binding);
}
Collection<Service> services = CastUtils.cast(definition.getAllServices().values());
for (Service service : services) {
def.addService(service);
}
Collection<ExtensibilityElement> extns = CastUtils.cast(definition.getExtensibilityElements());
for (ExtensibilityElement ext : extns) {
def.addExtensibilityElement(ext);
}
def.setExtensionRegistry(definition.getExtensionRegistry());
return def;
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLToIDLAction method findBinding.
private Binding findBinding(Definition definition) {
Binding binding = null;
Collection<Binding> bindings = CastUtils.cast(definition.getBindings().values());
if (bindingName != null) {
for (Binding b : bindings) {
binding = b;
if (binding.getQName().getLocalPart().equals(bindingName)) {
return binding;
}
}
} else {
if (!bindings.isEmpty()) {
binding = bindings.iterator().next();
}
}
return binding;
}
use of javax.wsdl.Binding in project cxf by apache.
the class PortTypeVisitor method createBinding.
public Binding createBinding(String scopedPortTypeName) {
StringBuilder bname = new StringBuilder();
bname.append(scopedPortTypeName).append("CORBABinding");
QName bqname = new QName(rootDefinition.getTargetNamespace(), bname.toString());
int count = 0;
while (queryBinding(bqname)) {
bname.append(count);
bqname = new QName(rootDefinition.getTargetNamespace(), bname.toString());
}
Binding binding = rootDefinition.createBinding();
binding.setPortType(portType);
binding.setQName(bqname);
try {
BindingType bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
String pragmaPrefix = (this.getWsdlVisitor().getPragmaPrefix() != null && this.getWsdlVisitor().getPragmaPrefix().length() > 0) ? this.getWsdlVisitor().getPragmaPrefix() + "/" : "";
bindingType.setRepositoryID(CorbaConstants.REPO_STRING + pragmaPrefix + scopedPortTypeName.replace('.', '/') + CorbaConstants.IDL_VERSION);
binding.addExtensibilityElement((ExtensibilityElement) bindingType);
} catch (WSDLException ex) {
throw new RuntimeException(ex);
}
binding.setUndefined(false);
rootDefinition.addBinding(binding);
return binding;
}
Aggregations