In Spring Integration, using inbound-gateway, do you know how to save each SOAP WS Request to separated files ?
Currently, I stuck at:
<!-- inbound -->
<ws:inbound-gateway id="inbound-gateway" request-channel="SOAPRequestChannel" reply-channel="SOAPResponseChannel"/>
<int:channel id="SOAPRequestChannel">
<int:interceptors>
<int:wire-tap channel="SOAPRequestChannelForLog"/>
</int:interceptors>
</int:channel>
<int:channel id="SOAPResponseChannel" />
<int:channel id="SOAPRequestChannelForLog" />
<int:logging-channel-adapter id="logger" expression="payload" level="INFO" channel="SOAPRequestChannelForLog"/>
But it just log all requests in 1 file.
OR I have to write another class like LogToFile which has a method to save that request to file, replace int:logging-channel-adapter with int:service-activator ? Does Spring support out-of-the-box logging each SOAP request ? I read the reference document, but couldn't find any thing.
OR there is any better way ? ^_^
Regards,
First of all PayloadLoggingInterceptor
is based on the org.apache.commons.logging.Log
and that is already your application responsibility which target logging system to use. Yes, Log4j2 is one of them. There is only just need to have a proper bridge from Commons Logging to the target impl. Looks like it is out-of-the-box for Log4j...
If you want to store each request to its own file, consider to use <int-file:outbound-channel-adapter>
for that purpose.
You just need to build a proper content based on the incoming Message:
Transformer transformer = createNonIndentingTransformer();
StringWriter writer = new StringWriter();
transformer.transform(source, new StreamResult(writer));
String message = writer.toString();
Where source
is a payload
of the message after <ws:inbound-gateway>
.
And you will just need to figure out the file name
based on that message or some other environment.