I want to log the incoming SOAP in my beans setup but I don't know how to intercept the requested body.
I found out if I add ?dataFormat=MESSAGE to my CxfEndpoint it shows the xml input but messes up the dataFormat that provides the addBookTransformer.
<from uri="cxf:bean:CxfEndpoint?dataFormat=MESSAGE" />
This is my setup
<cxf:cxfEndpoint id="CxfEndpoint"
address="/host/addBook"
endpointName="a:addBookEndpoint"
serviceName="a:addBookService"
wsdlURL="wsdl/add-book.wsdl"
serviceClass="com.library.AddBookEndpoint"
xmlns:a="http://library.com"/>
<bean id="addBookTransformer" class="com.library.bookshelf.AddBookTransformer"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="addBook" streamCache="true">
<from uri="cxf:bean:CxfEndpoint" />
<process ref="addBookTransformer" />
<log message="${body}"/>
</route>
</camelContext>
Is there a way to itercept and log the incoming post request data?
You could do wiretap for this
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="addBook" streamCache="true">
<from uri="cxf:bean:CxfEndpoint" />
<process ref="addBookTransformer" />
<wireTap uri="direct:tap"/>
<to uri="mock:result"/>
<log message="${body}"/>
</route>
</camelContext>
A copy of the exchange is sent to direct:tap
which you can read and process however you want.
For example we could just log the message like this. You could also add another processor.
<route id="wiretapped" streamCache="true">
<from uri="direct:tap" />
<log message="${body}"/>
</route>
Here is the documentation for this.