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);
}
}
}
}
}
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);
}
}
}
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);
}
}
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();
}
}
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();
}
}
Aggregations