??????? ?????? ??????????? ???????? XMLHTTP

?????? ????????? ?????? ?????????
???? ???????: 893659 - ??? ???????? ???? ????? ????? ??? ???????.
???? "????? ???" ASP.NET

??????? ?????? ??????????? ???????? XMLHTTP

?????? ??? ?????? ??? ?????????? ???? ?? ????? ??? ????? ?????? ??? ?????? ???? ????????? ???? ???? ?? ??? ??????? ?? ?????? ????? ??????? ??????? ???????? "??? ?????". ????? ????? ?????? ???????? ????????? ?????? ??? . ???? ???? ?????? ??? ??????? ?? ????? ?????? ?? ??? ??????.
????? ???? | ?? ????

?? ??? ??????

????? ???

??? ????? ??????? ????? ?????? ????????? ?? ????? ??? ??????? ????? ?????? ??? ???? ???. ???? ???? ?? ???? ?????? ??? ???????? ??? ???? ???? ???? ?????? ?? ?????? ????? ??????? ??????? (?? ?? ????? "??????? ????") ???? ???? ?? ?? ???.

???? ???????? ??? ????? ????? ??????? ??? ????? ????? ??????????? ?? ??? ??????. ?? ?????? ???? ??? ???? ??? ???????? ??? ??????? ????????? ?? ???? ??????? ?? ???? ??????? ???? ?? ??????. ??? ???? ?????? ??? ???? ?? ?? ??????? ????????? ??? ??? ?????? ??? ???? ?????? ??? ?????? ???? ??????? ????????. ??????? ??? ?????? ??? ??? ????? ??????? ????? ???? ????? ?????? ????? ????? ?????.

????? ??????? ???? ????? ???? ?? ???? ???? ?????? ?? ????? ??????? ?? ???? ??????? XMLHTTP ???????? ???????? ????? ?? ??????? ??? ???? ???. ???? ?? ??? ?????? ??? ?????. ??? ???? ?? ????? ??????? XMLHTTP ?????? ??? ?? ???? ??? ?? ???????? ?? ???? Microsoft ASP.NET ??? ??? ???? ?????? ?????? ??? ??? ????. ???? ????? ?????! ?? ??.

???? ???? ???

???? XMLHTTP ?? ???? ????? ??? ??? ???? ??? ?? ??? ?????? ?????? ????? ?????? XML. ???????? ??? ???? XML ???? ?? ??????? ????? ??????? XSLT ?? XML DOM ??????? ??? ???? ????? ?? ?????? ??? ??? ????????. ??? ????? ??? ??????.

?????? ???? Microsoft ???? "???? ???" ? Internet Explorer ????? ??????????? ??? ????????? ?????? ??? ASP.NET ???? ??????. ??? ???? ?? ??? ?????? ??? ?????? ??? ??? ???? ????? ?????? ???? ???? ??? ??????. ??? ???? ??????? XMLHTTP ????? ?? ???!

?? ?????? ??? ???? ?? ???? ?? ??? ??????? ??? ???? ???? ??????? ???? ??? ??? ???? ??? ASP.NET ?? ???? XMLHTTP. ???? ??? ???? ????????? ?? ????? ???????? Northwind ??? SQL Server ??????? ????? ?????? ?????? ?????? ??? ?????? ?? ??????? ?? diffgram XML. ???? ?? ??????? XML DOM ?????? ??? ???????? XML ?????? ????? ?? ?????? ?????? ?? ???? ????. ???? ????? ?? ??? ??? ??? ?????.

???? ???

????? ???? ??? ???? ??? ?????? ???? ????????????. ????? ??? ASP.NET ?????? ???? ??? ??????? ?? C# ????? ????? ??? ????? ?????? ???????.
  • GetCategories ? ????? ?????? ?????? ???? ????? ??? ???? ?????? ???????? ?? ???? "??????".
  • ??????????? ? ????? ?????? ?????? ???? ????? ??? ???? ?????? ????? ???? ?? ??????? ??? ???????.
  • ????????????????? ? ????? ?????? ?????? ???? ????? ??? ?????? ??? ?????? ???? ?????? ???? ??? ??????? ??? ???????.

