0
votes

I have created an adapter with this method:

function getLocation(gpsLat, gpsLong) {
path = "/maps/api/geocode/json?latlng=" + gpsLat + "," + gpsLong + "&sensor=false";
var input = {
method : 'get',
returnedContentType : 'json',
path : path
};
return WL.Server.invokeHttp(input);
}

the adapter configuration is this:

<displayName>GPSLocator</displayName>
    <description>GPSLocator</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>maps.googleapis.com</domain>
            <port>80</port> 
            <!-- Following properties used by adapter's key manager for choosing specific certificate from key store  
            <sslCertificateAlias></sslCertificateAlias> 
            <sslCertificatePassword></sslCertificatePassword>
            -->
            <proxy>
                <protocol>http</protocol>
                <domain>15.1.0.111</domain>
                <port>8080</port>
            </proxy>
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>

    <procedure name="getLocation" />

when i right-click and run Invoke WL Adapter i get this error:

{
   "errors": [
      "Runtime: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http:\/\/maps.googleapis.com:80 refused"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}

if i run a request in google maps from my browser, for example: https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false

then i get correct response. So the problem is by calling it from WL.

I am using worklight studio 6.1 Also i can access my console normally and see deployed apps, so my server is up and running properly.

Any suggestions?

1

1 Answers

6
votes

I believe it has to do with the proxy you are running through with the following settings:

<proxy> <protocol>http</protocol> <domain>15.1.0.111</domain> <port>8080</port> </proxy>

I was able to run the above adapter successfully without that proxy in place. You may want to look into your proxy configuration. Also you have the request going through http inside your adapter but have it going through https in your example address here:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false