- 更新 - 我最初发布与火狐错误,铬错误信息是比较有用的,所以我已经更新了它的名字
(火狐) - “在”在worklight.js类型错误:不能使用“在”运营商在空搜索“SUPPORT_WL_SERVER_CHANGE”
操作轮廓无效(铬) - 类型错误:“在”运营商不能使用搜索“SUPPORT_WL_SERVER_CHANGE”在空
我已经看到了类似的问题这个,没有人回答,也没有提供所有代码都需要重现结果。
我用firefox和chrome获得不同的信息。所以我更新了标题以显示两者。
重现:
创建一个新的工作灯项目,在该项目 创建一个新的HTTP适配器的应用程序,调用它myRESTAdapter
与替换的index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>angular_test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=0.5, minimum-scale=2.0, user-scalable=0">
<script>window.$ = window.jQuery = WLJQ;</script>
<script>
function mobGmapLatLng(pAddress) {
var invocationData = {
adapter : 'myRESTAdapter',
procedure : 'getGmapLatLng',
parameters : [ pAddress ]
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : function(result){
console.debug("good");
var httpStatusCode = result.status;
if (200 == httpStatusCode) {
var invocationResult = result.invocationResult;
var isSuccessful = invocationResult.isSuccessful;
if (true == isSuccessful) {
var lat = invocationResult.lat;
var lng = invocationResult.lng;
alert("Success: lat=" + lat + " lng=" + lng);
}
else {
alert("Error. isSuccessful=" + isSuccessful);
}
}
else {
alert("Error. httpStatusCode=" + httpStatusCode);
}
},
onFailure : function(result){
console.debug("bad");
}
});
}
</script>
</head>
<body>
Hello Worklight with getGmapLatLng
<p>
<button onclick="mobGmapLatLng('11501 Burnet Rd, Austin, TX, USA')">Austin, TX, USA</button>
</p>
<p>
<button onclick="mobGmapLatLng('4250 South Miami Boulevard, Durham, NC, USA')">Durham, NC, USA</button>
</p>
<p>
<button onclick="mobGmapLatLng('1681 Route des Dolines, 06560 Valbonne, France')">Valbonne, France</button>
</p>
<p>
<button onclick="mobGmapLatLng('Shefayim 60990, Israel')">Shefayim, Israel</button>
</p>
<p>
<button onclick="mobGmapLatLng('399 Ke Yuan Lu, Shanghai, China')">Shanghai, China</button>
</p>
</body>
</html>
下一个在您的适配器中用以下代码替换myRESTAdapter.xml:
<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="myRESTAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>myRESTAdapter</displayName>
<description>myRESTAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>http://maps.googleapis.com</domain>
<port>80</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
</connectivity>
<procedure name="getGmapLatLng"/>
</wl:adapter>
并更换myRESTAdapater-impl.js有:
function getGmapLatLng(pAddress) {
var input = {
method : 'get',
returnedContentType : 'json',
path : 'maps/api/geocode/json',
parameters : {
'address' : 'plaza 3 one nationwide blvd columbus oh',
'sensor' : 'false' // hard-coded
}
};
var response = WL.Server.invokeHttp(input);
// Extract latitude and longitude from the response.
var type = typeof response;
if ("object" == type) {
if (true == response["isSuccessful"]) {
// Drill down into the response object.
var results = response["results"];
var result = results[0];
var geometry = result["geometry"];
var location = geometry["location"];
// Return JSON object with lat and lng.
return location;
}
else {
// Returning null. Web request was not successful.
return null;
}
}
else {
// Returning null. Response is not an object.
return null;
}
}
右键单击index.html,然后选择Run AS->预览 打开Firebug这样你就可以看到错误消息:无效的“在”操作数的个人资料工作灯。 JS 点击按钮中的一个,你会在Firebug看到错误消息
***注:我不得不做出一些更改,以便这将包括公司防火墙后面工作,我想这应该粘贴并运行,但我目前无法对其进行测试。
**注2:我几乎可以肯定我成功之前,有这个确切的代码运行,我想不通为什么感觉有时我得到的错误,有时它的工作原理
与工作灯测试6.3.0 适配器代码功能是否正确,并返回时我把它与运行原样>调用mobilefirst过程
行号正确的数据:5059在worklight.js
错误是否给你一个行号? – 2015-02-06 17:02:30
是的,还会添加您遇到的错误以及提及您正在使用的Worklight版本。 – 2015-02-06 17:19:26
使用MFP 6.3并在Chrome中预览应用程序我不会收到此错误。 – 2015-02-06 17:47:54