private void defineFromTypeDescriptor() { if (typeDescriptor instanceof ComplexTypeDescriptor) { List elements = ((ComplexTypeDescriptor) typeDescriptor) .getElements(); inputNames = new String[elements.size()]; inputTypes = new String[elements.size()]; Class[] types = new Class[elements.size()]; TypeDescriptor.retrieveSignature(elements, inputNames, types); for (int i = 0; i < types.length; i++) { inputTypes[i] = TypeDescriptor.translateJavaType(types[i]); } } else if (typeDescriptor instanceof ArrayTypeDescriptor) { inputNames = new String[] { typeDescriptor.getType() }; if (((ArrayTypeDescriptor) typeDescriptor).getElementType() instanceof BaseTypeDescriptor) { inputTypes = new String[] { "l('text/plain')" }; } else { inputTypes = new String[] { "l('text/xml')" }; } } }
: new Element(this.typeDescriptor.getType())); try { if (typeDescriptor instanceof ComplexTypeDescriptor) {
itemkey = arrayElementType.getName(); } else { itemkey = arrayElementType.getType();
@Test public void testBaseTypes() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("bind.wsdl")); List<TypeDescriptor> inputs = parser .getOperationInputParameters("BIVGetRecord"); assertEquals("wrong number of inputs", 1, inputs.size()); assertTrue("should not be base type", inputs.get(0) instanceof BaseTypeDescriptor); assertEquals("wrong name", "bid", (inputs.get(0)) .getName()); assertEquals("wrong type", "int", (inputs.get(0)) .getType()); }
@Test public void testGoVizNoOutputs() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("GoViz.wsdl")); List<TypeDescriptor> inputs = parser .getOperationInputParameters("destroySession"); List<TypeDescriptor> outputs = parser .getOperationOutputParameters("destroySession"); assertEquals("wrong number of inputs", 1, inputs.size()); assertEquals("wrong number of outputs", 0, outputs.size()); TypeDescriptor typeDesc = inputs.get(0); assertTrue("input should be BaseType", typeDesc instanceof BaseTypeDescriptor); assertEquals("wrong name", "sessionID", typeDesc.getName()); assertEquals("wrong type", "string", typeDesc.getType()); }
@Test public void testArrayType() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("bind.wsdl")); List<TypeDescriptor> inputs = parser .getOperationInputParameters("BIVGetRecords"); List<TypeDescriptor> outputs = parser .getOperationOutputParameters("BIVGetRecords"); assertEquals("wrong number of inputs", 1, inputs.size()); assertTrue("input should be of AArrayTypeDescriptor", inputs.get(0) instanceof ArrayTypeDescriptor); ArrayTypeDescriptor arrayTypeDesc = (ArrayTypeDescriptor) inputs.get(0); assertEquals("wrong name", "ids", arrayTypeDesc.getName()); assertEquals("wrong type", "ArrayOf_xsd_int", arrayTypeDesc.getType()); TypeDescriptor typeDesc = arrayTypeDesc.getElementType(); assertTrue("element should be of type BaseTypeDescriptor", typeDesc instanceof BaseTypeDescriptor); assertEquals("wrong type", "int", typeDesc.getType()); assertEquals("wrong number of outputs", 1, outputs.size()); assertTrue("output should be of ArrayTypeDescriptor", outputs.get(0) instanceof ArrayTypeDescriptor); arrayTypeDesc = (ArrayTypeDescriptor) outputs.get(0); assertEquals("wrong name", "BIVRecords", arrayTypeDesc.getName()); assertEquals("wrong type", "ArrayOfBIVRecord", arrayTypeDesc.getType()); typeDesc = arrayTypeDesc.getElementType(); assertEquals("wrong type", "BIVRecord", typeDesc.getType()); }
.get(0)).getName()); assertEquals("wrong type for input", "int", (inputs .get(0)).getType()); (outputs.get(0)).getType()); assertTrue("wrong descriptor class for output", outputs.get(0) instanceof ComplexTypeDescriptor); (typeDesc.getElements().get(0)).getName()); assertEquals("wrong type for first element", "int", (typeDesc.getElements().get(0)).getType()); (typeDesc.getElements().get(6)).getType());
assertEquals("wrong type", "string", typeDesc.getType()); assertTrue("db should be optional", typeDesc.isOptional()); assertFalse("db should not be unbounded", typeDesc.isUnbounded()); assertEquals("wrong type", "string", typeDesc.getType()); assertTrue("tool should be optional", typeDesc.isOptional()); assertFalse("tool should not be unbounded", typeDesc.isUnbounded()); assertEquals("wrong type", "string", typeDesc.getType()); assertTrue("email should be optional", typeDesc.isOptional()); assertFalse("email should not be unbounded", typeDesc.isUnbounded());