我目前在一家 IT 公司工作,MuleSoft 对我来说相对较新。虽然我学到了很多东西,但我遇到了一个问题。
我的问题是,每当我尝试设置有效负载以显示特定值时,它都不会按预期显示在响应正文中,即使我在流程末尾的转换消息中对其进行硬编码也是如此。
什么可能导致此问题?我的配置中是否缺少某些内容?
欢迎来到 Stack Overflow!分享您用于测试的代码是一个很好的做法,以便我们可以协助问题识别和调试。
如果没有您的具体代码,我将根据我对您的用例的理解提供一个示例。要继续,请按照以下步骤操作:
创建一个名为“mule-test”的新项目。
用下面提供的代码替换整个“mule-test.xml”mule 配置文件。
部署应用程序后,您可以使用以下 URL 访问它:http://localhost:8081/test。
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.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="4e5f4a85-7fbf-4574-adfa-6bf29817a9d1" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="mule-testFlow" doc:id="e09a142b-8597-4f90-a4f7-e4df8cb158a9" >
<http:listener doc:name="Listener" doc:id="b219dc15-d4ec-4334-80f3-c8f48bfb9c67" config-ref="HTTP_Listener_config" path="/test"/>
<ee:transform doc:name="Transform Message" doc:id="de99c1be-5fbc-43bd-9b94-7660dfef8210" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0 output application/json --- {
"Key1": "Value1",
"Key2": "Value2" }]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
谢谢!