我对Appcelerator钛工作室非常陌生。你能帮我解决一下如何在Appcelerator钛中调用webservice(Java Based)。
答案 0 :(得分:5)
您可以使用Titanium.Network.HTTPClient拨打RESTful电话。
GET请求示例
var url = "http://www.appcelerator.com";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.open("GET", url);
// Send the request.
client.send();
POST请求示例
var xhr = Ti.Network.createHTTPClient();
xhr.onload = function(e) {
//handle response, which at minimum will be an HTTP status code
};
xhr.open('POST','http://www.myblog.com/post.php');
xhr.send({
title:'My awesome blog',
body:'Today I met Susy at the laundromat. Best day EVAR\!'
});
它支持动词GET,POST,DELETE,PUT,PATCH