use of jakarta.xml.soap.SOAPBodyElement in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageTest method testWhiteSpaceCharacters.
public void testWhiteSpaceCharacters() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPBody body = message.getSOAPBody();
QName name = new QName("testString1");
SOAPBodyElement bodyElement = body.addBodyElement(name);
bodyElement.addTextNode("Hello World, ---\003\007\024---");
name = new QName("testString2");
bodyElement = body.addBodyElement(name);
bodyElement.addTextNode("Hello \t\n\r World");
SAAJMessage saajMsg = new SAAJMessage(message);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
saajMsg.writeTo(writer);
writer.close();
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(baos.toString())));
NodeList nodeList = doc.getElementsByTagName("testString1");
assertEquals(nodeList.item(0).getFirstChild().getNodeValue(), "Hello World, ------");
nodeList = doc.getElementsByTagName("testString2");
assertEquals(nodeList.item(0).getFirstChild().getNodeValue(), "Hello \t\n\r World");
}
use of jakarta.xml.soap.SOAPBodyElement in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageTester method testDOMLevel1WriteTo.
public void testDOMLevel1WriteTo() throws Exception {
DocumentBuilderFactory builderFactory = null;
DocumentBuilder builder = null;
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
soapEnvelope.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
soapEnvelope.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
SOAPBody soapBody = soapEnvelope.getBody();
Name elementName = soapEnvelope.createName("addNumbers", "", "http://duke.org");
SOAPBodyElement bodyElement = soapBody.addBodyElement(elementName);
SAAJMessage msg = new SAAJMessage(soapMessage);
ByteArrayBuffer baos = new ByteArrayBuffer();
XMLStreamWriter writer = XMLStreamWriterFactory.createXMLStreamWriter(baos);
msg.writeTo(writer);
writer.flush();
}
use of jakarta.xml.soap.SOAPBodyElement in project openmq by eclipse-ee4j.
the class MessageUtil method getJMSBodyElement.
public static SOAPBodyElement getJMSBodyElement(SOAPMessage message, String localName) throws SOAPException {
Name name = createJMSName(localName);
Iterator it = message.getSOAPBody().getChildElements(name);
if (it.hasNext()) {
return (SOAPBodyElement) it.next();
}
return null;
}
Aggregations