Question

I am following training module 04_02_HTTP_adapter_-_Communicating_with_HTTP_back- end_systems, available on IBM Worklight Getting Started website, and when invoking a procedure it gives me an error:

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

Adapter -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 file

        <?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>

ahha, finally I got my answer. I did some proxy settings in the XML file and my adapter started working. Here is the Proxy code that one must add if they are using any Proxy.

 <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>
Was it helpful?

Solution

ahha, finally I got my answer. I did some proxy settings in the XML file and my adapter started working. Here is the Proxy code that one must add if they are using any Proxy.

 <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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top