???? HTML

??? ??? ???? ?? ???? ??? ??? ??????? ?? ?????? ?? ??? ????? ??? ????? ?? ???? ??? ASP.NET ??? ???? ASP.NET. ?? ???? HTML ????? ???. ??? ???? ??? ???? ???? ????? ?? JavaScript ?????? ??? ??????? ??? ??? ???????? ????? ???? ???? ?????? ??????????? ??? ???? ???.

??? ???? ????? ??? ??????? ?????? ?? ????????? ???????? ?? ???? HTML.
var objHttp;
var objXmlDoc;

function getDataFromWS(methodName, dataSetName, wsParamValue, wsParamName)
{

    // create the XML object
    objXmlDoc = new ActiveXObject("Msxml2.DOMDocument");

    if (objXmlDoc == null)
    {
        alert("Unable to create DOM document!");
        
    } else {

	    // create an XmlHttp instance
	    objHttp = new ActiveXObject("Microsoft.XMLHTTP");
	
	
	    // Create the SOAP Envelope
	    strEnvelope = "<soap:Envelope xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
	
	            " xsd=\"http://www.w3.org/2001/XMLSchema\"" +
	
	            " soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
	
	            "  <soap:Body>" +
	
	            "    <" + methodName + " xmlns=\"http://jimcoaddins.com/DynaProducts\">" +
	
	            "    </" + methodName + ">" +
	
	            "  </soap:Body>" +
	
	            "</soap:Envelope>";
	
	
	    // Set up the post
	    objHttp.onreadystatechange = function(){
	
	        // a readyState of 4 means we're ready to use the data returned by XMLHTTP
	        if (objHttp.readyState == 4)
	        {
	
	            // get the return envelope
	            var szResponse = objHttp.responseText;
							
	            // load the return into an XML data island
	            objXmlDoc.loadXML(szResponse);
	
	            if (objXmlDoc.parseError.errorCode != 0) {
	                var xmlErr = objXmlDoc.parseError;
	                alert("You have error " + xmlErr.reason);
	            } else {
	
	                switch(dataSetName)
	                {
	                    case "CategoriesDS":
	                        processCategory();
	                        break;
	
	                    case "ProductsDS":
	                        processProducts();
	                        break;
	
	                    case "ProductDetailDS":
	                        processProductDetails();
	                        break;
	
	                }
	            }
	
	        }
	     }
	
	    var szUrl;
	    szUrl = "http://dadatop/wsXmlHttp/DynaProducts.asmx/" + methodName;
	
	    if (wsParamValue != null)
	    {
	
	        szUrl += "?" + wsParamName + "=" + wsParamValue;
	    }
	
	    // send the POST to the Web service
	    objHttp.open("POST", szUrl, true);
	    objHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    objHttp.send(strEnvelope);
	  }
}
??? ?? ???? ???? ?? ????????? ???????? ?? ??????? ????? ?? ???? ???? ?? ??? ???????? ??? ???? ??? ?? ????.

?? ???? ???? ???????? ????? ???? ??? ?????? ????? ?? ?????????: ??????? ? ???????????. ??? ?? ????????? ???? ??? ?????? ????? XMLHTTP ????? ?? ????? XML DOM ?????? ??. ?????? ??? ??? ?? ????? ???? ?????? ????????????? . ???? ?? ?????? ???????? ?? ????? ??????? ?????? ??? ???? ???. ???? ??????? ???? ?????? ?????? ???? ????????:
  • methodName ? ??? ??????? ??????? ??? ???? ???.
  • ??????????? -??? ????? ???????? ???? ??? ??????? ?????? ???? ???.
  • ???????????? ? ???? ??????? ???? ??? ??????? ??? ???? ??? ??? ??? ??? ??????. (???????)
  • ??????????? -??? ??????? ???? ??? ??????? ??? ???? ??? ??? ??? ??? ??????. (???????)
