Example usage for javax.xml.soap SOAPElement getNamespaceURI

List of usage examples for javax.xml.soap SOAPElement getNamespaceURI

Introduction

In this page you can find the example usage for javax.xml.soap SOAPElement getNamespaceURI.

Prototype

public String getNamespaceURI();

Source Link

Document

The namespace URI of this node, or null if it is unspecified (see ).

Usage

From source file:org.jbpm.bpel.integration.soap.SoapUtil.java

public static void copyChildElement(Element parent, SOAPElement source) {
    // create a DOM element with the same name as the source
    String namespaceURI = source.getNamespaceURI();
    String qualifiedName = source.getNodeName();
    Element target = parent.getOwnerDocument().createElementNS(namespaceURI, qualifiedName);
    parent.appendChild(target);/*from www.j a  va 2 s  .  c o  m*/
    if (traceEnabled)
        log.trace("appended element: {" + namespaceURI + '}' + qualifiedName);
    // namespaces
    copyNamespaces(target, source);
    XmlUtil.ensureOwnNamespaceDeclared(target);
    // attributes
    copyAttributes(target, source);
    // child nodes
    copyChildNodes(target, source);
}

From source file:org.jbpm.bpel.integration.soap.SoapUtil.java

public static void ensureOwnNamespaceDeclared(SOAPElement elem) throws SOAPException {
    ensureNamespaceDeclared(elem, elem.getNamespaceURI(), elem.getPrefix());
}

From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java

public void testCopyChildNodes_soapDom() throws Exception {
    String xml = "<lunch xmlns:produce='urn:example:produce'" + " xmlns='urn:example:meal'>"
            + " <time>1200</time>" + " <produce:lettuce>0.1lb</produce:lettuce>"
            + " <fish:fillet xmlns:fish='urn:example:fish'>0.25lb</fish:fillet>" + " <padding xmlns=''/>"
            + "</lunch>";
    Element source = XmlUtil.parseText(xml);

    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
    SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
    SOAPElement target = envelope.getBody().addBodyElement(envelope.createName("detail"));

    // perform the copy
    SoapUtil.copyChildNodes(target, source);

    // qualified, prefixless element
    SOAPElement time = SoapUtil.getElement(target, "urn:example:meal", "time");
    assertEquals(SoapUtil.DEFAULT_NAMESPACE_PREFIX, time.getPrefix());
    // qualified, prefixed element
    SOAPElement lettuce = SoapUtil.getElement(target, "urn:example:produce", "lettuce");
    assertEquals("produce", lettuce.getPrefix());
    // parent qualified, prefixed element
    SOAPElement fillet = SoapUtil.getElement(target, "urn:example:fish", "fillet");
    assertEquals("fish", fillet.getPrefix());
    // local element
    SOAPElement padding = SoapUtil.getElement(target, "padding");
    assertNull(padding.getPrefix());//from w  ww  .  jav a2s  . c  om
    assertNull(padding.getNamespaceURI());
}