2015-04-07 54 views
0
<message-properties-transformer scope="outbound"> 
    <add-message-property key="username" value="admin" /> 
    <add-message-property key="password" value="admin"/> 
    <add-message-property key="Accept" value="application/json"/> 
</message-properties-transformer> 
<logger message=" outbound header username and password... 
    #[message.outboundProperties['username']] and  
    #[message.outboundProperties['password']]" 
level="INFO" doc:name="Logger"/> 

<http:outbound-endpoint 
     exchange-pattern="request-response" 
     address="http://localhost:8080/callReservation" 
     method="POST" 
     contentType="application/json" 
     doc:name="HTTP"/> 

在這裏,我無法通過標題值到http出境endpoint.any建議如何通過HTTP標頭值喜歡的用戶名和密碼:出站端點騾子

<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/callreservation" method="POST" contentType="application/json" doc:name="HTTP"> 

此出站端點,我嘗試設置的用戶名,密碼,頭

喜歡如下

<message-properties-transformer scope="outbound"> 
<add-message-property key="'http.headers'.username" value="admin"/> 
<add-message-property key="'http.headers'password" value="admin"/> 
</message-properties-transformer> 



<set-property propertyName="username" value="admin"/> 
<set-property propertyName="password" value="[email protected]"/> 
<set-property propertyName="Accept" value="application/json"/> 

,但沒有接受作爲頭用於出站端點。即時通訊使用騾子3.6.0

任何建議

+0

這是什麼mule版本? – afelisatti

+0

另外,記錄器的輸出是什麼? – afelisatti

+0

我在任意一個工作室中運行應用程序。如何檢查mule版本 – muledevlepoer07

回答

0

你可以通過用戶名和密碼如下: -

<http:outbound-endpoint exchange-pattern="request-response" user="admin" password="admin" host="localhost" port="8080" path="callReservation" method="POST" contentType="application/json" doc:name="HTTP"/> 
+0

我已經試過這個它不接受作爲標題值。 – muledevlepoer07

2

由於您使用的騾子3.6.0,我建議使用HTTP Request element自您正在使用的HTTP傳輸已棄用。使用此連接器添加顯式標頭是easy。這裏有一個例子:

<http:request-config name="HTTP_Request_Configuration" host="localhost" port="8080" doc:name="HTTP Request Configuration"/> 
<flow> 
... 
    <http:request config-ref="HTTP_Request_Configuration" path="callReservation" method="POST" doc:name="HTTP"> 
     <http:request-builder> 
      <http:header headerName="Content-Type" value="application/json"/> 
      <http:header headerName="username" value="admin"/> 
      <http:header headerName="password" value="admin"/> 
     </http:request-builder> 
    </http:request> 
... 
</flow> 

如果你想堅持到HTTP傳輸,那麼你需要使用一個Properties Transformer。在這種情況下:

<set-property propertyName="username" value="admin"/> 
<http:outbound-endpoint .../> 
相關問題