WSO2 ESB“发送”中介不发送到出局代理序列

时间:2015-01-12 12:20:54

标签: wso2 wso2esb wso2carbon synapse

我在WSO2 Esb代理服务中创建的2个序列有轻微问题。

这是我的配置:

我的代理(Pepkor_Product_Search_Proxy)需要在Web服务和数据服务中搜索产品信息并恢复响应(如果需要,可以汇总)。

我的代理服务调用2个服务;托管在DSS上的数据服务和托管在AS上的Web服务。代理请求被发送到2"请求序列"格式化请求以匹配AS和DSS上相应服务调用的预期消息。收到回复后,我将它们发送到2"响应序列"为了根据(与WSDL一致)格式化它们到代理服务响应。但是,一旦到达这些序列中的发送调解器,执行就会停止,并且代理的Out Sequence不会接收它们。

发送调解器正在使用默认行为(应该发送到代理序列),例如:

所有4个序列(2个Rq + 2Rs)都是动态的并保存在system_ / conf:registry

我只用一个服务接收肥皂中的消息(似乎rs序列正在响应,而不是代理的out seq!)

我想知道如何才能获得这些"调解"响应回到我的代理序列...

我尝试过序列介体而不是克隆,但无济于事。

请参阅以下内容:Rq mssg,代理和"响应"序列突触配置以及代理碳日志。

提前致谢,您需要告诉我任何其他信息。

SOAP Rq:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:prod="http://za.co.pepkor/product_service/">
   <soapenv:Header/>
   <soapenv:Body>
      <prod:productSearchReq>
         <!--Optional:-->
         <productName>NIKE_SHIRTS</productName>
         <!--Optional:-->
         <productSize>7</productSize>
         <!--Optional:-->
         <productColour>RED</productColour>
      </prod:productSearchReq>
   </soapenv:Body>
</soapenv:Envelope>

代理:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Pepkor_Product_Search_Proxy"
    transports="https http" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <log level="custom">
                <property name="Sending request to :"
                    value="ackServiceSearchSeqRq and shcServiceSearchSeqRq sequences..." />
            </log>
            <clone sequential="true">
                <target sequence="conf:/ackServiceSearchSeqRq" />
                <target sequence="conf:/shcServiceSearchSeqRq" />
            </clone>
        </inSequence>
        <outSequence>
            <log level="custom">
                <property name="Out Sequence reached"
                    value="++++++++++++++=========Aggregating now========+++++++++++++++++==" />
            </log>
            <aggregate>
                <completeCondition>
                    <messageCount min="-1" max="-1" />
                </completeCondition>
                <onComplete expression="//productDetails">
                    <log level="custom" separator=",">
                        <property name="::::"
                            value="======================= Sending Back the Aggregated Responses. ===============" />
                    </log>
                </onComplete>
            </aggregate>
            <respond />
        </outSequence>
        <faultSequence />
    </target>
    <publishWSDL key="gov:service_integration/wsdls/PepKorProductSearch.wsdl" />
</proxy>

Ack服务Rs序列

    <?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="ackServiceSearchSeqRs">
    <log level="custom">
        <property name="Below Response recieved from Ack-WS" value="==================" />
    </log>
    <log level="full" />
    <property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ax23="http://ack.pepkor.org/xsd" name="product_Colour"
        expression="//ns1:productSearchResponse/ns1:return/ax23:product_Colour/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Colour : "
            expression="$ctx:product_Colour" />
    </log>
    <property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ax23="http://ack.pepkor.org/xsd" name="product_ID"
        expression="//ns1:productSearchResponse/ns1:return/ax23:product_ID/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:ID : "
            expression="$ctx:product_ID" />
    </log>
    <property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ax23="http://ack.pepkor.org/xsd" name="product_Name"
        expression="//ns1:productSearchResponse/ns1:return/ax23:product_Name/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Name : "
            expression="$ctx:product_Name" />
    </log>
    <property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ax23="http://ack.pepkor.org/xsd" name="product_Size"
        expression="//ns1:productSearchResponse/ns1:return/ax23:product_Size/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Size : "
            expression="$ctx:product_Size" />
    </log>
    <property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ax23="http://ack.pepkor.org/xsd" name="source"
        expression="//ns1:productSearchResponse/ns1:return/ax23:source/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Source : "
            expression="$ctx:source" />
    </log>
    <property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ax23="http://ack.pepkor.org/xsd" name="type"
        expression="//ns1:productSearchResponse/ns1:return/ax23:type/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Type : "
            expression="$ctx:type" />
    </log>
    <payloadFactory media-type="xml">
        <format>
            <productDetails xmlns:pep="http://za.co.pepkor/product_service/">
                <productID>$1</productID>
                <productName>$2</productName>
                <productSize>$3</productSize>
                <productColour>$4</productColour>
                <productType>$5</productType>
                <sourceID>$6</sourceID>
            </productDetails>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:product_ID" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:product_Name" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:product_Size" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:product_Colour" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:type" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:source" />
        </args>
    </payloadFactory>
    <send />
    </sequence>

