Search in sources :

Example 16 with Binding

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

the class WSDLToCorbaBindingTest method testMultipartCORBABindingGeneration.

@Test
public void testMultipartCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/multipart.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("Test.MultiPart");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/tests", "Test.MultiPartCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("Test.MultiPartCORBABinding", binding.getQName().getLocalPart());
    assertEquals("Test.MultiPart", binding.getPortType().getQName().getLocalPart());
    assertEquals(1, binding.getExtensibilityElements().size());
    assertEquals(32, binding.getBindingOperations().size());
    List<ExtensibilityElement> extElements = getExtensibilityElements(binding);
    ExtensibilityElement extElement = extElements.get(0);
    if ("binding".equals(extElement.getElementType().getLocalPart())) {
        BindingType bindingType = (BindingType) extElement;
        assertEquals(bindingType.getRepositoryID(), "IDL:Test/MultiPart:1.0");
    }
    getStringAttributeTest(binding);
    getTestIdTest(binding);
    setTestIdTest(binding);
    testVoidTest(binding);
    testPrimitiveTypeTest(binding, "test_short", CorbaConstants.NT_CORBA_SHORT);
    testPrimitiveTypeTest(binding, "test_long", CorbaConstants.NT_CORBA_LONG);
    testPrimitiveTypeTest(binding, "test_longlong", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_ushort", CorbaConstants.NT_CORBA_USHORT);
    testPrimitiveTypeTest(binding, "test_ulong", CorbaConstants.NT_CORBA_ULONG);
    testPrimitiveTypeTest(binding, "test_ulonglong", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_float", CorbaConstants.NT_CORBA_FLOAT);
    testPrimitiveTypeTest(binding, "test_double", CorbaConstants.NT_CORBA_DOUBLE);
    testPrimitiveTypeTest(binding, "test_octet", CorbaConstants.NT_CORBA_OCTET);
    testPrimitiveTypeTest(binding, "test_boolean", CorbaConstants.NT_CORBA_BOOLEAN);
    testPrimitiveTypeTest(binding, "test_char", CorbaConstants.NT_CORBA_CHAR);
    testPrimitiveTypeTest(binding, "test_integer", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_nonNegativeInteger", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_positiveInteger", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_negativeInteger", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_normalizedString", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_token", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_language", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_Name", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_NCName", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_ID", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_anyURI", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_nick_name", CorbaConstants.NT_CORBA_STRING);
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

Example 17 with Binding

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

the class WSDLToCorbaBindingTest method testArrayMapping.

@Test
public void testArrayMapping() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/array.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("X");
        Definition model = generator.generateCORBABinding();
        QName bName = new QName("http://schemas.apache.org/idl/anon.idl", "XCORBABinding", "tns");
        Binding binding = model.getBinding(bName);
        assertNotNull(binding);
        assertEquals("XCORBABinding", binding.getQName().getLocalPart());
        assertEquals("X", binding.getPortType().getQName().getLocalPart());
        assertEquals(1, binding.getExtensibilityElements().size());
        assertEquals(1, binding.getBindingOperations().size());
        for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
            if ("binding".equals(extElement.getElementType().getLocalPart())) {
                BindingType bindingType = (BindingType) extElement;
                assertEquals(bindingType.getRepositoryID(), "IDL:X:1.0");
            }
        }
        Iterator<?> j = binding.getBindingOperations().iterator();
        while (j.hasNext()) {
            BindingOperation bindingOperation = (BindingOperation) j.next();
            assertEquals(1, bindingOperation.getExtensibilityElements().size());
            assertEquals(bindingOperation.getBindingInput().getName(), "op_a");
            assertEquals(bindingOperation.getBindingOutput().getName(), "op_aResponse");
            for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
                if ("operation".equals(extElement.getElementType().getLocalPart())) {
                    OperationType corbaOpType = (OperationType) extElement;
                    assertEquals(corbaOpType.getName(), "op_a");
                    assertEquals(1, corbaOpType.getParam().size());
                    assertNotNull(corbaOpType.getReturn());
                    ParamType paramtype = corbaOpType.getParam().get(0);
                    assertEquals(paramtype.getName(), "part1");
                    QName idltype = new QName("http://schemas.apache.org/idl/anon.idl/corba/typemap/", "ArrayType", "ns1");
                    assertEquals(paramtype.getIdltype(), idltype);
                    assertEquals(paramtype.getMode().toString(), "IN");
                }
            }
        }
        // See if an IDL is able to produce from this CORBA Binding.
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("XCORBABinding");
        idlgen.setOutputFile("array.idl");
        idlgen.generateIDL(model);
        File f = new File("array.idl");
        assertTrue("array.idl should be generated", f.exists());
    } finally {
        new File("array.idl").deleteOnExit();
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) File(java.io.File) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) Test(org.junit.Test)

Example 18 with Binding

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

the class WSDLToCorbaBindingTest method testMixedArraysMapping.

