Simplest SOAP example

前端 未结 13 1665
死守一世寂寞
死守一世寂寞 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:04

    Easily consume SOAP Web services with JavaScript -> Listing B

    function fncAddTwoIntegers(a, b)
    {
        varoXmlHttp = new XMLHttpRequest();
        oXmlHttp.open("POST",
     "http://localhost/Develop.NET/Home.Develop.WebServices/SimpleService.asmx'",
     false);
        oXmlHttp.setRequestHeader("Content-Type", "text/xml");
        oXmlHttp.setRequestHeader("SOAPAction", "http://tempuri.org/AddTwoIntegers");
        oXmlHttp.send(" \
     \
       \
         \
          " + a + " \
          " + b + " \
         \
       \
     \
    ");
        return oXmlHttp.responseXML.selectSingleNode("//AddTwoIntegersResult").text;
    }
    

    This may not meet all your requirements but it is a start at actually answering your question. (I switched XMLHttpRequest() for ActiveXObject("MSXML2.XMLHTTP")).

提交回复
热议问题