首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >给404映射为失败的http请求

给404映射为失败的http请求
EN

Stack Overflow用户
提问于 2019-01-04 13:26:07
回答 3查看 1.2K关注 0票数 0

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

代码语言:javascript
复制
    <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映射为failure.

代码语言:javascript
复制
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.

如果可以提供任何帮助,请让我知道!

EN

回答 3

Stack Overflow用户

发布于 2019-01-04 13:50:15

这意味着url不存在。在执行Mule之前,尝试在邮递员中直接点击网址。既然你消灭了host="",我就假装它是example.com。我的猜测是,它与p2有问题。如果要发送实际字符串,则需要对"/“进行URL编码,即%2F

因此,要测试命中https://www.example.com/resources/shipments/3054/child%2FLines,使用基本8月的授权。

邮差:https://www.getpostman.com/apps

票数 0
EN

Stack Overflow用户

发布于 2019-01-08 10:14:57

我面临的问题对我来说是独一无二的,我尝试了来自SOAPUI的REST调用,在那里它给了我同样的错误,即404 not found,所以我将它与POSTMAN请求进行比较,发现Authorization头是这方面缺少的部分。在将这个添加到http header之后,它完美地工作了。

票数 0
EN

Stack Overflow用户

发布于 2019-01-09 06:37:38

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

这里有两个解决方案: 1.在基本身份验证配置中添加preemptive="true“,先发制人选项传递用户名和密码,而无需等待服务器的提示。

  1. 在http:header value ="Basic dXNlcjoxMjM=“中添加授权
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54039838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档