2

How do I get the raw xml from SOAPBody? Perhaps some util function that will just give me the Body xml (not body text). I don't want to reinvent code to walk through every node/child - it may already be there in some util?

Camel flow has a dataconverter "soapjxb", but I don't have a need to map/unmarshal to java objects.

Why do I need that?: Cleanup operation

One of the client app (that I'm trying to integrate using ApacheCamel), is putting an xml message to my mq, the message is embedded within a soap envelope ("unnecessary noise"), I can't change the client-app. I have to just discard the soap envelope and take the xml within the soap-body and post it to another jmsqueue.

PS: I know how to get raw xml from SOAPMessage as mentioned here: Getting Raw XML From SOAPMessage in Java

Community
  • 1
  • 1
Espresso
  • 5,378
  • 4
  • 35
  • 66

2 Answers2

1

if you have the SOAPEnvelope in XML, then just use xpath to isolate the XML you want and send it on its way...

.setBody(xpath("//SOAPBody"))...
Ben ODay
  • 20,784
  • 9
  • 45
  • 68
  • Tried xml equivalent of the above: //SOAPBody Error I got: On delivery attempt: 5 caught: org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.xml.dtm.ref.DTMNodeList to the required type: org.w3c.dom.Document with value org.apache.xml.dtm.ref.DTMNodeList@1ace672 – Espresso Nov 20 '12 at 00:55
-1

Use xslt to remove the namespaces and treat as normal xml.

&ltxsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt &ltxsl:output method="xml" indent="yes" omit-xml-declaration="yes" /&gt&ltxsl:template match=""&gt&ltxsl:element name="{local-name()}"&gt&ltxsl:apply-templates select="@ | node()" /&gt&lt/xsl:element&gt&lt/xsl:template&gt&ltxsl:template match="@*"&gt &ltxsl:attribute name="{local-name()}"&gt &ltxsl:value-of select="." /&gt&lt/xsl:attribute&gt&lt/xsl:template&gt&ltxsl:template match="text() | comment() | processing-instruction()"&gt &ltxsl:copy /&gt &lt/xsl:template&gt&lt/xsl:stylesheet&gt

replace &gt with greater than and &lt with less than ans save as xslt and use for tranformation to remove soap namespaces.