2013-01-10 32 views
0

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

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); 

}

+0

任何代码,你可以分享?这里附上 – David

+0

示例代码。 –

回答

0

我会尝试每次重新创建客户端不只是打电话再次发送

+0

任何猜测。这是什么原因? –

+0

对此有任何回应。这是可以解决的吗? –