You need to tell the XML serializer to not parse and delete the contents of SOAPBody as XML. You can do this by including XML inside <![CDATA[]]>
String rawXml = "<![CDATA[<some-data><some-data-item>1</some-data-item></some-data>]]>"; // Start the API MessageFactory mf = MessageFactory.newInstance(); SOAPMessage request = mf.createMessage(); SOAPPart part = request.getSOAPPart(); SOAPEnvelope env = part.getEnvelope(); // Get the body. How do I add the raw xml directly into the body? SOAPBody body = env.getBody(); SOAPElement se = body.addTextNode(rawXml); System.out.println(body.getTextContent());
EDIT
<some-data><some-data-item>1</some-data-item></some-data>
This is the conclusion.
System.out.println(body.getTextContent());
source share