我用这种方法创建了一个适配器:
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); }
适配器配置是这样的:
GPSLocator GPSLocator http maps.googleapis.com 80 http 15.1.0.111 8080
当我右键单击并运行Invoke WL Adapter时,我收到此错误:
{ "errors": [ "Runtime: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http:\/\/maps.googleapis.com:80 refused" ], "info": [ ], "isSuccessful": false, "warnings": [ ] }
如果我在浏览器中使用谷歌地图运行请求,例如:https: //maps.googleapis.com/maps/api/geocode/json ?latlng = 40.714224,-73.961452&theseor = false
然后我得到正确的答复.所以问题是从WL调用它.
我正在使用worklight studio 6.1此外,我可以正常访问我的控制台并查看已部署的应用程序,因此我的服务器已启动并正常运行.
有什么建议?
我相信它与您使用以下设置运行的代理有关:
<proxy>
<protocol>http</protocol>
<domain>15.1.0.111</domain>
<port>8080</port>
</proxy>
我能够在没有代理的情况下成功运行上述适配器.您可能需要查看代理配置.您也可以通过适配器中的http进行请求,但请在示例地址中通过https:
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false