javascript循环并调用soap webservice

时间:2019-02-13 06:20:24

标签: javascript loops soap xml-parsing

我正在循环调用Web服务,并将参数从DB传递到Web服务。所有Web服务调用都在循环中得到响应。这是我的响应XML节点[Siebel response] [1] [ 1]:https://i.stack.imgur.com/TRCE2.png

我现有的代码是

<!-- language: lang-js -->

for(db=0;db.length;db++) // db loop
{
//call webservice and get below is **employeeData is multiple soap webservice response** xml that is attached in the picture. 

var soapEnv = new Namespace("SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/");
var rpc = new Namespace("http://siebel.com/asi/");

var siebelMessage = **employeeData**.soapEnv::Body.rpc::STEMIServiceRequestThinRefreshResponse.SiebelMessage;
    default xml namespace = "http://www.siebel.com/xml/STE%20MI%20Service%20Request%20Thin%20Refresh";
var employee = siebelMessage.ListOfSteMIServiceRequestThinRefresh.ListOfServiceRequest["ServiceRequest"];
for each(var rootNodeVal in employee) {

// do parsing but it executes only the first response and exits any advice
}

}

1 个答案:

答案 0 :(得分:0)

从Siebel角度来看,ListOfServiceRequest是一个零(一个)或更多ServiceRequests的字面列表。 还有

for each(var rootNodeVal in employee)

在这种情况下不正确,因为每个rootNodeVal = ServiceRequest。考虑公共循环(例如) for (var i =0; i < count; i++){ ListOfServiceRequest[i] .... }