2017-07-30 66 views
0

我剛開始關注WSO2企業集成商。 我現在堅持當我試圖創建一個調用需要身份驗證的後端服務的API。WSO2企業集成商,向後端請求添加頭文件

我目前卡住試圖添加一個簡單的頭,它應該發送到後端,因爲它需要身份驗證來訪問它。

我正在使用他們的eclipse工具,我的XML目前看起來像這樣。

<?xml version="1.0" encoding="UTF-8"?> 
    <api context="/one" name="singleRestApi" xmlns="http://ws.apache.org/ns/synapse"> 
    <resource methods="GET"> 
     <inSequence> 
     <header name="Authorization" scope="transport" value="Basic ZWNYGWRtaH42Q2xvdGRBZG1pbjmeMw=="/> 
     <send> 
      <endpoint key="repos"/> 
     </send> 
     </inSequence> 
     <outSequence> 
      <send/> 
     </outSequence> 
     <faultSequence/> 
    </resource> 
</api> 

目前在積分教程:here

任何幫助或方向將不勝感激。

+0

您使用此API面臨什麼問題?您可以使用標頭介體或定義「授權」標頭屬性,如http://nuwanwimalasekara.blogspot.com/2014/03/how-to-add-http-basic-authentication.html中所述 –

回答

0

你應該儘量把你的授權的屬性,而不是一個標頭(如果你想要做一個簡單的基本身份驗證)

<?xml version="1.0" encoding="UTF-8"?> 
 
    <api context="/one" name="singleRestApi" xmlns="http://ws.apache.org/ns/synapse"> 
 
    <resource methods="GET"> 
 
     <inSequence> 
 
     <property action="remove" name="REST_URL_POSTFIX" scope="axis2"/> 
 
     <property name="Authorization" scope="transport" value="Basic ZWNYGWRtaH42Q2xvdGRBZG1pbjmeMw=="/> 
 
     <send> 
 
      <endpoint key="repos"/> 
 
     </send> 
 
     </inSequence> 
 
     <outSequence> 
 
      <send/> 
 
     </outSequence> 
 
     <faultSequence/> 
 
    </resource> 
 
</api>

<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/> 部分去除api上下文(在/ one之後)發送到您的後端端點時,如果您需要保留它,您可以刪除此線路