我刚开始骡子和POC工作。我想通过调用一个返回xml作为响应的http端点来丰富有效负载(target.xml)(source.xml)。
<flow name="mule-configFlow" doc:name="mule-configFlow">
<jms:inbound-endpoint doc:name="JMS" connector-ref="Active_MQ" queue="QUEUE1"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
<enricher doc:name="Message Enricher" target="#[xpath:Customer/OfficeId]">
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8095" path="myservice/v1/" method="GET" doc:name="HTTP">
<expression-transformer evaluator="xpath" expression="Response/OffId" />
</http:outbound-endpoint>
</enricher>
<jms:outbound-endpoint queue="QUEUE2" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
我已经验证并且http端点工作正常,但我收到以下错误
Expression Evaluator "xpath" with expression "Response/OffId" returned null but a value was required
我是否正确配置了源和目标表达式?
传入消息有效负载(target.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.xyz.com/abc/v1">
<ActionType>ACCOUNT_ADDED</ActionType>
<OfficeId></OfficeId>
<MemberId></MemberId>
</Customer>
富集源(source.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response xmlns="http://www.xyz.com/abc/v1">
<OffId></OffId>
<MemId></MemId>
</Response>
答案 0 :(得分:0)
这里有几个问题:
要使其工作,将出站端点和表达式传输器放在流程链中,使用xpath表达式处理命名空间或忽略它们,并将初始xml字符串有效负载转换为其他东西,例如DOM,你可以操纵。
这样的事情应该有效:
<mulexml:xml-to-dom-transformer returnClass="org.dom4j.Document"/>
<enricher source="#[payload]" target="#[payload.rootElement.element('OfficeId').text]">
<processor-chain>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8095" path="myservice/v1/" method="GET"/>
<expression-transformer evaluator="xpath" expression="//*[local-name()='OffId']" />
</processor-chain>
</enricher>