List of usage examples for javax.xml.soap SOAPElement addChildElement
public SOAPElement addChildElement(String localName, String prefix, String uri) throws SOAPException;
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/*from www.j a v a 2s. c o m*/ public void testAddChildElementWithUndeclaredNamespace() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); SOAPElement child = element.addChildElement("test", "p", "urn:ns"); assertEquals("urn:ns", child.getNamespaceURI()); assertEquals("p", child.getPrefix()); assertEquals("test", child.getLocalName()); Attr nsDecl = child.getAttributeNodeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "p"); assertNotNull(nsDecl); assertEquals("urn:ns", nsDecl.getValue()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//from w w w. j a v a 2 s . c o m public void testAddChildElementWithDeclaredNamespace() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:p", "urn:ns"); SOAPElement child = element.addChildElement("test", "p", "urn:ns"); assertEquals("urn:ns", child.getNamespaceURI()); assertEquals("p", child.getPrefix()); assertEquals("test", child.getLocalName()); assertEquals(0, child.getAttributes().getLength()); }
From source file:eu.planets_project.tb.gui.backing.admin.wsclient.util.WSClient.java
/** * Builds a hierarchy of SOAPElements given a complex value JDOM Element * * @param envelope The SOAP Envelope * @param rootElem The root SOAP Element to build content for * @param jdomElem A JDOM Element that represents a complex value * @param isRPC Pass true when building for RPC encoded messages * * @throws SOAPException/*from ww w .ja v a 2s . c om*/ */ protected static void buildSoapElement(SOAPEnvelope envelope, SOAPElement soapElem, Element jdomElem, boolean isRPC) throws SOAPException { // If the source node has text use its value String elemText = jdomElem.getText(); if (elemText != null) { if (isRPC == true) { // Set the type attribute for this element String type = jdomElem.getAttributeValue("type"); if (type != null) { soapElem.addAttribute(envelope.createName(XSI_NAMESPACE_PREFIX + ":type"), XSD_NAMESPACE_PREFIX + ":" + type); } } // Add the element text value soapElem.addTextNode(elemText); } // If the source node has attributes add the attribute values List attrs = jdomElem.getAttributes(); if (attrs != null) { Iterator attrIter = attrs.iterator(); while (attrIter.hasNext()) { // Get the attribute to add Attribute attr = (Attribute) attrIter.next(); // Create a name for the attribute Name attrName = envelope.createName(attr.getName(), attr.getNamespacePrefix(), attr.getNamespaceURI()); // Add the attribute and its value to the element soapElem.addAttribute(attrName, attr.getValue()); } } // Build children List children = jdomElem.getChildren(); if (children != null) { Iterator childIter = children.iterator(); while (childIter.hasNext()) { Element jdomChildElem = (Element) childIter.next(); // Create a new SOAPElement as a child of the current one //SOAPElement soapChildElem = soapElem.addChildElement(jdomChildElem.getName()); SOAPElement soapChildElem = soapElem.addChildElement(jdomChildElem.getName(), jdomChildElem.getNamespacePrefix(), jdomChildElem.getNamespaceURI()); // Build it buildSoapElement(envelope, soapChildElem, jdomChildElem, isRPC); } } }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
public static SOAPElement addChildElement(SOAPElement parent, String localName) throws SOAPException { // the proper call is addChildElement(localName); however, the WS4EE stack // mistakenly adds a child element with parent's namespace URI return parent.addChildElement(localName, "", ""); }