Title: Store Soap Response Message in Citrus Framework
Tags: java;testng;citrus-framework
Question: Good Morning:
I'm new in Citrus Framework. Actually i work in a Test Case that consumes one soap webservice. I can send request message from a xml file and i need to store response message from server into another xml file for trazability and audit.
I try some options but still not working. Can you help me with posibles solutions to this requirement?
My test look like this:
public class DummyIT extends TestNGCitrusTestDesigner {
@Autowired
private WebServiceClient DummyClient;
@CitrusTest
public void dummyTest() {
soap()
.client(DummyClient)
.send()
.messageType(MessageType.XML)
.charset("UTF-8")
.contentType("text/xml")
.payload(new ClassPathResource("templates/DummyRequest.xml"));
soap()
.client(DummyClient)
.receive()
.schemaValidation(false);
I'm using Citrus Framework version 2.7.2.
Thanks for your help.


Here is another answer: You can add a message tracing test listener to the Spring application context. This listener is called with all inbound and/or outbound messages. With a custom implementation you can write the message content as file to an external folder.
There is a default message listener implementation available that is a good starting point. See if this default tracing listener fits your requirements. Otherwise you would have to implement the listener logic on your own.
You can add the default listener to the application context as bean:
public MessageTracingTestListener tracingTestListener() {
return new MessageTracingTestListener();
After that you should see .msgs files in target/citrus-logs/trace/messages folder containing all exchanged inbound and outbound messages.
Here is the default implementation: https://github.com/citrusframework/citrus/blob/master/modules/citrus-core/src/main/java/com/consol/citrus/report/MessageTracingTestListener.java

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:10/17/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><testng><citrus-framework>', 'Title': 'Store Soap Response Message in Citrus Framework', 'ViewCount': 348, 'id': 52860300, 'user_AboutMe': None, 'user_AccountId': 14564762.0, 'user_DisplayName': 'diego armando arias hurtado', 'user_Reputation': 1.0, 'user_Views': 1.0, 'user_id': 10519846.0}}