使用 Mule 从 URL 获得 XML

Get XML from URL with Mule

我有一个基本的 mule 流:

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

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
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://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <flow name="flow_test" doc:name="flow_test">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8089" doc:name="HTTP"/>
        <logger level="INFO" doc:name="Logger"/>
        <logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>

    </flow>
</mule>

我使用记录器通过控制台使用此值显示消息:

#[message.payloadAs(java.lang.String)]

问题是我只收到这条消息:

信息 2015-05-27 12:36:42,659 [[测试].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: /

其中“/”值将是 XML。我需要做什么才能显示 XML?

更新: 问题是 http.method INBOUND 是 GET,显示数据会是 POST。我可以将 GET 转换为 POST 吗?

谢谢。

您不需要转换 http 入站端点中的任何内容来获取数据...如果您使用 Rest 客户端 post 某些数据到此流或 postman,您将自动获取流中的数据并可以在记录器中打印。

你只需要 post 数据从外部到这个流程,正如我提到的使用 Rest clientpostman[= 18=..你会自动获取流中的数据