Shc服务Rs序列

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="shcServiceSearchSeqRs">
    <log level="custom">
        <property name="Below response recieved from Shc-DS" value="==================" />
    </log>
    <log level="full" />
    <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
        name="Product_ID" expression="//ns1:productDetails/ns1:Product_ID/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_ID : "
            expression="$ctx:Product_ID" />
    </log>
    <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
        name="Product_Name" expression="//ns1:productDetails/ns1:Product_Name/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Name : "
            expression="$ctx:Product_Name" />
    </log>
    <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
        name="Product_Size" expression="//ns1:productDetails/ns1:Product_Size/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Size : "
            expression="$ctx:Product_Size" />
    </log>
    <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
        name="Product_Colour" expression="//ns1:productDetails/ns1:Product_Colour/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Colour : "
            expression="$ctx:Product_Colour" />
    </log>
    <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
        name="Product_Type" expression="//ns1:productDetails/ns1:Product_Type/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Type : "
            expression="$ctx:Product_Type" />
    </log>
    <property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
        name="Source" expression="//ns1:productDetails/ns1:Source/text()"
        scope="default" type="STRING" />
    <log level="custom">
        <property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Source : "
            expression="$ctx:Source" />
    </log>
    <payloadFactory media-type="xml">
        <format>
            <productDetails xmlns="">
                <productID>$1</productID>
                <productName>$2</productName>
                <productSize>$3</productSize>
                <productColour>$4</productColour>
                <productType>$5</productType>
                <sourceID>$6</sourceID>
            </productDetails>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:Product_ID" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:Product_Name" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:Product_Size" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:Product_Colour" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:Product_Type" />
            <arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
                expression="$ctx:Source" />
        </args>
    </payloadFactory>
    <send />
</sequence>

SOAP Rs

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <productDetails>
         <productID>214562</productID>
         <productName>NIKE_SHIRTS</productName>
         <productSize>7</productSize>
         <productColour>RED</productColour>
         <productType>SHIRT</productType>
         <sourceID>SHC</sourceID>
      </productDetails>
   </soapenv:Body>
</soapenv:Envelope>

WSO2碳日志

https:// docs。谷歌。 COM /文件/ d / 12At0zir99H9cOo9hzNrgG33r52PHF0W32XLyBT6dzUQ /编辑? USP =共享


修改

我的AggHandlerSequence:

<sequence xmlns="http://ws.apache.org/ns/synapse">
   <log level="custom">
      <property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="></property>
   </log>
   <aggregate>
      <completeCondition>
         <messageCount min="-1" max="-1"></messageCount>
      </completeCondition>
      <onComplete xmlns:ns="http://org.apache.synapse/xsd" xmlns:prod="http://za.co.pepkor/product_service/" expression="//prod:productSearchResp/productDetails">
         <log level="custom" separator=",">
            <property name="::::" value="======================= Sending Back the Aggregated Responses. ==============="></property>
         </log>
         <respond></respond>
      </onComplete>
   </aggregate>
</sequence>

我的一个Rs Seq

