2015-04-06 45 views
0
<flow name="getDetails"> 
    <http:inbound-endpoint doc:description="This endpoint receives an HTTP message." doc:name="HTTP" exchange-pattern="request-response" host="localhost" port="8081" path="getDetails"/> 
    <json:xml-to-json-transformer doc:name="XML to JSON" mimeType="text/json" ignoreBadInput="true"/> 
    <logger message="xml to json output #[message.payload]" level="INFO" doc:name="Logger"/> 

     <logger message=" custom header username ... #[message.outboundProperties.get('http.headers.username')]" level="INFO" /> 
     <logger message=" custom header username ... #[message.inboundProperties.get('http.headers.username')]" level="INFO" /> 
    <http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8081/callReservation" method="POST" contentType="application/json" doc:name="HTTP"/> 
</flow> 

thru postman rest client(chrome)using,form-data,x-www-form-urlencoded。mule如何从postman rest客户端获取http头部值

我设置标头值等
http.headers.username =骡 http.headers.password =骡

在骡**<logger message=" custom header username ... #[message.outboundProperties.get('http.headers.username')]" level="INFO" />**

它显示空值。欢迎任何有价值的建议

+0

你正在使用哪个mule版本?你能分享你的流量吗? – afelisatti 2015-04-06 10:29:28

+0

我在上面添加了我的代码。请注意那 – muledevlepoer07 2015-04-06 12:03:42

回答

0

您不需要使用密钥名称作为http.headers.username。请使用键作为用户名和值作为骡子。然后,您应该能够使用MEL喜欢#入站访问属性的用户名属性[message.inboundProperties [“用户名”]]

+0

我在上面加了我的代码,看看那个。我得到像下面的错误 com.ctc.wstx.exc.WstxUnexpectedCharException:意外的字符'{'(代码123)在序言;预期'[' at [row,col {unknown-source}]:[1,1](javax.xml.transform.TransformerException)(org.mule.api.transformer.TransformerException)。消息有效负载的类型为:字符串 – muledevlepoer07 2015-04-06 12:04:41

0

这个问题似乎是从你的

<json:xml-to-json-transformer doc:name="XML to JSON" mimeType="text/json" ignoreBadInput="true"/> 

这是给你的但以下情况除外: - com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<' at [row,col {unknown-source}]: [1,1] (javax.xml.transform.TransformerException) (org.mule.api.transformer.TransformerException).

只需使用下面的表达式: - #[message.inboundProperties.username]#[message.inboundProperties['username']]在一个记录器,并将其放置刚过<http:inbound-endpoint/>,你会得到的值。