Simplest SOAP example

前端 未结 13 1666
死守一世寂寞
死守一世寂寞 2020-11-22 01:32

What is the simplest SOAP example using Javascript?

To be as useful as possible, the answer should:

  • Be functional (in other words actually work)
  • <
13条回答
  •  死守一世寂寞
    2020-11-22 02:12

    function SoapQuery(){
      var namespace = "http://tempuri.org/";
      var site = "http://server.com/Service.asmx";
      var xmlhttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0");
      xmlhttp.setOption(2,  13056 );  /* if use standard proxy */
      var args,fname =  arguments.callee.caller.toString().match(/ ([^\(]+)/)[1]; /*Имя вызвавшей ф-ции*/
      try { args =   arguments.callee.caller.arguments.callee.toString().match(/\(([^\)]+)/)[1].split(",");  
        } catch (e) { args = Array();};
      xmlhttp.open('POST',site,true);  
      var i, ret = "", q = ''+
       ''+
       '<'+fname+ ' xmlns="'+namespace+'">';
      for (i=0;i" + arguments.callee.caller.arguments[i] +  "";
      q +=   '';
                // Send the POST request
                xmlhttp.setRequestHeader("MessageType","CALL");
                xmlhttp.setRequestHeader("SOAPAction",namespace + fname);
                xmlhttp.setRequestHeader('Content-Type', 'text/xml');
                //WScript.Echo("Запрос XML:" + q);
                xmlhttp.send(q);
         if  (xmlhttp.waitForResponse(5000)) ret = xmlhttp.responseText;
        return ret;
      };
    
    
    
    
    
    function GetForm(prefix,post_vars){return SoapQuery();};
    function SendOrder2(guid,order,fio,phone,mail){return SoapQuery();};
    
    function SendOrder(guid,post_vars){return SoapQuery();};
    

提交回复
热议问题