<sequence xmlns="http://ws.apache.org/ns/synapse">
       :
       :
   <payloadFactory media-type="xml">
      <format>
         <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:prod="http://za.co.pepkor/product_service/">            
             <soapenv:Body>               
               <prod:productSearchResp>                  
                  <productDetails xmlns="">                     
                     <productID>$1</productID>                     
                     <productName>$2</productName>                     
                     <productSize>$3</productSize>                     
                     <productColour>$4</productColour>                     
                     <productType>$5</productType>                     
                     <sourceID>$6</sourceID>                  
                  </productDetails>               
               </prod:productSearchResp>            
            </soapenv:Body>         
         </soapenv:Envelope>
     : 
     :
   <sequence key="conf:/pocSearchRsHandlerSeq"></sequence>
     :
     :

但是我在肥皂中得到这个Rs

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <productDetails>
         <productID>2145627</productID>
         <productName>NIKE_SHIRTS</productName>
         <productSize>7</productSize>
         <productColour>RED</productColour>
         <productType>SHIRT</productType>
         <sourceID>ACK</sourceID>
      </productDetails>
      <productDetails>
         <productID>214562</productID>
         <productName>NIKE_SHIRTS</productName>
         <productSize>7</productSize>
         <productColour>RED</productColour>
         <productType>SHIRT</productType>
         <sourceID>SHC</sourceID>
      </productDetails>
   </soapenv:Body>
</soapenv:Envelope>

我想要一个类似于Rs seq中的Payload工厂的响应,尝试过使用corrolateOn表达式。我可以将这些聚合字段存储为属性并在有效负载工厂中使用它们,或者如何将Agg响应映射到?

最终修改

这里有一个完美的Rs seq有效载荷:(这将由agg处理程序收到)

         <productDetails xmlns="">            
            <productID>$1</productID>            
            <productName>$2</productName>            
            <productSize>$3</productSize>            
            <productColour>$4</productColour>            
            <productType>$5</productType>            
            <sourceID>$6</sourceID>         
         </productDetails>

我的完整agg处理程序:

<sequence xmlns="http://ws.apache.org/ns/synapse">
   <log level="custom">
      <property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="></property>
   </log>
   <aggregate>
      <completeCondition>
         <messageCount min="-1" max="-1"></messageCount>
      </completeCondition>
      <onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
         <log level="custom" separator=",">
            <property name="::::" value="======================= Formatting the Aggregated Responses. ==============="></property>
         </log>
         <log level="full"></log>
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">                  
                  <soapenv:Body>                     
                     <prod:productSearchResp>                                                                                                                   $1                                                                                                </prod:productSearchResp>                  
                  </soapenv:Body>               
               </soapenv:Envelope>
            </format>
            <args>
               <arg expression="//productDetails" evaluator="xml"></arg>
            </args>
         </payloadFactory>
         <respond></respond>
      </onComplete>
   </aggregate>
</sequence>

2 个答案:

答案 0 :(得分:1)

如果要使用聚合介体,则2个响应必须与使用此介体的顺序相同

在您的代理inSequence中,您使用clone并调用&#34; ackServiceSearchSeqRq&#34;和&#34; shcServiceSearchSeqRq&#34;就像你已经做的那样

在每个请求seq中,您根据要调用的服务格式化请求,然后从以下方式之一使用send mediator:

  • 第一个选项:<send> <endpoint key="xxx"> </send>:来自您的2项服务的2条回复将转到您的代理商的outSequence
  • 第二个选项:<send receive="MyAggregateSequence"> <endpoint key="xxx"> </send>:来自您的2个服务的2个回复将转到&#34; MyAggregateSequence&#34;

在您的代理的outSequence或&#34; MyAggregateSequence&#34;中,根据您选择的选项,您使用过滤器或开关介体来确定它是来自ackService还是来自shcService的响应并决定要应用哪个转换(注意使用payloadFactory创建的productDetails节点,如果没有命名空间,则在调用聚合调解器之前指定xmlns =&#34;&#34;每次:样本中不是这种情况)。在aggregate / onComplete中,您可以使用没有端点的send mediator将聚合的消息发送回代理的呼叫者。

在你的情况下,有2 <send/>,你的每个2 Rs序列中有一个:第一个被发送到代理的呼叫者而第二个没有做任何事情(ESB必须说明你试着回应2次)。

答案 1 :(得分:1)

使用克隆介体并且您想要收集两条消息的响应时,必须在克隆介体上设置id并在聚合器介体中使用相同的id

< clone id="XXX">

< aggregate id="XXX">

这样聚合器就知道它需要等待哪些调用。