【问题标题】:Mule http request giving 404 mapped as failureMule http请求将404映射为失败
【发布时间】:2019-01-04 13:26:07
【问题描述】:

我正在尝试在 http 请求中传递多个 URI 参数,如下所示:

    <http:listener-config name="HTTP_Listener_Configuration"
    host="localhost" port="8081" doc:name="HTTP Listener Configuration"
    connectionIdleTimeout="40000" />
<http:request-config name="HTTP_Request_Configuration1" protocol="HTTPS" host="" port="443" doc:name="HTTP Request Configuration" connectionIdleTimeout="300000" responseTimeout="50000">
    <http:basic-authentication username="user" password="123"/>
</http:request-config>    
<flow name="testFlow">
    <http:listener config-ref="HTTP_Listener_Configuration"
        path="/paypal" allowedMethods="GET" doc:name="HTTP" />
    <set-variable variableName="config" value="#[{'p1':'3054', 'p2':'child/Lines'}]" doc:name="Variable"/>
    <http:request config-ref="HTTP_Request_Configuration1" path="/resources/shipment/{p1}/{p2}" method="GET" doc:name="HTTP">
        <http:request-builder>
            <http:uri-params expression="#[flowVars.config]"/>
        </http:request-builder>
    </http:request>
</flow>

但这给了我如下错误:

响应代码 404 映射为失败。

ERROR 2019-01-04 18:46:34,526 
[[paypaltest].HTTP_Listener_Configuration.worker.01] 
org.mule.exception.DefaultMessagingExceptionStrategy: 


********************************************************************************
Message               : Response code 404 mapped as failure.
Payload               : org.glassfish.grizzly.utils.BufferInputStream@b473ec2
Element               : /testFlow/processors/1 @ test:test.xml:29 (HTTP)
Element XML           : <http:request config-ref="HTTP_Request_Configuration1" path="/resources/shipments/{p1}/{p2}" method="GET" doc:name="HTTP">
                        <http:request-builder>
                        <http:uri-params expression="#[flowVars.config]"></http:uri-params>
                        </http:request-builder>
                        </http:request>
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.http.internal.request.ResponseValidatorException: Response code 404 mapped as failure.

如果可以提供任何帮助,请告诉我!

【问题讨论】:

    标签: mule mule-studio mule-component mule-esb


    【解决方案1】:

    表示该网址不存在。在 Mule 中实现之前,尝试直接在 postman 中点击 url。既然你清除了host="",我就假装它是example.com。我的猜测是p2有问题。如果您想发送实际的字符串,您需要对“/”进行 URL 编码,即%2F

    所以要使用 Basic Auth for Authorization 测试命中 https://www.example.com/resources/shipments/3054/child%2FLines

    邮递员:https://www.getpostman.com/apps

    【讨论】:

    • 谢谢..你的猜测是正确的,因为它使用一个参数,即p1,但一旦我实施p2,它就不起作用..我尝试了你的解决方案,但它给了我同样的问题.
    【解决方案2】:

    我遇到的问题对我来说是独一无二的,我从 SOAPUI 尝试了这个 REST api 调用,它给了我同样的错误,即 404 not found 所以我将它与 POSTMAN 请求进行比较,发现 Authorization 标头是缺失的部分为了这。 将此添加到http header 后,它运行良好。

    【讨论】:

      【解决方案3】:

      请参考 https://docs.mulesoft.com/connectors/http/http-authentication

      这里有两个解决方案: 1.基本认证配置中增加preemptive="true" 抢先选项传递用户名和密码,无需等待服务器提示。

      1. 在 http:header 值 ="Basic dXNlcjoxMjM="
      2. 中添加授权

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-04-10
        • 1970-01-01
        • 2011-01-10
        • 1970-01-01
        • 2020-01-21
        • 2018-09-18
        • 2019-03-25
        • 2022-11-13
        相关资源
        最近更新 更多