Search in sources :

Example 6 with ParamType

use of org.apache.cxf.binding.corba.wsdl.ParamType in project cxf by apache.

the class WSDLParameter method processOutputParams.

private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
    Output output = operation.getOutput();
    if (output != null) {
        Message msg = output.getMessage();
        List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
        for (Part part : parts) {
            XmlSchemaType schemaType = null;
            // check if in input list
            String mode = "out";
            ParamType paramtype = null;
            boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
            for (int x = 0; x < inputs.size(); x++) {
                paramtype = null;
                ParamType d2 = inputs.get(x);
                if (part.getElementName() != null && !isObjectRef) {
                    XmlSchemaElement el = getElement(part, xmlSchemaList);
                    if (el != null) {
                        if (el.getSchemaType() != null) {
                            schemaType = el.getSchemaType();
                        }
                        QName typeName = el.getSchemaTypeName();
                        if (typeName == null) {
                            typeName = el.getQName();
                        }
                        QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                        if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                            inputs.remove(x);
                            paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                            inputs.add(paramtype);
                        }
                    }
                } else {
                    schemaType = getType(part, xmlSchemaList);
                    QName typeName = part.getTypeName();
                    if (isObjectRef) {
                        typeName = part.getElementName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                    if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
                        inputs.remove(x);
                        paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
                        inputs.add(paramtype);
                    }
                }
            }
            if (paramtype == null) {
                if (part.getElementName() != null && !isObjectRef) {
                    XmlSchemaElement el = getElement(part, xmlSchemaList);
                    QName typeName = el.getSchemaTypeName();
                    if (typeName == null) {
                        typeName = el.getQName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                    paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                } else {
                    QName typeName = part.getTypeName();
                    if (isObjectRef) {
                        typeName = part.getElementName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                    paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
                }
                if (paramtype != null) {
                    outputs.add(paramtype);
                }
            }
        }
    }
}
Also used : Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) Output(javax.wsdl.Output) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 7 with ParamType

use of org.apache.cxf.binding.corba.wsdl.ParamType in project cxf by apache.

the class WSDLParameter method processReturnParams.

private void processReturnParams(List<ParamType> outputs, List<ArgType> returns) {
    if (!outputs.isEmpty()) {
        ParamType d2 = outputs.get(0);
        if (d2.getMode().value().equals("out")) {
            ArgType argType = new ArgType();
            argType.setName(d2.getName());
            argType.setIdltype(d2.getIdltype());
            returns.add(argType);
            outputs.remove(0);
        }
    }
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 8 with ParamType

use of org.apache.cxf.binding.corba.wsdl.ParamType in project cxf by apache.

the class WSDLParameter method orderParameters.

private void orderParameters(List<ParamType> inputs, List<ParamType> outputs, boolean simpleOrdering) {
    ListIterator<ParamType> inputit = inputs.listIterator();
    while (inputit.hasNext()) {
        ParamType d2 = inputit.next();
        if (d2.getMode().value().equals("inout")) {
            ListIterator<ParamType> it = outputs.listIterator();
            while (it.hasNext()) {
                ParamType d3 = it.next();
                if (!d3.getName().equals(d2.getName()) && (!simpleOrdering) && (!d3.getMode().value().equals("inout"))) {
                    // the in/outs are in a different order in the
                    // output than the input
                    // we'll try and use the input oder for the INOUT's,
                    // but also try and
                    // maintain some sort of ordering for the OUT's
                    it.remove();
                    inputit.previous();
                    inputit.add(d3);
                    inputit.next();
                }
            }
        }
    }
    for (ParamType d3 : outputs) {
        inputs.add(d3);
    }
}
Also used : ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 9 with ParamType

use of org.apache.cxf.binding.corba.wsdl.ParamType 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 (extElement.getElementType().getLocalPart().equals("binding")) {
                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 (extElement.getElementType().getLocalPart().equals("operation")) {
                    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 (extElement.getElementType().getLocalPart().equals("typeMapping")) {
                    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 10 with ParamType

use of org.apache.cxf.binding.corba.wsdl.ParamType 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 (extElement.getElementType().getLocalPart().equals("binding")) {
                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 (extElement.getElementType().getLocalPart().equals("operation")) {
                    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)

Aggregations

ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)21 QName (javax.xml.namespace.QName)9 ArgType (org.apache.cxf.binding.corba.wsdl.ArgType)8 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)8 Message (javax.wsdl.Message)4 CorbaStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaStreamWriter)4 ModeType (org.apache.cxf.binding.corba.wsdl.ModeType)4 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)4 OperationInfo (org.apache.cxf.service.model.OperationInfo)4 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)4 ArrayList (java.util.ArrayList)3 BindingOperation (javax.wsdl.BindingOperation)3 Part (javax.wsdl.Part)3 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)3 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)3 MessageInfo (org.apache.cxf.service.model.MessageInfo)3 File (java.io.File)2 Binding (javax.wsdl.Binding)2 Definition (javax.wsdl.Definition)2 Input (javax.wsdl.Input)2