【问题标题】:Recursively calling the web service not executing completely递归调用未完全执行的 Web 服务
【发布时间】:2013-01-10 12:29:01
【问题描述】:

我正在使用 Titanium Appcelerator 来开发 iphone 应用程序。我需要调用不同参数的 Web 服务大约 1250 次以上。我已将 xhr.send() 方法放在 xhr.onload 函数中。它工作正常大约 3-8 次,但之后停止调用。那里没有显示错误或任何问题。请提出建议。

  function(e){

var xhr = Titanium.Network.createHTTPClient();

var Request = "<RefId>"+idArray[e.index]"</RefId>";
xhr.open("POST", url); 

xhr.setRequestHeader("WWW-Authenticate","Basic");
xhr.setRequestHeader("Content-Type","text/xml", "charset=utf-8");
xhr.setRequestHeader("Content-Length", Request.length); 
xhr.setRequestHeader("SOAPAction", "http://example.com"); 

xhr.onload = function() {


    var doc = Titanium.XML.parseString(this.responseText);
    var type = doc.getElementsByTagName("studentName");

    Ti.API.info(type.item+';'+type.item.length);
    if(type.item.length<1){

        file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "textfile.txt");

    }
    doc=null;
    type=null;


if(idArray.length>e.index){
//alert('Calling API');

var url="http://example.com";
var Request = "<RefId>"+idArray[e.index++]"</RefId>";   
xhr.setTimeout(2500);
xhr.open("POST", url); 
xhr.send(Request);

}

};    
xhr.onerror = function(){
    alert('Error')
};
xhr.send(Request);

}

【问题讨论】:

  • 此处附上示例代码。

标签: javascript iphone titanium


【解决方案1】:

我会尝试每次重新创建客户端,而不仅仅是再次调用发送

【讨论】:

  • 任何猜测。这是什么原因?
  • 对此的任何回应。这可以解决吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
相关资源
最近更新 更多