Mule ESB XML映射到HTTP Post

时间:2014-12-04 06:07:50

标签: xml http mule

我有以下Mule ESB流程。它的目的是读取XML,映射它,然后通过HTTP post将一组字段提交给API。

我没有向API发送任何数据并且此错误消息。我相信我的问题是无法正确设置输出属性,例如这个区域。

org.mule.transformer.simple.MessagePropertiesTransformer:带有键'区域'的属性,在使用'#[message.outboundProperties [' area']]的邮件中找不到&#39 ;.由于该值已标记为可选,因此未对此属性的消息设置任何内容

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

<mule xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" 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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <data-mapper:config name="XML_To_XML" transformationGraphPath="xml_to_xml.grf" doc:name="XML_To_XML"/>
    <flow name="Flow1" doc:name="Flow1">
        <file:inbound-endpoint path="/Users/dylan/Documents/Projects/Mulesoft/XMLin" moveToDirectory="/Users/dylan/Documents/Projects/Mulesoft/XMLout" responseTimeout="10000" doc:name="File"/>
        <data-mapper:transform config-ref="XML_To_XML" doc:name="XML To XML">
            <data-mapper:input-arguments>
            </data-mapper:input-arguments>
        </data-mapper:transform>
        <message-properties-transformer doc:name="send-check-api">
            <add-message-property key="source_id" value="#[message.outboundProperties['source_id']]"/>
            <add-message-property key="country" value="#[message.outboundProperties['country']]"/>
            <add-message-property key="region" value="#[message.outboundProperties['region']]"/>
            <add-message-property key="area" value="#[message.outboundProperties['area']]"/>
            <add-message-property key="city" value="#[message.outboundProperties['city']]"/>
            <add-message-property key="source_agentid" value="#[message.outboundProperties['source_agentid']]"/>
            <add-message-property key="status" value="#[message.outboundProperties['status']]"/>
            <add-message-property key="source" value="#[message.outboundProperties['source']]"/>
        </message-properties-transformer>
        <set-property propertyName="http.method" value="#[flowVars['send-check-api']]" doc:name="set-post-attributes"/>
        <logger level="DEBUG" doc:name="Logger"/>
        <http:outbound-endpoint exchange-pattern="request-response" host="XX.XX.XX.com" port="80" method="POST" doc:name="HTTP" path="v1/property/check"/>
    </flow>
</mule>

1 个答案:

答案 0 :(得分:0)

message-properties-transformers内的出站属性不太可能存在。 IIRC datamapper的出站属性被转换为流量变量。

这也可以解释整个message-properties-transformer的含义,因为就像现在一样,将VAR_X复制到VAR_X中。