如何在Mule中使用HTTP组件传递标头

问题描述:

我正在与Any Point Studio合作,我想通过键值对与当前请求一起传递标头如何使用现有的HTTP组件实现该目标.

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.

您可以通过Mule Client调用HTTP入站,这是一个示例:

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);

HTTP头位于MuleMessage的入站范围属性中.要从流中获取标题,可以使用:

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]"/>