Logging HTTP Response Headers and Bodies of Web Service --- Materials applied


I have made a demo project and published at


Problem to solve

  1. I want to test a Web Service API, like katalon-studio-samples/jira-api-tests
  2. I want to save HTTP Response Header and Response Body into files in JSON format.
  3. I want to retain files chronologically for logging purpose. I do not like overwriting files. If I execute a single Test Suite 3 times, then I want to retain 3 sets of json files.
  4. I will look back retained sets of json files frequently. So I want a nice GUI that enables me to retrieve stored files quickly.


I would introduce Materials, a java/groovy library that resolves output file paths in a well-structured format. Thecom.kazurayam.materials.MaterialRepository class provides convenient methods with which I can solve the above-mensioned problems easily.

  1. resolveMaterialPath(String testCaseId, String fileName) method returns java.nio.file.Path object for a File to be created. The path would be in the format of
  1. makeIndex() method generates the ./Materials/index.html file. This is a simple viewer for the Materials folder contents.

How to run the demo

  1. download the zip of this project from releases page.
  2. unzip it. You will obtain a folder named KatalonDiscussion10209.
  3. start your Katalon studio, and open the project
  4. open a Test Suite named Test Suites/TS_Materials_applied and run it.
  5. you should run it multiple times. e.g., try 3 times.

What the test does

This project is based on the katalon-studio-samples/jira-api-tests project. I added a few codes on it without changing files of the original project.

The Test Suites/TS_Materials_applied executes Test Cases/Simple examples/api-2-issue/Get issue/Get an issue by Key - 1 - Materialized. The test case code looks like this:

// Send the request and get the responseresponse = WS.sendRequest(findTestObject('Simple examples/api-2-issue/Get issue/Get an issue by Key'))// Verify the responseWS.verifyResponseStatusCode(response, 200)// make MaterialRepository accessibleMaterialRepository mr = (MaterialRepository)GlobalVariable.MATERIAL_REPOSITORY// store the HTTP Response Headers into filePath path2 = mr.resolveMaterialPath(GlobalVariable.CURRENT_TESTCASE_ID, "headers.json")Map<String, List<String>> headerFields = response.getHeaderFields()String headersJson = CustomKeywords.'com.kazurayam.ksbackyard.WebServiceTestSupport.convertHeaderFieldsToJsonString'(headerFields)path2.toFile().append(headersJson, 'utf-8')// store the HTTP Response Body into filePath path3 = mr.resolveMaterialPath(GlobalVariable.CURRENT_TESTCASE_ID, "body.json")String body = response.getResponseBodyContent()path3.toFile().append(body, 'utf-8')

This test case send a HTTP GET request to a RESTFul URL https://katalon.atlassian.net/rest/api/2/issue/KD-1000?expand=names&fields=summary,status,issuetype,assignee,project,priority,description&= . The test case makes a bit of assertions over the response. And it writes the HTTP Response Headers and Body into files on local disk in JSON format.


By running Test Suites/TS_Materials_applied, a new folder <projectDir>/Materials will be created. In there you can find a folder tree and a HTML file named index.html.


You can browse the index.html. It will look like this:


In the index you will find as many records of test suite runs as you executed. In the above screenshot, you can find 3 times of test suite run recorded.

Each test suite run contains a record of test case run, which contains links to the files created.

By clicking the links, you can view the files in modal widdow. Here is headers.json:


Here is body.json:


Path format

The created files has a path like this:


A concrete path example:

./Materials/TS_Materials_applied/20181018_140249/Simple examples.api-2-issue.Get issue.Get an issue by Key - 1 - Materialized/header.json

Please note that this folder tree contains a timestamp layer yyyyMMdd_hhmmss. Having a timestamp layer enables you to retain outputs as long as you like until you intensionally delete them. This chronological folder structure is best fit for logging purpose.

How to reproduce a Materials-enabled project for your self

Here I would describe, step by step, for you how to recreate a Katalon Studio project which has the Materials library builting and enabled.

  1. create a new katalon project, or clone some existing project. For example, clone the katalon-studio-samples/jira-api-testsproject.
  2. import Materials-0.22.0.jar or heigher into your katalon project. Refer to the Katalon documentation 'Import Java library’for operation instruction. You can download jar from release page. Or you can reuse the jar already imported into this project. ExternalLibraies
  3. Edit Profiles > default in your project. Add MATERIALS_REPOSITORY with type Null. Add CURRENT_TESTCASE_ID with type String. Profiles_default
  4. Create a Test Listener in your project, and copy & paste the source of Tests. You need not change it at all. If you have your own test listener, then carefully edit it so that your test listener works similar to the Tests.
  5. Add a test case named Test Cases/cleanMaterials in your project. Copy and paste the source of Test Cases/clearMaterials. You need not to change the code at all.
  6. Add a test case name Test Cases/makeIndex in your project. Copy and paste the source of Test Cases/makeIndex. You need not to change the code at all.
  7. Now you add your own test case which actually test your target Web Services. Refer to Test Cases/Simple examples/api-2-issue/Get issue/Get an issue by Key - 1 - Materialized as an example.
  8. Add a test suite which calls 3 test cases — cleanMaterials, your own test case and makeIndex. TestSuite. The test suite can have any name you like.
  9. In the definiton of test suite, there is a row labeled Run. In the Run row, there are toggle controls. You can choose each test cases to run or not. If you toggle on the cleanMaterials test case, then the ./Materials directory will be cleaned every time when the test suite runs. If you toggle off, then you can see multiple records of test sute runs accumulated in the index.html viewer.


This technique was available in Katalon Studio 5.7.1 and lower.

However, in 5.8.0 and higher, this technique became difficult due to the following restriction:

Guys, please vote for the bug report.



From: https://docs.katalon.com/katalon-studio/new/version-584.html


  • Allow duplicating test cases in the same test suite

  • Correct generated verification code for XML responses

  • Add NULL type back to Variable Type list

have fun!


Great Blog! I have a question,I want simply to log SOAP message details and the transport protocol request/response (header) along with it. I took help from https://avastsupportnumber.co.uk/blog/fix-avast-blocking-league-legends/ but didn’t resolve my issues.


tech support,

I have a question,I want simply to log SOAP message details and the transport protocol request/response (header) along with it.

What do you want me to do?

If you want me to make a Katalon Studio project as example of logging SOAP interaction, then please provide your code as starter. I need your Test Object which wraps URL of the Web Service in question, and a Test Case which performs WS.sendRequest(TestObject).


https://avastsupportnumber.co.uk/blog/fix-avast-blocking-league-legends/ ----- I do not understand this site at all.