2016-04-28 56 views
1

我有一個代理服務,需要使用ws安全性調用exernal服務。我要 調用服務,並根據響應,我需要提取一些信息 然後調用數據服務來更新數據庫。當我得到響應,並創建有效負載來調用數據服務時,它也具有ws安全標頭,最終出現異常。WSO2 ESB無法在DSS調用前刪除響應中的ws-security標頭

我用

<header action="remove" name="wsse:Security" scope="default" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" />

同時創建和調用數據服務,但沒有運氣結束了。

以下是我的代理服務。

<?xml version="1.0" encoding="UTF-8"?> 
<proxy name="EDI_Test_Proxy_2" startOnLoad="true" trace="disable" 
    transports="http https" xmlns="http://ws.apache.org/ns/synapse"> 
    <target> 
     <inSequence> 
      <header name="Action" scope="default" value="get_mcash_data" /> 
      <property name="Content-Type" scope="transport" type="STRING" 
       value="application/soap+xml; charset=UTF-8; action=get_mcash_data" /> 
      <call> 
       <endpoint> 
        <address trace="disable" 
         uri="http://localhost:9770/services/my_fetch_data_service" /> 
       </endpoint> 
      </call> 
      <property expression="//mc:mcash/mc:tran_id/text()" name="tran_id" 
       scope="default" type="STRING" xmlns:mc="http://ws.wso2.org/dataservice" 
       xmlns:ns="http://org.apache.synapse/xsd" /> 
      <log level="custom"> 
       <property expression="$ctx:tran_id" name="tran_id" /> 
      </log> 
      <filter xmlns:mc="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" 
       xpath="boolean(//mc:mcash/mc:mobile_no)"> 
       <then> 
        <property expression="//mc:mcash/mc:tran_id/text()" name="tran_id" 
         scope="default" type="STRING" /> 
        <property expression="//mc:mcash/mc:mobile_no/text()" 
         name="mobile_no" scope="default" type="STRING" /> 
        <property expression="//mc:mcash/mc:tran_amt/text()" name="tran_amt" 
         scope="default" type="STRING" /> 
        <property expression="//mc:mcash/mc:tran_date/text()" 
         name="tran_date" scope="default" type="STRING" /> 
        <property expression="//mc:mcash/mc:tran_time/text()" 
         name="tran_time" scope="default" type="STRING" /> 
        <property expression="//mc:mcash/mc:part_tran_srl_num/text()" 
         name="part_tran_srl_num" scope="default" type="STRING" /> 
        <log level="custom"> 
         <property expression="$ctx:tran_id" name="tran_id" /> 
         <property expression="$ctx:mobile_no" name="mobile_no" /> 
         <property expression="$ctx:tran_amt" name="tran_amt" /> 
         <property expression="$ctx:tran_date" name="tran_date" /> 
         <property expression="$ctx:tran_time" name="tran_time" /> 
         <property expression="$ctx:part_tran_srl_num" name="tran_time" /> 
        </log> 
        <payloadFactory description="pf_mcash" media-type="xml"> 
         <format> 
          <flw:purchaceFromMMR xmlns:flw="http://flw.mwt.mobitel.com/"> 
           <!--Optional: --> 
           <bankPurchaseRequest xmlns=""> 
            <amount>$1</amount> 
            <!--Optional: --> 
            <bankCode>XXX</bankCode> 
            <!--Optional: --> 
            <date>$2</date> 
            <!--Optional: --> 
            <mobile>$3</mobile> 
            <!--Optional: --> 
            <time>$4</time> 
            <!--Optional: --> 
            <transactionId>$5</transactionId> 
           </bankPurchaseRequest> 
          </flw:purchaceFromMMR> 
         </format> 
         <args> 
          <arg evaluator="xml" expression="$ctx:tran_amt" /> 
          <arg evaluator="xml" expression="$ctx:tran_date" /> 
          <arg evaluator="xml" expression="$ctx:mobile_no" /> 
          <arg evaluator="xml" expression="$ctx:tran_time" /> 
          <arg evaluator="xml" expression="$ctx:tran_id" /> 
         </args> 
        </payloadFactory> 
        <call> 
         <endpoint> 
          <address trace="disable" 
           uri="https://my_external_web_service/to_be/called?wsdl"> 
           <enableSec policy="gov:ws-policy/sample_policy.xml" /> 
          </address> 
         </endpoint> 
        </call> 
        <loopback /> 
       </then> 
       <else> 
        <log> 
         <property name="STATUS" value="*****No data available*****" /> 
        </log> 
       </else> 
      </filter> 
     </inSequence> 
     <outSequence> 
      <header action="remove" name="wsse:Security" scope="default" 
       xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" /> 
      <header action="remove" name="To" scope="default" /> 
      <property expression="//return/mobile/text()" name="mobile" 
       scope="default" type="STRING" /> 
      <property expression="//return/date/text()" name="date" 
       scope="default" type="STRING" /> 
      <property expression="//return/recipetNo/text()" name="recipetNo" 
       scope="default" type="STRING" /> 
      <property expression="//return/resultCode/text()" name="resultCode" 
       scope="default" type="STRING" /> 
      <property expression="//return/resultDesc/text()" name="resultDesc" 
       scope="default" type="STRING" /> 
      <payloadFactory description="pf_mcash_update" 
       media-type="xml"> 
       <format> 
        <p:TestUpdate xmlns:p="http://ws.wso2.org/dataservice"> 
         <!--Exactly 1 occurrence --> 
         <p:trf_status>$1</p:trf_status> 
         <!--Exactly 1 occurrence --> 
         <p:resp_code>$2</p:resp_code> 
         <!--Exactly 1 occurrence --> 
         <p:receipt>$3</p:receipt> 
         <!--Exactly 1 occurrence --> 
         <p:rsp_message>$4</p:rsp_message> 
         <!--Exactly 1 occurrence --> 
         <p:tran_id>$5</p:tran_id> 
         <!--Exactly 1 occurrence --> 
         <p:part_tran_srl_num>$6</p:part_tran_srl_num> 
        </p:TestUpdate> 
       </format> 
       <args> 
        <arg value="10" /> 
        <arg evaluator="xml" expression="$ctx:resultCode" /> 
        <arg evaluator="xml" expression="$ctx:recipetNo" /> 
        <arg evaluator="xml" expression="$ctx:resultDesc" /> 
        <arg value="SDC311521" /> 
        <arg evaluator="xml" expression="$ctx:part_tran_srl_num" /> 
       </args> 
      </payloadFactory> 
      <header name="Action" scope="default" value="TestUpdate" /> 
      <property name="Content-Type" scope="transport" type="STRING" 
       value="application/soap+xml; charset=UTF-8; action=TestUpdate" /> 
      <call> 
       <endpoint> 
        <address trace="disable" 
         uri="http://my_internal_data_service/which_ends_up_with/ws_sec_header" /> 
       </endpoint> 
      </call> 
     </outSequence> 
     <faultSequence /> 
    </target> 
</proxy> 

任何意見是非常感謝。

回答

1

您可以在調用過程中的調用調解器之前添加以下日誌調解器,並使用輸出日誌對其進行更新。它將幫助我們確定問題。

<log level="full"> 
      <property name="OutSequence" value="==== OUTSEQ ===="/> 
    </log> 
+0

感謝您的評論,我將盡快更新請求,同時爲了澄清我在' repository/conf/axis2/axis2.xml'中使用了' ================================================ - > <! - Global Engaged Modules - > <! - ================================= ================ - > <! - 註釋掉禁用尋址 - > '這是正確的嗎?這是否像全球參與所有服務都涉及到城牆? – Yasothar

1

的問題是我已經在<ESB_HOME>repository/conf/axis2/發現axis2.xml從事壁壘模塊<module ref="rampart" />。在註釋掉這一行後,異常消失,dss調用工作。我相信的原因是,如果啓用了這一行代碼,ws-securiy全局參與,所有服務調用將查找ws-security頭。無論如何,如果我錯了,請糾正我。