如何在http:outbound endpoint mule中传递诸如用户名和密码之类的头值
这里我无法将头值传递给http出站端点。有什么建议吗如何在http:outbound endpoint mule中传递诸如用户名和密码之类的头值,mule,Mule,这里我无法将头值传递给http出站端点。有什么建议吗 <message-properties-transformer scope="outbound"> <add-message-property key="username" value="admin" /> <add-message-property key="password" value="admin"/> <add-message-property key="Acce
<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:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/callreservation" method="POST" contentType="application/json" doc:name="HTTP">
但任何内容都不接受作为出站端点的标头。我正在使用mule 3.6.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"/>
<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="isgn@123"/>
<set-property propertyName="Accept" value="application/json"/>
由于您使用的是Mule 3.6.0,我建议使用,因为您使用的HTTP传输已不推荐使用。无法使用此连接器添加显式标头。下面是一个例子:
<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"/>
...
...
如果您想坚持HTTP传输,那么您需要使用一个。在这种情况下:
<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>
那是什么mule版本?还有,记录器的输出是什么?我在anypoint studio中运行应用程序。如何检查mule版本在参考库和JRE系统库部分旁边的项目结构中,您还应该看到“mule服务器”及其旁边的版本。