Wednesday, May 15, 2013

How to Convert JMeter Responses' Content-Type Header to any Format



How to Convert JMeter Responses' Content-Type Header to any Format: 


There are situations where you will get different formatted responses in JMeter.

As an example you will get binary response which is not readable. i.e: "Content-Type: application/octet-stream"
 Yet, you want to convert them to human readable format such as "Content-Type: application/xml"

To Convert the content-Type format, "Accept" header in HTTP Header Manager can be used.
ex:
Accept: application/xml or Aceept: text/xml, application/xhtml+xml

Send JMeter requests such as POST, PUT, GET, DELETE and view the message format with TCPMON.
(TCPMon is a utility that allows the messages to be viewed and resent. It is very much useful as a debug tool. http://ws.apache.org/tcpmon/)

tcpmon response from backend:

HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=83A7EAF464474482FAB4ACE810E14592; Path=/jaxrs_basic_44/; HttpOnly
Date: Thu, 16 May 2013 04:51:13 GMTfr
Content-Type: application/octet-stream
Content-Length: 115
Server: WSO2 Carbon Server

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <Customer>
      <id>123</id>
      <name>method : test1</name>
   </Customer>


Binary format Response at user level: 

HTTP/1.1 200 OK
Content-Type: application/xml; charset=UTF-8
Server: WSO2 Carbon Server
Set-Cookie: JSESSIONID=83A7EAF464474482FAB4ACE810E14592; Path=/jaxrs_basic_44/; HttpOnly
Date: Thu, 16 May 2013 04:51:13 GMT
Transfer-Encoding: chunked
Connection: keep-alive

fb
<axis2ns11:binary xmlns:axis2ns11="http://ws.apache.org/commons/ns/payload">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxDdXN0b21lcj48aWQ+MTIzPC9pZD48bmFtZT5tZXRob2QgOiB0ZXN0MTwvbmFtZT48L0N1c3RvbWVyPg==</axis2ns11:binary>0


After Using the "Accept" header in JMeter HTTP Header Manager (Refer the screenshot to add the Accept header):




Response at user level:
HTTP/1.1 200 OK
Content-Type: application/xml; charset=UTF-8
Server: WSO2 Carbon Server
Set-Cookie: JSESSIONID=78A769D448B58BC8D0F2D7858AB20E63; Path=/jaxrs_basic_44/; HttpOnly
Date: Thu, 16 May 2013 06:16:36 GMT
Transfer-Encoding: chunked
Connection: keep-alive

3c
<Customer>
   <id>123</id>
   <name>method : test1</name></Customer>0


1 comment: