简体   繁体   English

在wso2esb中使用迭代器介体时出错

[英]Error while using iterator mediator in wso2esb

I'm using wso2esb 4.7.0 and wso2dss 3.1.0.My scenario is i wish to select all partybranch regarding particular clientid. 我正在使用wso2esb 4.7.0和wso2dss 3.1.0。我的场景是我希望选择关于特定clientid的所有partybranch。 For that purpose i have fire a query like : 为此,我有一个类似的查询:

select partybranchid,clientid from mpartybranch where clientid = 473906852857651

and it gives me list of 2 records like : 它给了我2条记录的清单,例如:

partybranchid    clientid

-2500000000      473906852857651
796243010946586  473906852857651

I wish to split these two and find out address regarding each of them.I have use following query in dss that works seperately for me is : 我希望将这两个分开并找出每个地址。​​我在dss中使用以下查询,对我来说单独工作是:

select * from address where partybranchid = ? and clientid =?

Now i have use iterator mediator in wso2esb to implement this in single click.My configuration is : 现在我在wso2esb中使用了迭代器中介器,只需单击即可实现此功能。我的配置是:

     <iterate xmlns:f="http://ws.wso2.org/dataservice" continueParent="true" preservePayload="true" expression="//f:Datalist" id="iterate1" sequential="true">
        <target>
           <sequence>
              <property xmlns:s="http://ws.wso2.org/dataservice" name="partybranchid1" expression="//s:partybranchid/text()" scope="default" type="STRING"/>
              <property xmlns:s="http://ws.wso2.org/dataservice" name="latitude" expression="get-property('latitude')"/>
              <property xmlns:s="http://ws.wso2.org/dataservice" name="longitude" expression="get-property('longitude')"/>
              <property xmlns:s="http://ws.wso2.org/dataservice" name="radius" expression="get-property('radius')"/>
              <payloadFactory media-type="xml">
                 <format>
                    <p:select_addresses_op xmlns:p="http://ws.wso2.org/dataservice">
                       <p:latitude>$1</p:latitude>
                       <p:longitude>$2</p:longitude>
                       <p:radius>$3</p:radius>
                       <p:objectid>$4</p:objectid>
                    </p:select_addresses_op>
                 </format>
                 <args>
                    <arg xmlns:s="http://ws.wso2.org/dataservice" expression="get-property('latitude')" evaluator="xml"/>
                    <arg xmlns:s="http://ws.wso2.org/dataservice" expression="get-property('longitude')" evaluator="xml"/>
                    <arg xmlns:s="http://ws.wso2.org/dataservice" expression="get-property('radius')" evaluator="xml"/>
                    <arg xmlns:s="http://ws.wso2.org/dataservice" expression="get-property('partybranchid1')" evaluator="xml"/>
                 </args>
              </payloadFactory>
              <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
              <property name="messageType" value="application/json" scope="axis2"/>
              <send receive="spatial_seq3">
                 <endpoint>
                    <address uri="http://localhost:9764/services/Aspatialtrial_Dataservice/" format="soap11"/>
                 </endpoint>
              </send>
           </sequence>
        </target>
     </iterate>

This configuration is working but doesn't give expected output.Following are the outputs at client side and server side: 此配置有效,但未提供预期的输出。以下是客户端和服务器端的输出:

At server side(ESB) output : 在服务器端(ESB)输出:

[2014-09-25 09:52:30,941]  INFO - LogMediator To: /services/spatial_proxy_test, MessageID: urn:uuid:c91c22b6-245f-49f7-bf30-65561c87050f, Direction: request, userid = null, username = vikash|214057357158656, password = gbadmin
[2014-09-25 09:52:30,953]  INFO - TimeoutHandler This engine will expire all callbacks after : 120 seconds, irrespective of the timeout action, after the specified or optional timeout
[2014-09-25 09:52:31,286]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:9fa3c017-27f5-405e-a11b-33a9fa9a8f44, Direction: response, kk = true, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ResponseJSON><Body><Datalist><Authentication>true</Authentication></Datalist></Body></ResponseJSON></soapenv:Body></soapenv:Envelope>
[2014-09-25 09:52:32,148]  INFO - LogMediator FORCE_ERROR_ON_SOAP_FAULT = true, partybranchid1 = -2500000000796243010946586, latitude = 18.975, longitude = 72.8258, radius = 10
[2014-09-25 09:52:32,344]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:c635aa03-36ac-4af7-8b01-9bb31b35f4ef, Direction: response, Datalist values logged = <Datalist xmlns="http://ws.wso2.org/dataservice"><addressid>457492199890748451</addressid><geocode>POINT(18.975 72.8258)</geocode></Datalist>, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><DataCollection xmlns="http://ws.wso2.org/dataservice"><Datalist><addressid>457492199890748451</addressid><geocode>POINT(18.975 72.8258)</geocode></Datalist></DataCollection></soapenv:Body></soapenv:Envelope>
[2014-09-25 09:52:32,345]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:e77556c0-b722-4f91-879b-1cbb4ae20aec, Direction: response, Datalist values logged = <Datalist xmlns="http://ws.wso2.org/dataservice"><addressid>456211760366486560</addressid><geocode>POINT(19.0769048 72.8570555)</geocode></Datalist><Datalist xmlns="http://ws.wso2.org/dataservice"><addressid>456217678470710306</addressid><geocode>POINT(18.975 72.8258)</geocode></Datalist>, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><DataCollection xmlns="http://ws.wso2.org/dataservice"><Datalist><addressid>456211760366486560</addressid><geocode>POINT(19.0769048 72.8570555)</geocode></Datalist><Datalist><addressid>456217678470710306</addressid><geocode>POINT(18.975 72.8258)</geocode></Datalist></DataCollection></soapenv:Body></soapenv:Envelope>

at client side output 在客户端输出

{"ResponseJSON":{"Body":{"Datalist":{"addressid":"457492199890748451","geocode":"POINT(18.975 72.8258)"}},"Status":"200","Total":"1.0"}}

And request is : 要求是:

 curl -v -H "Accept: application/json" -H "Content-Type:application/json" -H "ModifiedOn:0"   -H "username:vikash|214057357158656" -H "password:gbadmin" -d '{"usercode":"suresh","clientid":"473906852857651","longitude":"72.8258","radius":"10","latitude":"18.975"}' http://youtility-desktop:8282/services/spatial_proxy_test

Server side log shows that it is iterating fine but at client side gives response of one iteration only.Why so?IS their any changes regarding sequence options like ContinueParent or preservepayload etc..?Please let me know.. 服务器端日志显示它正在迭代,但是在客户端仅给出了一次迭代的响应。为什么?它们对诸如ContinueParent或preservepayload等序列选项的任何更改是吗?请告诉我。

I test your scenario last night, my proxy look like this: 昨晚我测试了您的方案,我的代理如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="AddressProxy"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <property xmlns:p="http://www.example.org/Address/"
                   name="clientid"
                   expression="//p:getAddress/clientid"
                   scope="default"
                   type="STRING"/>
         <sequence key="conf:/sequencesStackOverFlow/getmpartybranch"/>
      </inSequence>
      <outSequence>
         <aggregate>
            <completeCondition>
               <messageCount min="-1" max="2"/>
            </completeCondition>
            <onComplete xmlns:add="http://ws.wso2.org/dataservice"
                        expression="//add:Addresses/add:Address">
               <send/>
            </onComplete>
         </aggregate>
      </outSequence>
   </target>
   <publishWSDL key="conf:/wsdls/Address.wsdl"/>
</proxy>

And the sequences used in the insequence: 和序列中使用的序列:

conf:/sequencesStackOverFlow/getmpartybranch CONF:/ sequencesStackOverFlow / getmpartybranch

<sequence xmlns="http://ws.apache.org/ns/synapse">
   <payloadFactory media-type="xml">
      <format>
         <dat:getmpartybranch xmlns:dat="http://ws.wso2.org/dataservice">            
            <dat:clientid>$1</dat:clientid>         
         </dat:getmpartybranch>
      </format>
      <args>
         <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('clientid')" evaluator="xml"></arg>
      </args>
   </payloadFactory>
   <send receive="conf:/sequencesStackOverFlow/iterOvermpartybranch">
      <endpoint>
         <address uri="http://127.0.0.1:5555/services/mpartybranch"></address>
      </endpoint>
   </send>
</sequence>

conf:/sequencesStackOverFlow/iterOvermpartybranch CONF:/ sequencesStackOverFlow / iterOvermpartybranch

<sequence xmlns="http://ws.apache.org/ns/synapse">
   <iterate xmlns:ns="http://org.apache.synapse/xsd" xmlns:ds="http://ws.wso2.org/dataservice" expression="//ds:DataCollection/ds:Datalist" id="iterate1" sequential="true">
      <target>
         <sequence>
            <property name="partybranchid" expression="//ds:partybranchid/text()" scope="default" type="STRING"></property>
            <property name="clientid" expression="//ds:clientid/text()" scope="default" type="STRING"></property>
            <log>
               <property name="PARTYID" expression="get-property('partybranchid')"></property>
               <property name="CLIENTID" expression="get-property('clientid')"></property>
            </log>
            <payloadFactory media-type="xml">
               <format>
                  <dat:getselect_addresses xmlns:dat="http://ws.wso2.org/dataservice">                     
                     <dat:objectid>$1</dat:objectid>                     
                     <dat:clientid>$2</dat:clientid>                  
                  </dat:getselect_addresses>
               </format>
               <args>
                  <arg expression="get-property('partybranchid')" evaluator="xml"></arg>
                  <arg expression="get-property('clientid')" evaluator="xml"></arg>
               </args>
            </payloadFactory>
            <log level="full"></log>
            <send>
               <endpoint>
                  <address uri="http://127.0.0.1:5555/services/getAddress" format="soap12"></address>
               </endpoint>
            </send>
         </sequence>
      </target>
   </iterate>
</sequence>

You need to use the aggregate mediator to collect the responses and create one unique message to return to the client. 您需要使用聚合介体来收集响应并创建一条唯一的消息以返回到客户端。 Check my outsequence. 检查我的结果。 In my case I just need to use the transformer mediator to change my payload according to the WSDL. 就我而言,我只需要使用转换器介体来根据WSDL更改我的有效负载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM