29 August 2012

How to retrieve XML sent into SOAP Payload

Using WebLogic Server 10.3.5 , we need a way to retrieve XML payload that is not sent between CDATA:


To implement the solution, please use the following snippet code to achieve the requirement:

To achieve this, we use JAX-RPC and following webservice endpoint:
in the method nodeToString() we are getting the XML as String:


public String sayHello(javax.xml.soap.SOAPElement message) {


System.out.println("sayHello:" + message.toString());

System.out.println("sayHello:" + message.getClass());


String xml_str = nodeToString(message);




return "Here is the message: '" + message + "'";


private String nodeToString(Node node) {

StringWriter sw = new StringWriter();

try {

System.out.println("Start string conversion...");

Transformer t = TransformerFactory.newInstance().newTransformer();

t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

t.transform(new DOMSource(node), new StreamResult(sw));

} catch (TransformerException te) {

System.out.println("nodeToString Transformer Exception");


System.out.println("end string conversion...");

return sw.toString();


There is a workaround escaping the XML with CDATA or XML entities < >
but the solution would be to use javax.xml.soap.SOAPElement as parameter of the webservice endpoint

No comments :

My Blog List

Search This Blog


Blog Archive

There was an error in this gadget


The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.