我可不是工作方案中的工作與調用DataService的和發送該消息代理服務:結合WSO2 ESB內迭代/聚合和XSLT調解員預計一樣
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:add="http://www.example.org/Address/">
<soap:Body>
<dat:getmpartybranch xmlns:dat="http://ws.wso2.org/dataservice">
<dat:clientid>473906852857651</dat:clientid>
</dat:getmpartybranch>
</soap:Body>
</soap:Envelope>
並且接受這樣的響應:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<DataCollection xmlns="http://ws.wso2.org/dataservice">
<Datalist>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Datalist>
<Datalist>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</Datalist>
</DataCollection>
</soapenv:Body>
</soapenv:Envelope>
代理迭代在每個節點Datalist中,並與客戶端ID和partybranchid的值,它創建另一個請求發送到另一個的DataService:
請求1:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<dat:getselect_addresses xmlns:dat="http://ws.wso2.org/dataservice">
<dat:objectid>796243010946586</dat:objectid>
<dat:clientid>473906852857651</dat:clientid>
</dat:getselect_addresses>
</soapenv:Body>
</soapenv:Envelope>
請求2:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<dat:getselect_addresses xmlns:dat="http://ws.wso2.org/dataservice">
<dat:objectid>2500000000</dat:objectid>
<dat:clientid>473906852857651</dat:clientid>
</dat:getselect_addresses>
</soapenv:Body>
</soapenv:Envelope>
響應1:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<Addresses xmlns="http://ws.wso2.org/dataservice">
<Address>
<address>direccion1</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Address>
<Address>
<address>direccion3</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Address>
</Addresses>
</soapenv:Body>
</soapenv:Envelope>
響應2:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<Addresses xmlns="http://ws.wso2.org/dataservice">
<Address>
<address>yo</address>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</Address>
</Addresses>
</soapenv:Body>
</soapenv:Envelope>
在我使用與此表達一個agregator介//添加outsequece :地址/地址:地址,等等Ÿ出把消息是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<Address xmlns="http://ws.wso2.org/dataservice"><address>direccion1</address><partybranchid>796243010946586</partybranchid><clientid>473906852857651</clientid></Address>
<Address xmlns="http://ws.wso2.org/dataservice"><address>direccion3</address><partybranchid>796243010946586</partybranchid><clientid>473906852857651</clientid></Address>
<Address xmlns="http://ws.wso2.org/dataservice"><address>yo</address><partybranchid>2500000000</partybranchid><clientid>473906852857651</clientid></Address>
</soapenv:Body>
</soapenv:Envelope>
輸出序列:
<outSequence>
<aggregate id="iterate1">
<completeCondition>
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:add="http://ws.wso2.org/dataservice"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
expression="//add:Addresses/add:Address">
<log level="full"/>
</onComplete>
</aggregate>
<xslt key="conf:/xslt/Tranformacion_DS_to_ESB.xsl"/>
<send/>
</outSequence>
現在我想用XSLT把這個消息讓我使用Altova的XML SPY,打造這個「Tranformacion_DS_to_ESB.xsl」:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:a="http://ws.wso2.org/dataservice" xmlns:b="http://www.example.org/Address/" exclude-result-prefixes="a fn xs">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<b:getAddressResponse>
<xsl:for-each select="//a:Address">
<address>
<address>
<xsl:value-of select="a:address"/>
</address>
<partybranchid>
<xsl:value-of select="a:partybranchid"/>
</partybranchid>
<clientid>
<xsl:value-of select="a:clientid"/>
</clientid>
</address>
</xsl:for-each>
</b:getAddressResponse>
</xsl:template>
</xsl:stylesheet>
如果我測試這個變換XML SPY與先前的SOAP消息的結果是這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<b:getAddressResponse xmlns:b="http://www.example.org/Address/">
<address>
<address>direccion1</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</address>
<address>
<address>direccion3</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</address>
<address>
<address>yo</address>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</address>
</b:getAddressResponse>
而且it's OK,但是當我把ESB內這種轉變的總調停後完成它的工作我收到此錯誤信息:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<b:getAddressResponse xmlns:b="http://www.example.org/Address/">
<address>
<address>direccion1</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</address>
</b:getAddressResponse>
<Address xmlns="http://ws.wso2.org/dataservice">
<address>direccion3</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Address>
<Address xmlns="http://ws.wso2.org/dataservice">
<address>yo</address>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</Address>
</soapenv:Body>
</soapenv:Envelope>
這個結果的任何想法?
編輯: 當我嘗試用馬蒂亞斯建議我得到一個正確的輸出XML SPY但在ESB我得到另一個錯誤輸出代碼:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<address xmlns:b="http://www.example.org/Address/">
<address>direccion1</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</address>
<Address xmlns="http://ws.wso2.org/dataservice">
<address>direccion3</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Address>
<Address xmlns="http://ws.wso2.org/dataservice">
<address>yo</address>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</Address>
</soapenv:Body>
</soapenv:Envelope>
最後更新: 使用什麼@Ratha建議我和這個鏈接wso2 ESB : Split/Gather Pattern - Single Response這是正確的配置。
這是我outsequence:
<outSequence>
<property name="root" scope="default">
<root:rootelement xmlns:root="http://ws.wso2.org/dataservice"/>
</property>
<aggregate id="iterate1">
<completeCondition>
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:add="http://ws.wso2.org/dataservice"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
expression="//add:Addresses/add:Address"
enclosingElementProperty="root">
<log level="full"/>
</onComplete>
</aggregate>
<xslt key="conf:/xslt/Tranformacion_DS_to_ESB.xsl"/>
<send/>
</outSequence>
正如你可以看到我把root屬性與rootElement的作爲根我的彙總信息,並使用enclosingElementProperty =「根」的的onComplete配置裏面,所以我總輸出看現在這個樣子:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<root:rootelement xmlns:root="http://ws.wso2.org/dataservice">
<Address xmlns="http://ws.wso2.org/dataservice">
<address>direccion1</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Address>
<Address xmlns="http://ws.wso2.org/dataservice">
<address>direccion3</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</Address>
<Address xmlns="http://ws.wso2.org/dataservice">
<address>yo</address>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</Address>
</root:rootelement>
</soapenv:Body>
</soapenv:Envelope>
而且更新我的XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:a="http://ws.wso2.org/dataservice" xmlns:b="http://www.example.org/Address/" exclude-result-prefixes="a fn xs">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<b:getAddressResponse>
<xsl:for-each select="//a:rootelement/a:Address">
<address>
<address>
<xsl:value-of select="a:address"/>
</address>
<partybranchid>
<xsl:value-of select="a:partybranchid"/>
</partybranchid>
<clientid>
<xsl:value-of select="a:clientid"/>
</clientid>
</address>
</xsl:for-each>
</b:getAddressResponse>
</xsl:template>
</xsl:stylesheet>
現在我的代理響應是這樣的,因爲我想:這裏
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<b:getAddressResponse xmlns:b="http://www.example.org/Address/">
<address>
<address>direccion1</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</address>
<address>
<address>direccion3</address>
<partybranchid>796243010946586</partybranchid>
<clientid>473906852857651</clientid>
</address>
<address>
<address>yo</address>
<partybranchid>2500000000</partybranchid>
<clientid>473906852857651</clientid>
</address>
</b:getAddressResponse>
</soapenv:Body>
</soapenv:Envelope>
關於配置/信封問題我剛剛發現另一個SO帖子提到這種問題並提供了一種方法。不知道是否可應用,但只是想分享的情況下,這可能是任何幫助:http://stackoverflow.com/questions/17903010/wso2-esb-split-gather-pattern-single-response – 2014-09-28 16:44:09
謝謝,我會試試這個方法並返回結果 – 2014-09-28 16:46:27
@JorgeInfanteOsorio在聚合介體結束後記錄聚合介體的輸出。在發送到xslt mediator之前查看記錄的消息格式。然後,你可以很容易地確定問題 – Ratha 2014-10-02 05:08:26