@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: 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())); }
@Override public SOAPElement build(Map inputMap) throws WSDLException, ParserConfigurationException, SOAPException, IOException, SAXException, UnknownOperationException { SOAPElement result = super.build(inputMap); for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) { String namespaceURI = (String) iterator.next(); String ns = namespaceMappings.get(namespaceURI); result.addNamespaceDeclaration(ns, namespaceURI); } result.setAttributeNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "soapenv:encodingStyle", SOAPConstants.URI_NS_SOAP_ENCODING); return result; }
EncodedBodyBuilder extends AbstractBodyBuilder { @Override public SOAPElement build(Map inputMap) throws WSDLException, ParserConfigurationException, SOAPException, IOException, SAXException, UnknownOperationException { SOAPElement result = super.build(inputMap); for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) { String namespaceURI = (String) iterator.next(); String ns = namespaceMappings.get(namespaceURI); result.addNamespaceDeclaration(ns, namespaceURI); } result.setAttributeNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "soapenv:encodingStyle", SOAPConstants.URI_NS_SOAP_ENCODING); return result; } }
EncodedBodyBuilder extends AbstractBodyBuilder { @Override public SOAPElement build(Map inputMap) throws WSDLException, ParserConfigurationException, SOAPException, IOException, SAXException, UnknownOperationException { SOAPElement result = super.build(inputMap); for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) { String namespaceURI = (String) iterator.next(); String ns = namespaceMappings.get(namespaceURI); result.addNamespaceDeclaration(ns, namespaceURI); } result.setAttributeNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "soapenv:encodingStyle", SOAPConstants.URI_NS_SOAP_ENCODING); return result; } EncodedBodyBuilder(String style, WSDLParser parser, String operationName, List<TypeDescriptor> inputDescriptors); }
EncodedBodyBuilder extends AbstractBodyBuilder { @Override public SOAPElement build(Map inputMap) throws WSDLException, ParserConfigurationException, SOAPException, IOException, SAXException, UnknownOperationException { SOAPElement result = super.build(inputMap); for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) { String namespaceURI = (String) iterator.next(); String ns = namespaceMappings.get(namespaceURI); result.addNamespaceDeclaration(ns, namespaceURI); } result.setAttributeNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "soapenv:encodingStyle", SOAPConstants.URI_NS_SOAP_ENCODING); return result; } EncodedBodyBuilder(String style, WSDLParser parser, String operationName, List<TypeDescriptor> inputDescriptors); @Override SOAPElement build(Map inputMap); }
EncodedBodyBuilder extends AbstractBodyBuilder { @Override public SOAPElement build(Map inputMap) throws WSDLException, ParserConfigurationException, SOAPException, IOException, SAXException, UnknownOperationException { SOAPElement result = super.build(inputMap); for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) { String namespaceURI = (String) iterator.next(); String ns = namespaceMappings.get(namespaceURI); result.addNamespaceDeclaration(ns, namespaceURI); } result.setAttributeNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "soapenv:encodingStyle", SOAPConstants.URI_NS_SOAP_ENCODING); return result; } EncodedBodyBuilder(String style, WSDLParser parser, String operationName, List<TypeDescriptor> inputDescriptors); @Override SOAPElement build(Map inputMap);  }