我试图从骡子流中调用API Rest。这个API有一个基本的auth协议,所以我需要发送报头"Authorization: basic“。我遇到的问题是,在Anypoint Studio上,当我计算HTTP请求时,我在身份验证选项卡上没有获得Basic选项,我只看到NTLM。
在http:上,它也不起作用。
这是Mule配置:
< http:listener-config name="Gateway" host="localhost" port="8281" basePath="/base" doc:name="HTTP Listener Configuration"/>
< http:request-config name="OFSC" host="api.etadirect.com" basePath="/rest/ofscCore/v1" doc:name="HTTP Request Configuration" port="443" protocol="HTTPS">
< http:basic-authentication username="${ofsc.clientId}@${ofsc.instance}" password="${ofsc.clientKey}"/>
< /http:request-config>
< spring:beans>
< spring:bean id="Bean" name="BasicAuthEncode" class="tools.BasicAuthEncode" />
< /spring:beans>
< context:property-placeholder location="env.properties"/>
<flow name="TestFlow">
<http:listener config-ref="Gateway" path="/test" doc:name="HTTP">
<http:response-builder disablePropertiesAsHeaders="true"/>
<http:error-response-builder disablePropertiesAsHeaders="true"/>
</http:listener>
<invoke object-ref="BasicAuthEncode" method="encodeCredentials" doc:name="LPM" methodArgumentTypes="java.lang.String" methodArguments="${ofsc.clientId}@${ofsc.instance}:${ofsc.clientKey}" name="LPM2"/>
<set-variable variableName="credentials" value="Basic #[message.payloadAs(java.lang.String)]" doc:name="Creds"/>
<http:request config-ref="OFSC" path="/activities/3818" method="GET" doc:name="HTTP">
<http:request-builder>
<http:header headerName="Content-Type" value="application/json"/>
</http:request-builder>
<http:success-status-code-validator values="200,400,401,404,403"/>
</http:request>
<logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</flow>
我可能做错了什么,但找不到答案。希望你们能帮我
谢谢
发布于 2019-07-05 16:07:10
问题在我的财产档案里。
用引号包装的值和base64编码给了我错误的字符串。
发布于 2022-12-01 15:41:39
取消选中http配置中的“启用cookie”解决了这个问题。
https://stackoverflow.com/questions/56893245
复制相似问题