mik*_*_x_ 0 worklight-adapters ibm-mobilefirst
我用这种方法创建了一个适配器:
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);
}
Run Code Online (Sandbox Code Playgroud)
适配器配置是这样的:
<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" />
Run Code Online (Sandbox Code Playgroud)
当我右键单击并运行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": [
]
}
Run Code Online (Sandbox Code Playgroud)
如果我在浏览器中使用谷歌地图运行请求,例如: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
| 归档时间: |
|
| 查看次数: |
668 次 |
| 最近记录: |