Search in sources :

Example 21 with Binding

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());
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) WSDLManager(org.apache.cxf.wsdl.WSDLManager) Service(javax.wsdl.Service) Operation(javax.wsdl.Operation) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Example 22 with Binding

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]);
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 23 with Binding

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;
}
Also used : Binding(javax.wsdl.Binding) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 24 with Binding

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;
}
Also used : Binding(javax.wsdl.Binding)

Example 25 with 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;
}
Also used : Binding(javax.wsdl.Binding) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType)

Aggregations

Binding (javax.wsdl.Binding)69 QName (javax.xml.namespace.QName)39 BindingOperation (javax.wsdl.BindingOperation)28 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)22 Definition (javax.wsdl.Definition)18 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)18 Test (org.junit.Test)18 Port (javax.wsdl.Port)17 Operation (javax.wsdl.Operation)16 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)15 PortType (javax.wsdl.PortType)14 Service (javax.wsdl.Service)12 BindingType (org.apache.cxf.binding.corba.wsdl.BindingType)12 ToolException (org.apache.cxf.tools.common.ToolException)12 File (java.io.File)9 ArrayList (java.util.ArrayList)8 BindingInput (javax.wsdl.BindingInput)8 Message (javax.wsdl.Message)8 Map (java.util.Map)7 HashSet (java.util.HashSet)6