JavaScripts communicate with WebServices

[Example1]

var xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
 
 xmlRequest.open("POST", "http://apcndaewchen1/FTHSEWebService/Service.asmx", false);
 xmlRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
 xmlRequest.setRequestHeader("SOAPAction", "http://apcndaewchen5/GetPIServerList");
 
 xmlRequest.send('<?xml version="1.0" encoding="utf-8"?>'
  '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
  '<soap:Body>'
  '<GetPIServerList xmlns="http://apcndaewchen5/" />'
  '</soap:Body>'
  '</soap:Envelope>');
 
 if( xmlRequest.status == 200 )
 {
  alert(xmlRequest.responseXML);
 }


 var xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
 
 xmlRequest.open("POST", "http://apcndaewchen1/FTHSEWebService/Service.asmx", false);
 xmlRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
 xmlRequest.setRequestHeader("SOAPAction", "http://apcndaewchen5/GetPIServerList");
 
 xmlRequest.send('<?xml version="1.0" encoding="utf-8"?>'+
  '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
  '<soap:Body>'+
  '<GetPIServerList xmlns="http://apcndaewchen5/" />'+
  '</soap:Body>'+
  '</soap:Envelope>');
 
 if( xmlRequest.status == 200 )
 {
  //alert(xmlRequest.responseXML.xml);
  var nodes = xmlRequest.responseXML.getElementsByTagName("GetPIServerListResult");
  for(var i = 0; i < nodes.length; i++ )
  {
   node = nodes[i];
   for( var j = 0; j < node.getElementsByTagName("anyType").length; j++  )
   {
    if( node.getElementsByTagName("anyType")[j].firstChild !== null )
    {
     nodeValue = node.getElementsByTagName("anyType")[j].firstChild.nodeValue;
     alert(nodeValue);
    }
   }
   
  }
 }

 

 

[Example2]

function Button1_onclick() {

 var xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
 
 xmlRequest.open("POST", "http://apcndaewchen1/FTHSEWebService/Service.asmx", false);
 xmlRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
 xmlRequest.setRequestHeader("SOAPAction", "http://apcndaewchen5/GetPIServerList");
 
 xmlRequest.send('<?xml version="1.0" encoding="utf-8"?>'+
  '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
  '<soap:Body>'+
  '<GetPIServerList xmlns="http://apcndaewchen5/" />'+
  '</soap:Body>'+
  '</soap:Envelope>');
 
 if( xmlRequest.status == 200 )
 {
  //alert(xmlRequest.responseXML.xml);
  var nodes = xmlRequest.responseXML.getElementsByTagName("anyType");
  for(var i = 0; i < nodes.length; i++ )
  {
   node = nodes[i];
   alert(node.text);
  }
 }
}

正在加载评论数据....
正在加载用户信息....

最新文章列表

正在下载文章列表...

博客访问数

正在加载访问计数....
博客推荐