IM和我也跟着在這個網址樣本:WSO2 ESB總調解人工作不使用wso2ESB 4.8.0正確
寫這個代理服務:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="adminBroadcastEndpoint"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<send>
<endpoint>
<recipientlist>
<endpoint>
<address uri="http://127.0.0.1:8080/RestService/rest/servizio/"/>
</endpoint>
<endpoint>
<address uri="http://127.0.0.1:8081/RestService/rest/servizio/"/>
</endpoint>
</recipientlist>
</endpoint>
</send>
<drop/>
</inSequence>
<outSequence>
<payloadFactory media-type="xml">
<format>
<broadcast>
$1
</broadcast>
</format>
<args>
<arg evaluator="xml" expression="$body/root"/>
</args>
</payloadFactory>
<aggregate>
<completeCondition>
<messageCount/>
</completeCondition>
<onComplete xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" expression="/">
<send/>
</onComplete>
</aggregate>
</outSequence>
</target>
<description/>
</proxy>
收件人列表中有兩個用xml字符串回答的服務器。第一臺服務器的答案與
<root>
<codice>0</codice>
<messaggio>MESSAGE1</messaggio>
<result><name>CorreggiPecJob1</name><group>POSTA1</group></result>
<result><name>SchedulaIndiceJob1</name><group>INDICE1</group></result>
</root>
,並與第二服務器:
<root>
<codice>0</codice>
<messaggio>MESSAGE2</messaggio>
<result><name>CorreggiPecJob2</name><group>POSTA2</group></result>
<result><name>SchedulaIndiceJob2</name><group>INDICE2</group></result>
</root>
總調解員後,我應該期待與所有那些2消息的結果合併......但在從代理響應服務我得到只是第二個服務器的答案或第一個隨機。 如果我在onComplete標記hawever之後突然插入一個日誌調解器,那麼esb會用兩個響應打印整個合併的消息,但似乎在發送中介器上會有東西丟失。 這是爲什麼發生?
另一個問題是:爲什麼像
$體/廣播// XPath表達式導致 不起作用上升這一例外?
2014-03-02 17:37:32,021] ERROR - AggregateMediator Error evaluating expression: $body/broadcast//result
org.apache.synapse.SynapseException: Could not find matching elements to aggregate.
我意識到,如果我定義了一個命名空間和prfix在像payloadfactory追加:
<payloadFactory xmlns:m0="my.namespace" media-type="xml">
<m0:format>
<m0:broadcast>
$1
</m0:broadcast>
</m0:format>
<args>
<arg evaluator="xml" expression="$body/root"/>
</args>
</payloadFactory>
表達:$體/ M0:廣播做工精細...所以是的命名空間定義是必需的
它有什麼我失蹤?感謝
我不認爲WSO支持XPath 2.0,所以如果你想使用通配符命名空間,你必須去'$ body/* [local-name(。)='broadcast']'。 –
謝謝我添加了我的第一篇文章的答案,因爲我需要用一些代碼來豐富它。代理響應中仍存在問題 – Alex