Reputation: 535
Please let me know if there is any way to intercept the soap response sent to ws inbound gateway, add meta information to SOAP header and pass the entire soap envelope to SI file outbound adapter, which will log the response in a file.
Upvotes: 1
Views: 341
Reputation: 121552
You should implement EndpointInterceptor
and inject it into AbstractEndpointMapping
.
In its handleResponse()
you can get access to the
SoapMessage soapMessage = ((SoapMessage) messageContext.getResponse());
do anything you want and send a Spring Integration Message to the injected channel for that <int-file:outbound-channel-adapter>
.
UPDATE
1) The response sent back to ws inbound gateway is also modified, which i do not want. I want only the soap response sent to file adapter to be modified. Because that has some meta information to be logged 2) How to make the file file outbound adapter logging asynchronous.. like wiretap.
Sorry for delay, first of all.
No, you can't do that with the same object. It's typical issue with the mutable object in the multi-threaded environment. If one thread modify object, another can see those changes. In this case the WireTap
won't help.
I suggest you to clone
your SOAP Message object somehow, or even better convert it to String, build a new message and only after that send it to the file adapter:
TransformerHelper transformerHelper = new TransformerHelper();
Result result = new StringResult();
SoapMessage soapMessage = ((SoapMessage) messageContext.getResponse());
Source source = soapMessage.getEnvelope().getSource();
transformerHelper.transform(source, result);
String responseXml = result.toString();
Upvotes: 0