2013-08-02 84 views
1

我下面的培訓模塊04_02_HTTP_adapter_-_Communicating_with_HTTP_back- end_systems,在IBM工作燈入門網站獲得,並調用程序時,它給我一個錯誤:IBM工作燈6.0 - 獲取錯誤而調用適配器過程

{ 
    "errors": [ 
     "Runtime: Http request failed: java.net.UnknownHostException: rss.cnn.com" 
    ], 
    "info": [ 
    ], 
    "isSuccessful": false, 
    "warnings": [ 
    ] 
} 

適配器-impl。 JS

function getStories(interest) { 
    path = getPath(interest); 

var input = { 
    method : 'get', 
    returnedContentType : 'xml', 
    path : path 
      }; 


    return WL.Server.invokeHttp(input); 
       } 

     function getStoriesFiltered(interest) { 
    path = getPath(interest); 

    var input = { 
     method : 'get', 
     returnedContentType : 'xml', 
     path : path, 
     transformation : { 
     type : 'xslFile', 
     xslFile : 'filtered.xsl' 
     } 
    }; 

    return WL.Server.invokeHttp(input); 
     } 



     function getPath(interest) { 
     if (interest == undefined || interest == '') { 
    interest = ''; 
      }else { 
    interest = '_' + interest; 
     } 
      return 'rss/edition' + interest + '.rss'; 
        } 

XML文件

 <?xml version="1.0" encoding="UTF-8"?> 

    <wl:adapter name="RSSReader" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:wl="http://www.worklight.com/integration" 
xmlns:http="http://www.worklight.com/integration/http"> 

<displayName>RSSReader</displayName> 
<description>RSSReader</description> 
<connectivity> 
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> 
     <protocol>http</protocol> 
     <domain>rss.cnn.com</domain> 
     <port>80</port> 

    </connectionPolicy> 
    <loadConstraints maxConcurrentConnectionsPerNode="2" /> 
</connectivity> 

<procedure name="getStories"/> 

<procedure name="getStoriesFiltered"/> 

    </wl:adapter> 

一哈,最後我得到了我的答案。我在XML文件中做了一些代理設置,我的適配器開始工作。這是代理代碼,如果他們使用任何代理,則必須添加代碼。

<connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> 
<protocol>http</protocol> 
<domain>rss.cnn.com</domain> 
<port>80</port> 
<proxy> 
<protocol>http</protocol> 
<domain>proxy.My_company_name.com</domain> ----use proxy URL here 
<port>8080</port> 
<authentication> 
<basic/> 
<serverIdentity> 
<username>user</username> --------user is username 
<password>password</password> ------------Proxy Password 
</serverIdentity> 
</authentication> 
</proxy> 
</connectionPolicy> 
+0

編輯 –

+0

同樣的問題被要求有人與您的適配器-impl.js和XML的問題這裏 - https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777 -0000-0000-0000-000014835720 –

+0

好吧,這看起來像默認的HTTP適配器;你能在你的瀏覽器中訪問rss.cnn.com嗎?你如何嘗試調用適配器過程? –

回答

3

ahha,最後我得到了我的答案。我在XML文件中做了一些代理設置,我的適配器開始工作。這是代理代碼,如果他們使用任何代理,則必須添加代碼。

<connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> 
<protocol>http</protocol> 
<domain>rss.cnn.com</domain> 
<port>80</port> 
<proxy> 
<protocol>http</protocol> 
<domain>proxy.My_company_name.com</domain> ----use proxy URL here 
<port>8080</port> 
<authentication> 
<basic/> 
<serverIdentity> 
<username>user</username> --------user is username 
<password>password</password> ------------Proxy Password 
</serverIdentity> 
</authentication> 
</proxy> 
</connectionPolicy>