我正在尝试m子训练演练6-3,并获得不同的输出

时间:2019-04-11 15:54:03

标签: mule mule-studio anypoint-studio mulesoft

这是m子4开发人员培训的6-3中的示例演练。使用Advanced Rest Client(ARC)时得到不同的输出

任何人都可以帮助我解决此问题。

下面是配置XML文件。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="7afe9f88-0f1f-4a25-9c3f-572e417bd4a4" >
        <http:listener-connection host="0.0.0.0" port="8081" />
    </http:listener-config>
    <http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="a965e1e5-26d7-49c1-9eb4-b169b18ff64f" >
        <http:request-connection host="localhost" port="8081" />
    </http:request-config>
    <flow name="helloFlow" doc:id="d8e8afa2-238a-4dc5-9a43-96a932422a2a" >
        <http:listener doc:name="GET /hello" doc:id="86b90724-ca42-46ee-bc40-41204f6a2f7f" config-ref="HTTP_Listener_config" path="/hello" allowedMethods="GET">
            <http:response reasonPhrase="Success">
                <http:headers ><![CDATA[#[output application/java
---
{
    "name" : "Max"
}]]]></http:headers>
            </http:response>
        </http:listener>
        <set-payload value="Hello World" doc:name="Hello" doc:id="c9c362cb-8d96-4a66-bdcf-91ce611cffbd" />
        <http:request method="GET" doc:name="GET /goodbye" doc:id="a2eab23f-42d2-4fef-94ea-c170364c5e27" config-ref="HTTP_Request_configuration" path="/goodbye" responseTimeout="300000" />
        <logger level="INFO" doc:name="Logger" doc:id="5f813a3c-9af8-4131-a1ec-2947e301ba90" />
    </flow>
    <flow name="apdev-examplesFlow" doc:id="06c419b2-f71e-4711-8d3c-4585b15fd8ed" >
        <http:listener doc:name="GET /goodbyeFlow" doc:id="60dc16f6-47d5-460b-a471-4567ac7ec0d0" config-ref="HTTP_Listener_config" path="/goodbye" allowedMethods="GET"/>
        <set-payload value="Goodbye Mulesoft" doc:name="Goodbye" doc:id="df40f379-5a7b-4556-abeb-7919863af9ec" />
        <logger level="INFO" doc:name="Logger" doc:id="39f101bc-f33b-4fdc-b66c-032455f6d0af" />
    </flow>
</mule>

预期产量

!(https://imgur.com/KRQJki0.png

获得的输出

!(https://i.imgur.com/0eukHAS.png

1 个答案:

答案 0 :(得分:0)

要在ARC中查看响应标头,请点击最右侧的“详细信息”链接(与200状态代码在同一行)

身体也有所不同,因为在设置有效载荷中您拥有“ Goodbye Mulesoft”而不是“ Goodbye”:

<set-payload value="Goodbye Mulesoft" doc:name="Goodbye" doc:id="df40f379-5a7b-4556-abeb-7919863af9ec" />

更改为:

<set-payload value="Goodbye" doc:name="Goodbye" doc:id="df40f379-5a7b-4556-abeb-7919863af9ec" />

这将使您的内容长度标题也匹配。