WSO2 ESB:显示dataService响应

时间:2015-03-03 19:34:16

标签: wso2 sequence wso2esb wso2carbon wso2dss

如何通过在序列上调用Web服务端点来显示返回的响应?

以下是我使用的序列。我想在wso2carbon.log上显示名为“CDServiceEndpoint”的dataservice的返回值。那可能吗?如果没有,我怎样才能显示数据。

<sequence xmlns="http://ws.apache.org/ns/synapse" name="ConcurGetADPExtractFlow" onError="GeneralErrorHandler">
   <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="current-context-details" expression="concat(get-property('current-context-details'), ', ConcurGetADPExtractFlow')" />
   <property name="scenario" value="ConcurGetADPExtractFlow" />
   <log level="custom">
      <property name="DEBUGGING" value="ConcurGetADPExtractFlow" />
      <property name="start-date" value="2015-02-23" />
      <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="End Date" expression="get-property('current-date')" />
   </log>
   <xslt key="Concur_Get_ADP_Extract_Transformation">
      <property name="start-date" value="2015-03-02" />
      <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="end-date" expression="get-property('current-date')" />
   </xslt>
   <property name="post-data-service-sequence" value="ConcurTransformADPExtractFlow" />
   <property name="OUT_ONLY" value="false" />
   <send receive="DataServiceInvocationErrorFlow">
      <endpoint key="ConcurDataServiceEndpoint" />
   </send>
   <description>Sends a request to the data service for the ADP extract data.</description>
</sequence>

下面是我的DataServiceInvocationErrorFlow的样子。

 <sequence xmlns="http://ws.apache.org/ns/synapse" name="DataServiceInvocationErrorFlow">
   <filter xmlns:ns="http://org.apache.synapse/xsd" xmlns:m="http://ws.wso2.org/dataservice" xmlns:ns3="http://org.apache.synapse/xsd" xpath="//m:DataServiceFault">
      <then>
         <log level="custom">
            <property name="status" value="data-service-fault" />
         </log>
         <property name="error_message" expression="//m:DataServiceFault" />
         <sequence key="GeneralErrorHandler" />
         <drop />
      </then>
      <else>
         <filter source="string-length(get-property('ERROR_MESSAGE'))" regex="0.0">
            <then>
               <filter xpath="//soapenv:Fault">
                  <then>
                     <log level="custom">
                        <property name="status" value="ERROR" />
                     </log>
                     <property name="error_message" expression="//soapenv:Fault" />
                     <sequence key="GeneralErrorHandler" />
                     <drop />
                  </then>
                  <else>
                     <log level="custom">
                        <property name="status" value="success response from DSS" />
                     </log>
                     <filter source="string-length(normalize-space(get-property('post-data-service-sequence')))" regex="0.0">
                        <then />
                        <else>
                           <property name="temp-post-data-service-sequence" expression="get-property('post-data-service-sequence')" />
                           <property name="post-data-service-sequence" value="" />
                           <sequence key="{get-property('temp-post-data-service-sequence')}" />
                        </else>
                     </filter>
                  </else>
               </filter>
            </then>
            <else>
               <property name="error_message" expression="get-property('ERROR_MESSAGE')" />
               <sequence key="GeneralErrorHandler" />
               <drop />
            </else>
         </filter>
      </else>
   </filter>
</sequence>

1 个答案:

答案 0 :(得分:0)

如果CDServiceEndpoint表示您ConcurDataServiceEndpoint,那么您已经在DataServiceInvocationErrorFlow调解员定义的Send序列中处理来自该终点的响应了这种方式容易混淆,因为无论您收到错误响应还是错误响应,都会运行receive序列。您需要做的就是使用Log mediator将其记录在DataServiceInvocationErrorFlow内。

如果您未在receive介体上定义Send序列,则响应将到达您的outSequence,您也可以使用Log mediator进行记录。