2012-09-19 126 views
0

任何人都有使用ProviderService.Src開發登錄模塊的經驗。Titanium登錄模塊

我需要使用Titanium Appcelerator開發具有webservice的登錄模塊。它需要兩個字符串(用戶名&密碼)並返回true/false。我需要通過網絡服務發送輸入的登錄名和密碼,並接收真/假。 webservice是

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

請有人指導我如何創建一個登錄模塊與它?我得到了說我使用SUDS的信息。有人可以幫我用代碼(如果可能) 幫助真的很感激。謝謝。

回答

0

使用webservice 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); 
+0

記錄請看web服務的鏈接。我沒有任何數據庫...只是使用這個網址,請告訴我如何去登錄模塊。我得到了一些使用suds.js的信息,我們可以繼續。但不知道該怎麼做。如果任何人都成功了,請給我代碼。謝謝。 – user1562991

+0

此外,當我嘗試使用這裏的代碼時,它說[INFO] [TiAPI(688)] webservice失敗,顯示消息:無法處理消息,因爲內容類型'application/x-www-form-urlencoded'不是預期類型'application/soap + xml;字符集= UTF-8' 。請幫助我瞭解關於內容類型的信息。謝謝。 – user1562991