我想寫下一個目標動作序列: 1.呼叫DSS接收客戶列表 2.通過單獨呼叫另一個DSS服務來豐富每個客戶的。wso2esb迭代通過wso2dss結果
所以,我想我應該調用標註調解器,然後使用迭代器迭代它的結果。但我不明白我應該在迭代器中寫什麼。
還有一個問題 - 我是否正確,每次迭代的結果都會附加在'customer'標籤下?
詳細說明:從DSS返回
XML是下一個:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<customers xmlns="crm.crm.crm">
<customer>
<customerId>1</customerId>
<name>Customer #1</name>
<birthdate>2017-01-15T14:54:12.000+03:00</birthdate>
</customer>
</customers>
</soapenv:Body>
</soapenv:Envelope>
序列:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="BatchSequence" statistics="enable" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log description="">
<property name="text" value="Start batch seq"/>
</log>
<payloadFactory description="create dss request" media-type="xml">
<format>
<soapenv:Envelope xmlns:crm="crm.crm.crm" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<crm:getCustomers>
<crm:batchSize>3</crm:batchSize>
</crm:getCustomers>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<callout action="urn:getCustomers" description="dss: main object" initAxis2ClientOptions="false" serviceURL="http://192.168.3.32:9765/services/CrmDataService?wsdl">
<source type="envelope"/>
<target key="customers"/>
</callout>
<log description="">
<property expression="get-property('customers')" name="text"/>
</log>
<iterate description="Enrich customers" expression="/soapenv:Envelope/soapenv:Body/customers/customer" id="iterateId" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<target>
<sequence>
<property description="customerId" expression="/customerId" name="customerID" scope="default" type="STRING"/>
<log description="">
<property expression="get-property('customerID')" name="text"/>
</log>
</sequence>
</target>
</iterate>
<log description="">
<property name="text" value="End batch seq"/>
</log>
</sequence>
輸出:
[2017年1月27日10: 17:17,371] INFO - LogMediator To:,MessageID:urn:uuid:d628e361-beb8- 4c26-b06d-3901227ad76a,方向:請求,文本=開始批處理seq [2017-01-27 10:17:18,558] INFO - LogMediator To:,MessageID:urn:uuid:d628e361-beb8-4c26-b06d-3901227ad76a, Direction:request,text = 1Customer#12017-01-15T14:54:12.000 + 03:002Customer#22016-12-16T14:54:20.000 + 03:003Customer#32016-10-27T14:54:21.000 + 03:00 [2017年1月27日10:17:18559] WARN - RuntimeStatisticCollector事件發生後,事件收集完成後,事件 - urn_uuid_d628e361-beb8-4c26-b06d-3901227ad7 6a231160071781262
更新1 一些工作代碼。不知道這是正確的,因爲我有點有點混亂了這裏PayloadFactory ..
<payloadFactory description="" media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>$1</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="get-property('customers')"/>
</args>
</payloadFactory>
<iterate continueParent="true" description="" expression="$body/crm:customers/crm:customer" sequential="true" xmlns:crm="crm.crm.crm">
<target>
<sequence>
<property expression="//crm:customerId" name="customerID" scope="default" type="STRING"/>
<log>
<property expression="get-property('customerID')" name="text"/>
</log>
</sequence>
</target>
</iterate>
更新2 我想出一個主要問題 - 標註調停犯規」把應對信封上下文(如果我理解的話)。所以,我們不能只使用屬性來將它與迭代器連接起來,所以在這種情況下,我們應該使用像Payload工廠這樣的smth連接它們。不是很有用 如果smbdy知道如何做到這一點更簡單(直接將迭代器傳遞給屬性) - 請寫信給我。 解決方案 - 使用Call Medator。工作正常。
謝謝大家!在DSS響應
如果兩個DSS服務都位於同一個DSS服務器中,我認爲最好的方法是直接在那裏進行充實,使用ESB只是爲了任何最終的轉換和/或添加QoS功能。在ESB中進行充實意味着會有與多個呼叫相關的大量開銷。在DSS上做這件事,也會有開銷,但由於每個客戶都沒有往返,因此它會更小。 –
當然你是對的! 但這只是爲了教育目的,我正在探索WSO - 是否有可能在我們的集成項目中使用) – PVN