@Test
public void testMixedArraysMapping() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/arrays-mixed.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("X");
        Definition model = generator.generateCORBABinding();
        QName bName = new QName("http://schemas.apache.org/idl/anon.idl", "XCORBABinding", "tns");
        Binding binding = model.getBinding(bName);
        assertNotNull(binding);
        assertEquals("XCORBABinding", binding.getQName().getLocalPart());
        assertEquals("X", binding.getPortType().getQName().getLocalPart());
        assertEquals(1, binding.getExtensibilityElements().size());
        assertEquals(1, binding.getBindingOperations().size());
        for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
            if ("binding".equals(extElement.getElementType().getLocalPart())) {
                BindingType bindingType = (BindingType) extElement;
                assertEquals(bindingType.getRepositoryID(), "IDL:X:1.0");
            }
        }
        Iterator<?> tm = model.getExtensibilityElements().iterator();
        assertTrue(tm.hasNext());
        TypeMappingType tmt = (TypeMappingType) tm.next();
        CorbaTypeMap typeMap = CorbaUtils.createCorbaTypeMap(Arrays.asList(tmt));
        assertNull("All nested anonymous types should have \"nested\" names", typeMap.getType("item"));
        // Checkstyle forces me to split the method...
        assertMixedArraysMappingEasyTypes(typeMap);
        // elem types are no longer strings from now.
        assertMixedArraysMappingDifficultSequences(typeMap);
        assertMixedArraysMappingDifficultArrays(typeMap);
        Iterator<?> j = binding.getBindingOperations().iterator();
        while (j.hasNext()) {
            BindingOperation bindingOperation = (BindingOperation) j.next();
            assertEquals(1, bindingOperation.getExtensibilityElements().size());
            assertEquals(bindingOperation.getBindingInput().getName(), "op_a");
            assertEquals(bindingOperation.getBindingOutput().getName(), "op_aResponse");
            for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
                if ("operation".equals(extElement.getElementType().getLocalPart())) {
                    OperationType corbaOpType = (OperationType) extElement;
                    assertEquals(corbaOpType.getName(), "op_a");
                    assertEquals(1, corbaOpType.getParam().size());
                    assertNotNull(corbaOpType.getReturn());
                    ParamType paramtype = corbaOpType.getParam().get(0);
                    assertEquals(paramtype.getName(), "part1");
                    QName idltype = new QName("http://schemas.apache.org/idl/anon.idl/corba/typemap/", "MixedArrayType", "ns1");
                    assertEquals(paramtype.getIdltype(), idltype);
                    assertEquals(paramtype.getMode().toString(), "IN");
                } else if ("typeMapping".equals(extElement.getElementType().getLocalPart())) {
                    System.out.println("x");
                }
            }
        }
        // See if an IDL is able to produce from this CORBA Binding.
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("XCORBABinding");
        idlgen.setOutputFile("array.idl");
        idlgen.generateIDL(model);
        File f = new File("array.idl");
        assertTrue("array.idl should be generated", f.exists());
    } finally {
        new File("array.idl").deleteOnExit();
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) CorbaTypeMap(org.apache.cxf.binding.corba.CorbaTypeMap) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) BindingOperation(javax.wsdl.BindingOperation) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) File(java.io.File) Test(org.junit.Test)

Example 19 with Binding

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

the class WSDLToCorbaBinding method generateCORBABinding.

private Binding generateCORBABinding(Definition definition, PortType portType) throws Exception {
    QName bqname;
    if (extReg == null) {
        extReg = def.getExtensionRegistry();
    }
    bindingNames = new ArrayList<>();
    String interfaceName = portType.getQName().getLocalPart();
    String bname = getMappedBindingName(interfaceName);
    String prefix = definition.getPrefix(definition.getTargetNamespace());
    if (prefix == null) {
        prefix = "";
    }
    if (bname == null && !allbindings) {
        bname = bindingName;
    }
    if (bname == null) {
        bname = mangleInterfaceName(interfaceName) + "CORBABinding";
        setBindingName(bname);
        bqname = new QName(definition.getTargetNamespace(), bname, prefix);
        int count = 0;
        StringBuilder builder = new StringBuilder(bname);
        while (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
            builder.append(count);
            bqname = new QName(definition.getTargetNamespace(), builder.toString(), prefix);
        }
        bname = builder.toString();
    } else {
        bqname = new QName(definition.getTargetNamespace(), bname, prefix);
        // Check if the Binding with name already exists
        if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
            String msgStr = "Binding " + bqname.getLocalPart() + " already exists in WSDL.";
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
            throw new ToolException(msg.toString());
        }
    }
    // jwsdl model should have all other bindings in it.
    String pfx = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
    if (pfx == null) {
        pfx = "corba";
        def.addNamespace(pfx, CorbaConstants.NU_WSDL_CORBA);
    }
    Binding binding = def.createBinding();
    binding.setPortType(portType);
    binding.setQName(bqname);
    bindingNames.add(bname);
    mapBindingToInterface(portType.getQName().getLocalPart(), bname);
    addCorbaTypeMap(def);
    try {
        BindingType bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
        bindingType.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + binding.getPortType().getQName().getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
        binding.addExtensibilityElement((ExtensibilityElement) bindingType);
    } catch (WSDLException ex) {
        ex.printStackTrace();
    }
    try {
        addBindingOperations(def, portType, binding);
        binding.setUndefined(false);
        definition.addBinding(binding);
    } catch (Exception ex) {
        binding.setUndefined(true);
    }
    cleanUpTypeMap(typeMappingType);
    return binding;
}
Also used : Binding(javax.wsdl.Binding) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) ToolException(org.apache.cxf.tools.common.ToolException)

Example 20 with Binding

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

the class WSDLHelper method getBindingOperation.

public BindingOperation getBindingOperation(Definition def, String operationName) {
    if (operationName == null) {
        return null;
    }
    Iterator<Binding> ite = CastUtils.cast(def.getBindings().values().iterator());
    while (ite.hasNext()) {
        Binding binding = ite.next();
        Iterator<BindingOperation> ite1 = CastUtils.cast(binding.getBindingOperations().iterator());
        while (ite1.hasNext()) {
            BindingOperation bop = ite1.next();
            if (bop.getName().equals(operationName)) {
                return bop;
            }
        }
    }
    return null;
}
Also used : Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation)

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