How to pass Headers using HTTP component in Mule

强颜欢笑 提交于 2019-12-12 05:59:27

问题


Hi I am working with Any Point Studio and i want to pass headers with the current request with a key value pair How to achieve that using existing HTTP Component.


回答1:


You can invoke the HTTP Inbound through Mule Client, here is an example:

MuleClient muleClient = new MuleClient(muleContext);
Map<String, Object> headers = new HashMap<String, Object>(1);
headers.put("key", "456453N123");
MuleMessage result = muleClient.send("http://localhost:8081/prm", PAYLOAD, headers);

The HTTP headers are in the inbound-scoped properties of the MuleMessage. To get the header from a flow, you can use:

<logger level="INFO" message="Header Content-Type = #[header:key]"/>



回答2:


You can also set header using the Property component or Message properties for setting multiple header data see below:



来源:https://stackoverflow.com/questions/27149882/how-to-pass-headers-using-http-component-in-mule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!