@Test
public void testComplexType() throws Exception {

	BodyBuilder builder = createBuilder(wsdlResourcePath("TestServices-rpcencoded.wsdl"), "personToString");
	
	assertTrue("Wrong type of builder created",builder instanceof EncodedBodyBuilder);
	
	String p = "<Person xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><name xsi:type=\"xsd:string\">bob</name><age xsi:type=\"xsd:int\">12</age></Person>";
	
	Map<String,Object> inputMap = new HashMap<String, Object>();
	
	inputMap.put("p",p);
	SOAPElement body = builder.build(inputMap);
	
               Iterator<SOAPElement> persons = body.getChildElements(new QName("", "p"));
               
               assertTrue("'Person' tag is missing", persons.hasNext());
               SOAPElement person = persons.next();
               assertFalse("more than one 'Person' tag found", persons.hasNext());
               
               String personType = person.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type");
               assertNotNull("type definition of Person is missing", personType);
               assertTrue("wrong xsi:type for the 'Person' tag", "ns1:Person".equals(personType));
               assertTrue("wrong type definition for Person", "ns1:Person".equals(personType));
               Iterator<SOAPElement> names = person.getChildElements(new QName("", "name"));
               
               assertTrue("'name' tag is missing", names.hasNext());
               SOAPElement name = names.next();
               assertFalse("More than one 'name' tag found", names.hasNext());
               String nameType = name.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type");
               assertNotNull("type definition of name is missing", nameType);
               assertTrue("wrong name's xsi:type", "xsd:string".equals(nameType));
               assertTrue("wrong 'name' tag value (must be 'bob')", "bob".equals(name.getTextContent()));
               Iterator<SOAPElement> ages = person.getChildElements(new QName("", "age"));
               
               assertTrue("'age' tag is missing", ages.hasNext());
               SOAPElement age = ages.next();
               assertFalse("more than one 'age' tag found", ages.hasNext());
               String ageType = age.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type");
               assertNotNull("missing type definition for the 'age' tag", ageType);
               assertTrue("wrong xsi:type for 'age' tag", "xsd:int".equals(ageType));
               assertTrue("wrong 'age' tag value (must be 12)", "12".equals(age.getTextContent()));
}