Java 从senchatouch调用webservice restful时出错
我花了几天时间试图解决这个问题,但没有办法 我想从我用senchatouch 2.0创建的web应用程序中向我用java创建的restful web服务发出请求。我研究了它,以跨域发出请求唯一的选择是使用“Ext.data.JsonP.request”。我举了这个代码示例:Java 从senchatouch调用webservice restful时出错,java,javascript,rest,extjs,sencha-touch-2,Java,Javascript,Rest,Extjs,Sencha Touch 2,我花了几天时间试图解决这个问题,但没有办法 我想从我用senchatouch 2.0创建的web应用程序中向我用java创建的restful web服务发出请求。我研究了它,以跨域发出请求唯一的选择是使用“Ext.data.JsonP.request”。我举了这个代码示例: Ext.data.JsonP.request({ url: 'http://free.worldweatheronline.com/feed/weather.ashx', callbackKe
Ext.data.JsonP.request({
url: 'http://free.worldweatheronline.com/feed/weather.ashx',
callbackKey: 'callback',
params: {
key: '23f6a0ab24185952101705',
q: '94301', // Palo Alto
format: 'json',
num_of_days: 5
},
callback: function( data ) { console.log("callback" + data);},
success: function(result, request) {
console.log("success");
var weather = result.data.weather;
this.respuesta = 'The temperature in Palo Alto is <b>' + weather[0].tempMaxF + '° F</b>';
return 'The temperature in Palo Alto is <b>' + weather[0].tempMaxF + '° F</b>';
},
failure: function(response) {
console.log("failure");
var json = Ext.decode(response.responseText);
return 'fail';
}
});
发出web服务请求的JavaScript代码是:
@GET
@Produces("application/json")
public String getJson(@QueryParam("texto") String cadenaTxt) {
System.out.println(" -----request in getJson:"+ cadenaTxt + "-----");
String json1 = "{'name:'George Koch', 'age':58}";
String jsonPoutput = "callback("+ json1 + ");";
return jsonPoutput;
}
Ext.data.JsonP.request({
url: 'http://localhost:8080/proxySimplext/webresources/simplificar',
callbackKey: 'callback',
params: {
format: 'json',
texto: 'texto que envio'
},
callback: function( data ) {
console.log("callback" + data);
},
success: function(result, request) {
console.log("success");
return 'Sucesss';
},
failure: function(response) {
console.log("failure");
var json = Ext.decode(response.responseText);
console.log('Fallo de conexion:' + json);
return 'failure';
}
});
不工作。
请求到达web服务,但跳过JavaScript代码中的超时。我尝试了很多解决方案,但没有办法解决它
控制台上的响应是:
Uncaught SyntaxError: Unexpected identifier
failure Utils.js:105
Fallo de conexion:undefined
会发生什么?欢迎你给我任何建议
非常感谢 由于故障处理程序被触发,我怀疑问题在于您的Web服务本身。我会查看你的服务器应用程序的日志,看看它阻塞了什么。有时,直接点击Web服务来调试Web服务也很有帮助……这样,您就不需要对Sencha Touch的额外层进行故障排除。我想问题在于,Web服务没有配置为正确接收Sencha Touch发送的url的构造。