Titanium中的登录模块

时间:2012-09-19 18:08:47

标签: login titanium

任何人都有使用ProviderService.Src开发Login模块的经验。

我需要使用Titanium Appcelerator使用webservice开发一个登录模块。它需要两个字符串(用户名和密码)并返回true / false。我需要通过Web服务发送输入的登录名和密码并接收true / false。网络服务是

http://46.18.8.42/FareBids.Service/FareBids.ServiceLayer.ProviderService.svc

请有人指导我如何用它创建一个登录模块?我得到的信息说我使用SUDS。有人可以用代码帮助我(如果可能的话)  真的很感激帮助。感谢。

1 个答案:

答案 0 :(得分:0)

使用网络服务http客户端。这应该这样做,您必须将其调整到您的特定Web服务并显然从用户收集数据,但如何在the most basic Titanium tutorials.

中详细记录
    var loginSrv = Ti.Network.createHTTPClient({
        onload : function(e) {
             // If the service returns successfully : true, or false
             var isUserAllowed = this.responseText; 
        },
        onerror : function(e) {
            // Web service failed for some reason
            Ti.API.info(this.responseText);
            Ti.API.info('webservice failed with message : ' + e.error);
        }
    });
    loginSrv.open('POST', 'http://46.18.8.42/FareBids.Service/FareBids.ServiceLayer.ProviderService.svc');
    // you may have to change the content type depending on your service
    loginSrv.setRequestHeader("Content-Type", "application/json");

    var sendObj = {loginid : 'someid', pwd : 'somepassword'};
    loginSrv.send(obj);