???? ??? ?????? ????????????? ??? ????? ?????? ?? ????. ????? ??????? ??????:
// create the XML object
    objXmlDoc = new ActiveXObject("Msxml2.DOMDocument");

    if (objXmlDoc == null)
    {
    		alert("Unable to create DOM document!");

    } else {

		// create an XMLHTTP instance
		objHttp = new ActiveXObject("Microsoft.XMLHTTP");
??? ?????? ?? ????????? ???????? ?????? ???? XMLHTTP ????? ????? XML. ???? ???? ???? ????? ???? SOAP.
// Create the SOAP Envelope
strEnvelope = "<soap:Envelope xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
	
          " xsd=\"http://www.w3.org/2001/XMLSchema\"" +
	
          " soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
	
          "  <soap:Body>" +
	
          "    <" + methodName + " xmlns=\"http://jimcoaddins.com/DynaProducts\">" +
	
          "    </" + methodName + ">" +
	
          "  </soap:Body>" +
	
          "</soap:Envelope>";
?? ??? ???????? ????????? ??? ???? ?????? ???? SOAP ??? ????? ????? ??? ??? ???? ????? ??? ???? ???. ?? ????? ?????? ????? ??????? ????? ????? ???? SOAP ????? ??? ?????? ??. ?????? ?????? ?????? ??? ???? ???? ????? ??? ???? ????? ??????? ???? SOAP ???? ???????. ??? ???? ??????? ???? ?? ???? ??? ??????? ??? ????? GetCategories ????????? ???? ??? ???? ?? ??????? ???? ???????:

?? ??? ??????????? ??? ??????
envelope.png


ASP.NET ???? ?? ????? ????? ???? SOAP HTTP POST ? HTTP GET. ?? ?????? ??????? ?? ??? ???????? ??? ?????? HTTP POST.

??? ???? ???? ????. ???? ???? ???? ??? ????? ?????? ?? ????????? ????????.
// Set up the post
objHttp.onreadystatechange = function(){
	
// a readyState of 4	means we're ready to use the	data returned by	XMLHTTP
	if (objHttp.readyState == 4)
	{
	
		// get	the return envelope
		   var	szResponse	= objHttp.responseText;
	
		   // load	the return into an XML data island
		   objXmlDoc.loadXML(szResponse);
	
		   if (objXmlDoc.parseError.errorCode != 0) {
			var xmlErr =	objXmlDoc.parseError;
				 alert("You have error " + xmlErr.reason);
	}
	else	
	{

		switch(dataSetName)
				{
					case "CategoriesDS":
						processCategory();
						break;
					case "ProductsDS":
						processProducts();
						break;
					case "ProductDetailDS":
					processProductDetails();
						break;

				}
			}
????? ??? ????? ?? ???? XMLHTTP? ?????? ???? XMLHTTP ????? readyState ????? ???? ?????. ????? ??? ???? ???? ???????? ?? ???? ??? ??? ????? ????? ??????? readyState ??? ???? 4. ???? ?? ?????? ????? ?? ????? ???? ???? ???????? ??? ????? ??????? readyState ??????? onreadystatechange ????? XMLHTTP. ?? ???? ?????? ?? ???? ???????? ??????? ??? ???????? ?? ????? ??? ??? ???????? ??? ??? ?????.

????? ???? ???? ????????? ?????? ????? ????? ?????? XML ?????????? ???????? ??????? ????????????? . ??? ??????? ?? ????? ????????? ?? ???? ??? ?? ????? XML. ?? ??? ??????? ????? Microsoft ADO.NET DataSet.

?????? ????? ?????? ?? ??? ?????? ?? ????????? ???????? ????? ????? ???????? ?????? ???????? ???????? ??? ??? DataSet ???? ??? ??????? ?? ???? ???. ??? ???? ??? ????????? ???????? ???? ?????? ???????? ?????? ?? ??? ????.

???? ???? ???? ??? ????????? ???????? ???? ?????? ?????? ??? XMLHTTP.
var szUrl;
	szUrl = "http://dadatop/wsXmlHttp/DynaProducts.asmx/" + methodName;
	
	if (wsParamValue != null)
	{
	
	      	szUrl += "?" + wsParamName + "=" + wsParamValue;
	}
	
// send the POST to the Web service
	objHttp.open("POST", szUrl, true);
	objHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objHttp.send(strEnvelope);
??????? ????? ????? ??? URL ???? ??? ???????? ???????? ???? ??? ?? ??? ??????. ?? ???? if ????? ???????? ??? ?? ?? ???????? ???? ?? ??????? ????? ????? ??????? ????? ????????? . ?? ?????? ?????? ??? ?? ????? ?????? ???????? ??? ???? SOAP. ??? ???? ???????? ????? ??? ?? ????.

??? ??????? ??????? ??? ???? XMLHTTP ??????. ??? ??????? ???????? ??????? ?????? ??????? open; ??????? URL ????? ?????? ???? ?? ??? ??? ????????? ??? ???????.
??? ??? ?? ????? ??????? ??? ?????? ???? ???? ??? ????? ????? ?? ????? ?? ???? ??????? ??????????????????? .

??? ????? ????? ????? ???? ???????? ???? ????? ????? SOAP ???????? ????? ????? ????? ?????.

??? ??????? ???? ??? ?? ?? ????????? ???????? ???? ???? ?????? ????? XMLHTTP. ???? ???? ????? ???? ??? ????????? ???????? ??????? ?? ??????? ?? ???????? ????? ????? ????????? ?? ??????? ???? ???.

????? ??? ???? ?? ?????? ???? ??? ????????? ??? ????? ??????.
function getCategories()
{

  var func = "getDataFromWS('GetCategories', 'CategoriesDS')";
  document.all.lblCategoryDropdown.innerText = 
"Please wait while data is retrieved...";
  window.setTimeout(func, 1);

  }
??? ?? ???? ?? ??? ?????? ????? ????? ?????? ??????? ?????? ?????????????. ???? ??? ???? ??? ??????? window.setTimeout ?? ????? ??? ?????? ???????? ?????? ????????????? . ????? ?? ??? ??????? ?????? ?? ???? ?????? ???????? ????? ??? ????? ??????? ???? ??? ??????. ???? ?? ??? ??? ????? innerText ?? DIV ???? ????? ???? ??? ?? ??? ??????? ????????. ??? ??? ????? ?????? ????????????? ?? ???? ??????? window.setTimeout ? ???? ??????? ???? ?????? ?? ???? ????? ?????.

?????? ????????? ???? ???

???? ??? ??????? ??????? ??????????????????? ?????? ????? ?? ?????. ???? ?? ??? ?????? ???? ?????? ???? ????? ???????? ??? ??? DataSet ????? ??? ???? ?? ???????. ?? ??? ??????? ??? ?????? ???????? ????? ??? ?? ???????????. ????? ???? ??????? ???? ?????????????? ?? ???? ?? ???????. ???? ????? ???? ??? ??? ?????? ?????? ????? ??????? XML DOM ?????? ???? ????????? ?? ???? ???.
function processCategory()
{

  // get an XML data island with the category data
  objNodeList = objXmlDoc.getElementsByTagName("Categories");
 
  // add default value to the drop-down
  document.forms[0].drpCategory.options[0] = new Option("Select a Category", 0);

  // walk through the nodeList and populate the drop-down
  for (var i = 0; i < objNodeList.length; i++) 
  {
      var dataNodeList;
      var textNode;
      var valueNode;

      dataNodeList = objNodeList[i].childNodes;
      valueNode = dataNodeList.item(0);
      textNode = dataNodeList.item(1);

      document.forms[0].drpCategory.options[i + 1] = 
new Option(textNode.text, valueNode.text);
      document.all.lblCategoryDropdown.innerText = "Select a Category:";
      document.forms[0].drpCategory.style.visibility = "visible";
       
    }

  }
???? ?? ?????? ????????????? ????? XML ?? ????????? ??? ???? ??????????? . ?? ???? ?????????????? ? ??? ??? ??? XML ?????? ?? ???? ??? ???? ??????? ???????? ?????.

??? ?? ???? ?? ????? ???? ????????????????? ???????? ??? ?? ??????? XML. ??? ????? ?????? ???????? ??? ???? ?? ??????? ???? ??? ? diffgram? ??? ????? ?????? ?? ??? ????????? ??? ???? ?? ???????? ?? DataTable ???? ??? ?? ????? ?? ?????? ????????. ???? ?? ???? ??? ??? ?? ???? ????? ???? ????????????????? ?? ???? XML ???? ????? ??? DataTable.

??? ???? ?? ????????? ???????? ?????? ????? ???? ???? ?? ????? DataTable ???? ???? ???? ???????? ??? ?????? ????????. ????? ??? ????? XML ?? ???? ???? ??? ????? ?????? ???????? ???? ???? <CategoriesDS>? ??? ?? ?? DataTable ????? ??? ??? <Categories>?????? ??? ?? ???? ?? ??? XML ?????.

</Categories></CategoriesDS>??????? ??????? ??? ?????? ??????? ?? Microsoft ???? ???????:
?? ??? ??????????? ??? ??????
?????
?? ?????? ?????? GetCategories.xml ????.
?? ??? ??????????? ??? ??????
?????
?? ?????? ?????? WSXMLHTTP.exe ????.????? ?? ????????? ??? ????? ????? ????? ??? Microsoft? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ? Microsoft":
119591 ????? ?????? ??? ????? ??? Microsoft ?? ??????? ??? ????????
???? Microsoft ??? ??? ????? ????? ?? ?????????. ???????? ???? Microsoft ???? ????? ????? ?? ????????? ???? ???? ?????? ??? ??? ?????. ??? ????? ????? ??? ????? ????? ?????? ???? ????? ??? ??? ????????? ??? ?????? ??? ??? ?????.

?????? ??? ???? XML ???? ????? ??? ??? DataTable? ?????? ??????? ????????? ???????? ???????:
objNodeList = objXmlDoc.getElementsByTagName("Categories");
???? ?????? ???? IXMLDOMNodeList ????? ??? ?? ???? <Categories>. ??? ?? ???? ?? ???? ??? ????? ???????? ??????.</Categories>
// walk through the nodeList and populate the drop-down
  for (var i = 0; i < objNodeList.length; i++) 
  {
      var dataNodeList;
      var textNode;
      var valueNode;

      dataNodeList = objNodeList[i].childNodes;
      valueNode = dataNodeList.item(0);
      textNode = dataNodeList.item(1);

      document.forms[0].drpCategory.options[i + 1] = 
new Option(textNode.text, valueNode.text);
      document.all.lblCategoryDropdown.innerText = "Select a Category:";
      document.forms[0].drpCategory.style.visibility = "visible";
       
    }
???? ?????? ?? ???? <Categories>?? ?????? ?????: ?????? <ID>??????? <CategoryName>. ????? ??? ??? ???? ?? ????? ???? ?? ????????????????? ????? ?????? ??????? ?????? <Categories>??????.</Categories> </CategoryName> </ID> </Categories>
dataNodeList = objNodeList[i].childNodes;
??? ?? ?????? ??????? ???? ?????? ??? ?? ?? ????? ???? ????? ???? ???????? ?????? ??. ????? " ???? _ ????? " ?? ????? ?????? ????? ??? ?????? ??????? ??????? ??????? ????? ??? ????? ??? ????? ?? ????? ????????. ??? ????? ???? ???? ???? ?????? ???? ??? ??? ??????????? ?????? ??? "???? ?????"??????? ??? ??????????? ??????? ????????. ?????? ???????? ???????? ????????? ?? ????? ???????? ??? ??????? ???? ???????? ???????? ?? ??????? XML ???? ????? ?? ??????.

?????? ????? ????? ?????? ?? ????? ????? ?? ???????? ???? ??????? DOM ????? ??? ????? ????? ???? ???????? ?????. ??? ??? ?????? ?? ???? ????? ?? ????????? ????? ?????? ??????? XSLT ????? ?? ???.

????? ?????? ?? ?? ???

???? ??? ??? ???? ?????? ????? ??? ?? ???? ??? ??? ???????? ??? ????? ??????? ????? ?????? ????? ???????? ?? ????? ?????.

??? ???? ???

???? ???? ??? ASP.NET? ?????? ??? ?????? ???? ??? ??????? ??? ??? ???? ????? ????? ??. ?????? ???? ????????? ???????? ? DynaProducts.asmx ?????? ????? ???????. ??? ?????? ?????? ??? ????? ???? ???? SA. ??? ????? ??? ???????? ?? ?????? ????? ???? ???.

??? ??? HTML

??? HTML ????? ??? ????? ?????? ????? ???? ????? ??? ????? URL ????? ???. ???? ??? ??????? ?? ?????? ????????????? ?????? ?? ???? ??????. ??? ????? ??? ????? ??? ??? ????? URL ????? ????? ??? ???? ??? ???? ?????.

??? ?????? ??? ?? ???? ??? ???? HTML? ?????? ??? ??? HTML. ??? ??????? ???? ??? ??????? ???????? ????? ?? ???? ????? XMLHTTP ????? ??? ???? ???. ????? ?? ??? ???? ??? ??? ???? ????? XMLHTTP ?????? ???? ???? ???? ??????? ?????? ????????. ????? ???? ?? ?????? ???????? ?????? ???? ?? ?????? ??? ??? ??????.

???? ?? ??? ??? ?????? ??? ???? ????? ?? ?? ??? ??????? XMLHTTP. ??? ?? ?????? ????? XMLHTTP. ??? ??? ?? ???? ??? ??? ???? ?????? ?????? ?? ????? ?????? ????? ??????? ??? "????" ??? ????????. ??? ??? ??????? ???? ?? ??? ??????? ???? ????!

???? ???: ?? ??? ??????? ???????? XMLHTTP ???????? ???? ???. ???? ?? ???? ?????? ??????? ?????? ???? ????? ASPX ?? ???? ASP. ??? ???? ??? ??? ??????? ???????? ?????????? ?? ??? ???. ???? ?? ??? XMLHTTP ????? ?? ????? ????? ????? ????? ?? ??????????.
??? ??????? ????? ?? ????? ?? ????? ????? ??? ???????? ???? ?????? ?? ???????? ????? ?? ?? ????? ??????? ? Microsoft ???????? ?????? ??? .

???????

???? ???????: 893659 - ????? ??? ??????: 19/?????/1434 - ??????: 6.0
????? ???
  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1
????? ??????: 
kbgraphic kbscript kbxml kbhowto kbmt KB893659 KbMtar
????? ????
???: ??? ????? ??? ??????? ???????? ????? ?????????? ??????? ?????? ??? ??????? ?? ??? ??????? ?? ??????? ??? ??? ?? ???? ????????? ???? ??????? ???????(CTF) ?? ?? ???? ????? ????. ???? ?? ???? ?????????? ??? ???????? ???????? ???? ??? ?? ???????? ??????? ?? ??? ??????? ???????? ?? ??? ??????? ??????? ??? ?????? ?? ?????? ??? ???? ???????? ???????? ?? ????? ??????? ????? ????? ??????. ??? ?? ???????? ???????? ?? ????? ??? ????? ?? ???????? ?? ???? ????? ?? ?????. ?????? ??? ???? ?????????? ???? ?????? ?? ??? ????? ?? ??? ??? ?? ??????? ?? ??? ????? ?? ???? ????? ????? ?? ????? ??????? ???? ?? ???????? ?? ??? ???????.
???? ??? ????? ??????? ?????? ??????????893659

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com