Example usage for javax.xml.soap SOAPBody appendChild

List of usage examples for javax.xml.soap SOAPBody appendChild

Introduction

In this page you can find the example usage for javax.xml.soap SOAPBody appendChild.

Prototype

public Node appendChild(Node newChild) throws DOMException;

Source Link

Document

Adds the node newChild to the end of the list of children of this node.

Usage

From source file:com.googlecode.ddom.saaj.SOAPMessageTest.java

/**
 * Tests that {@link SOAPMessage#writeTo(java.io.OutputStream)} performs namespace repairing.
 * //from   w  w  w.j  a  v a 2  s . co m
 * @throws Exception
 */
@Validated
@Test
public void testWriteToNamespaceRepairing() throws Exception {
    SOAPMessage message = getFactory().createMessage();
    SOAPPart part = message.getSOAPPart();
    SOAPBody body = part.getEnvelope().getBody();
    body.appendChild(part.createElementNS("urn:ns", "p:test"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    message.writeTo(baos);
    String content = baos.toString("UTF-8");
    assertTrue(content.contains("<p:test xmlns:p=\"urn:ns\"/>"));
}