2015-04-16 48 views
0

我想創建一個http適配器來使用SOAP獲取我的用戶信息,我不知道如何設置我的基本授權,如我使用soapUI工具設置。IBM MobileFirst - 如何在HTTP適配器中使用SOAP設置基本授權?

不添加基本授權(用戶名+密碼),我無法訪問此Web服務。我如何繼續?

SoapAdapter.xml

<displayName>SoapAdapter</displayName> 
<description>SoapAdapter</description> 
<connectivity> 
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> 
     <protocol>https</protocol> 
     <domain>www-304.ibm.com</domain> 
     <port>443</port>  
     <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds> 
     <socketTimeoutInMilliseconds>300000</socketTimeoutInMilliseconds> 
     <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode> 
     <!-- Following properties used by adapter's key manager for choosing specific certificate from key store 
     <sslCertificateAlias></sslCertificateAlias> 
     <sslCertificatePassword></sslCertificatePassword> 
     -->  
    </connectionPolicy> 
</connectivity> 

SoapAdapter-impl.js

function getUserPro() { 

    var request = 
     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://www.ibm.com/tools/wse/ws/"> 
      <soapenv:Header/> 
      <soapenv:Body> 
       <ws:ws_getUserCustomerOperation> 
        <ws:RequestedUserDetails> 
         <userid>my-email-address</userid> 
         <group>Customer</group> 
        </ws:RequestedUserDetails> 
       </ws:ws_getUserCustomerOperation> 
      </soapenv:Body> 
     </soapenv:Envelope>; 

    var input = { 
      method : 'post', 
      returnedContentType : 'xml', 
      headers:{'Content-Type':'text/xml','Authorization':'Basic ' + ('my-email-address:*******')},   
      path : '/easytools/runtime/uat/protect/***/Customer/webservices/ws_addProductToCartCustomer.wss?', 
      body: { 
       content : request.toString(), 
       contentType : 'text/xml; charset=utf-8' 
      } 
     }; 

    return WL.Server.invokeHttp(input); 
} 

回答

1

你不說你正在使用的MobileFirst平臺的版本,所以我會承擔7.0。

假設你的意思是HTTP基本身份驗證,它看起來像你這樣做,和值是後端服務的每次調用相同,通常要修改適配器的.xml文件<authentication>元素,像這樣:

<authentication> 
    <basic/> 
    <serverIdentity> 
    <username>${user}</username> 
    <password>${password}</password> 
    </serverIdentity> 
</authentication> 

請參閱知識中心的here以獲取更多信息。

不要忘記確保適配器本身已充分固定。否則,您有可能以不安全的方式暴露什麼是擔保服務。

此外,我假設您的後端服務通過HTTPS連接,以確保憑據受到保護。