97008 48403
+91 40-27177600

Blog

How to see 302 http status with header name location in Mule ESB?

single-blog

From the technical centre of excellence of Massil Technologies, our technology leaders make it easy to understand the complex situations you come across in Mule ESB from the experience of Massil Technologies to have countered them in their experience of working on client projects in real time. This blog introduces how to see 302 http status with header name location in Mule ESB. This blog is a part of series of blogs being authored and published by Massil Technologies for the benefit of the IT community globally.

While working on Mule ESB certifications, our team has come across the following situation: When you see there is a location header and http status 302 present in the code, Mule ESB http listener internally calls the location URL and gets the response with http status 200 which looks like a normal behavior. The requirement is to see is a 302 http status and a header with name location in Mule ESB postman.

Massil Technologies has come up with the following solution:

Step1: Go to POSTMAN setting as shown in the image:

Step2: Turn off the follow redirect as below:

Step3: Go to the interceptor on the top right as shown below:

Step4: If you don’t have the necessary interceptor, install it from from the following link: https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo

After installing restart the POSTMAN client.

Step5: Go again to the interceptor on top right and enable it as below:

Step6: Test your URL again as below, now you can track 302 in POSTMAN as below:

Step7: In the Mule ESB console you can see it has redirected although POSTMAN has tracked 302:

Mule Flow is as shown below:

XML CODE:

<?xml version=“1.0” encoding=“UTF-8”?>

<mule xmlns:http=“http://www.mulesoft.org/schema/mule/http”

xmlns=“http://www.mulesoft.org/schema/mule/core” xmlns:doc=“http://www.mulesoft.org/schema/mule/documentation”

xmlns:spring=“http://www.springframework.org/schema/beans”

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=“http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.9/mule-http.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd

http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd”>

<http:request-config name=“HTTP_Request_Configuration2” host=“localhost” port=“8081” doc:name=“HTTP Request Configuration”/>

<http:listener-config name=“HTTP_Listener_Configuration” host=“0.0.0.0” port=“8081” doc:name=“HTTP Listener Configuration”/>

<flow name=“xpathforeachFlow”>

<http:listener config-ref=“HTTP_Listener_Configuration” path=“/xpath” doc:name=“HTTP”/>

<logger message=“inside another flow” level=“INFO” doc:name=“Logger”/>

<set-payload value=“this is a test flow” doc:name=“Set Payload”/>

</flow>

<flow name=“MainFlow”>

<http:listener config-ref=“HTTP_Listener_Configuration” path=“/location302” doc:name=“HTTP” >

</http:listener>

<logger message=“inside 302” level=“INFO” doc:name=“Logger”/>

<set-property propertyName=“http.status” value=“#[‘302’]” doc:name=“Property”/>

<set-property propertyName=“location” value=“http://localhost:8081/xpath” doc:name=“Property”/>

<logger message=“after property setting #[message]” level=“INFO” doc:name=“Logger”/>

</flow>

</mule>

Hence, we have gone through the step by step process to depict the way Massil Technologies team has addressed the situation we have come across. Hope this article from Massil Technologies was useful for you. If you have any further queries on this topic, please reach out to info@massil.tech

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Get in touch with us

Scroll to top