How to preserve User-Agent HTTP header when messages passing through WSO2 ESB

When WSO2 ESB forwards a request to the back-end web service, ESB alters the User-Agent of the incoming request and sets it to Synapse-HttpComponent-NIO.

Suppose, you want to avoid this and preserve User-Agent header sent by client. You can simply do it using the following method.

Step 1

Open ESB_HOME/repository/conf/nhttp.properties file

Step 2

Add the following property and save nhttp.properties file.

http.user.agent.preserve=true


Step 3

Restart ESB and send a HTTP request to ESB. Monitor the HTTP traffic between ESB and the back-end web service. You will see the User-Agent value is not altered by ESB.

HTTP headers of the inbound request (client to ESB)

POST http://localhost:8280/services/Axis2Proxy HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: "urn:echoString"

User-Agent: Jakarta Commons-HttpClient/3.1

Host: localhost:8280

Content-Length: 299


HTTP headers of the outbound request (ESB to back-end service)

POST /services/Axis2Service HTTP/1.1

Content-Type: text/xml; charset=UTF-8

Accept-Encoding: gzip,deflate

User-Agent: Jakarta Commons-HttpClient/3.1

SOAPAction: "urn:echoString"

Transfer-Encoding: chunked

Host: 127.0.0.1:9765

Connection: Keep-Alive






Comments

Popular posts from this blog

Working with HTTP multipart requests in soapUI

Common mistakes to avoid in WSO2 ESB - 1 - "org.apache.axis2.AxisFault: The system cannot infer the transport information from the URL"

How to deploy JSR181 annotated class in Apache Axis2