Mule http请求给出404映射为失败

时间:2019-01-04 13:26:08

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

我试图按以下方式在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.

请让我知道是否可以提供任何帮助!

3 个答案:

答案 0 :(得分:0)

这表示该网址不存在。在Mule中实施之前,请尝试直接在邮递员中访问url。由于您清除了host =“”,因此我将其装作为example.com。我的猜测是p2存在问题。如果您想发送实际的字符串,则需要URL编码“ /”,即%2F

因此,要使用授权的基本身份验证来测试匹配https://www.example.com/resources/shipments/3054/child%2FLines

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

答案 1 :(得分:0)

我遇到的问题对我来说是唯一的,我尝试了从SOAPUI进行的REST api调用,它给了我相同的错误,即404 not found,所以我将它与POSTMAN请求进行了比较,发现Authorization标头是这件遗失的东西。 将其添加到http header后,效果很好。

答案 2 :(得分:0)

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

这是两种解决方案: 1.在基本身份验证配置中添加preemptive =“ true” 抢占式选项无需等待服务器的提示即可传递用户名和密码。

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