2012-01-10 9 views
4

にフィルタリングもの:
承認するとOK結果を与えるか、または失敗(第一サービス)
2.ん 1.コールサービス結果[サービス私は1つのプロキシを構築したいWSO2

を「OK」を呼び出す場合

<?xml version='1.0' encoding='utf-8'?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
     <soapenv:Body> 
       <result> 
        <status>OK</status> 
        <message></message> 
       </result> 
     </soapenv:Body> 
</soapenv:Envelope> 

そして、私はアウトのシーケンスで「フィルタリング」を与える:第一サービスがメッセージをお返しする際の問題は、あります。私は自分のアプリケーションを実行すると

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true"> 
    <target endpoint="AuthorizationService"> 
     <outSequence> 
     <log level="full" /> 
     <filter xpath="/result/status='OK'"> 
      <then> 
       <send> 
        <endpoint> 
        <address uri="http://192.168.1.140:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask" /> 
        </endpoint> 
       </send> 
      </then> 
      <else> 
       <makefault version="soap11"> 
        <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch" /> 
        <reason value="1" /> 
        <role>2</role> 
        <detail>3</detail> 
       </makefault> 
      </else> 
     </filter> 
     <log level="full" /> 
     </outSequence> 
    </target> 
</proxy> 

は、ESBは常にメッセージを与える:

16:08:59,358 [-] [HttpClientWorker-4] INFO Start : Log mediator 
16:08:59,361 [-] [HttpClientWorker-4] INFO To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:0bc33821-c4f1-448e-a7dc-be4194be8e99, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><result><status>OK</status><message></message></result></soapenv:Body></soapenv:Envelope> 
16:08:59,361 [-] [HttpClientWorker-4] INFO End : Log mediator 
16:08:59,361 [-] [HttpClientWorker-4] INFO Start : Filter mediator 
16:08:59,361 [-] [HttpClientWorker-4] INFO XPath expression : /result/status='OK' evaluates to false - executing the else path child mediators 

は、フィルタリングの条件のように思える常にfalseです。ここXMLです。
フィルタ内のXPathの正しい文は何ですか?

答えて

0

間違ったxpath式を指定した可能性があります。 xpath値とboolean式の両方をxpath値として与えることはできません。つまり、 "/ result/status = 'OK'"にすることはできませんが、 "/ result/status"にする必要があります。次に、あなたのシーケンスに従って、この要素が存在するならば、その後のセクションを起動します。 、あなたにもXPathのに基づいてブール条件を評価する必要があるので、私は(同じフィルタのために行うことができますプロパティを設定することにより)スイッチメディエーターに基づいて選択肢を提示します:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true"> 
    <target endpoint="AuthorizationService"> 
     <outSequence> 
     <log level="full" /> 
     <switch source="//result/status"> 
      <case regex="OK"> 
       <send> 
        <endpoint> 
        <address uri="http://192.168.1.140:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask" /> 
        </endpoint> 
       </send> 
      </case> 
      <default> 
       <makefault version="soap11"> 
        <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch" /> 
        <reason value="1" /> 
        <role>2</role> 
        <detail>3</detail> 
       </makefault> 
      </default> 
     </switch> 
     <log level="full" /> 
     </outSequence> 
    </target> 
</proxy> 
2

あなたのプロキシを設定は次のようになります。

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http"  statistics="disable" trace="enable" startOnLoad="true"> 
    <target endpoint="AuthorizationService"> 
     <outSequence> 
     <log level="full"/> 
     <filter source="/result/status" regex="ok"> 
      <then> 
       <send> 
        <endpoint> 
        <address uri="http://192.168.1.140:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask"/> 
        </endpoint> 
       </send> 
      </then> 
      <else> 
       <makefault version="soap11"> 
        <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/> 
        <reason value="1"/> 
        <role>2</role> 
        <detail>3</detail> 
       </makefault> 
       <send/> 
      </else> 
     </filter> 
     </outSequence> 
    </target> 
    <description></description> 
</proxy> 
関連する問題