nedcomp hosting homepage

Producten en diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

Microsoft XML Core Services (MSXML) 4.0 - DOM Reference

IXMLHTTPRequest

Provides client-side protocol support for communication with HTTP servers.

[Script]

Example

The following Microsoft® JScript® example posts a DOMDocument containing order information to an Active Server Pages (ASP) page on a server and returns the result as a new XML document.

<script language="JScript">
  function PostOrder(xmldoc)
  {    
    var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
    xmlhttp.Open("POST", "http://myserver/orders/processorder.asp", false);
    xmlhttp.Send(xmldoc);
    return xmlhttp.responseXML;
  }
</script>

The ASP page on the server loads the posted XML document, processes the order, and builds a resulting XML document.

<%@ language=javascript %>
<% 
    Response.Expires = -1000;
    // Load the posted XML document.
    var doc = Server.CreateObject("Msxml2.DOMDocument.4.0");
    doc.load(Request);
    var result = Server.CreateObject("Msxml2.DOMDocument.4.0");
    // Now process the order and build the result document.
    Response.ContentType = "text/xml";
    result.save(Response);
%>
[Visual Basic]

Example

The following Microsoft Visual Basic® example creates an XMLHTTP object and asks a server for an XML document. The server sends back an XML document that is displayed by the code snippet.

Private Sub Command1_Click()
  Dim HttpReq As New MSXML2.XMLHTTP40
  
  HttpReq.open "GET", "http://XMLSampleServer/CatalogServer.asp", False
  HttpReq.send
  MsgBox HttpReq.responseText
End Sub
[C/C++]

Example

The following C/C++ example creates an XMLHTTP object and asks a server for an XML document. The server sends back an XML document that is displayed by the code snippet.

#import "msxml4.dll"
using namespace MSXML2;

void XMLHttpRequestSample()
{
   IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;
   BSTR bstrString = NULL;
   HRESULT hr;

   try {
      hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP.4.0");
      SUCCEEDED(hr) ? 0 : throw hr;

      hr=pIXMLHTTPRequest->open("GET", "http://XMLSampleServer/CatalogServer.asp", false);
      SUCCEEDED(hr) ? 0 : throw hr;

      hr=pIXMLHTTPRequest->send();
      SUCCEEDED(hr) ? 0 : throw hr;

      bstrString=pIXMLHTTPRequest->responseText;

      MessageBox(NULL, _bstr_t(bstrString), _T("Results"), MB_OK);

      if(bstrString)
      {
         ::SysFreeString(bstrString);
         bstrString = NULL;
      }

   } catch (...) {
      MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);
      if(bstrString)
         ::SysFreeString(bstrString);
   }

}

Remarks

A client computer can use the XMLHTTP object (MSXML2.XMLHTTP.4.0) to send an arbitrary HTTP request, receive the response, and have the Microsoft® XML Document Object Model (DOM) parse that response.

This object is integrated with Microsoft® XML Core Services (MSXML) to support sending the request body directly from, and parsing the response directly into, the MSXML DOM objects. When combined with the support for Extensible Stylesheet Language (XSL), the XMLHTTP component provides an easy way to send structured queries to HTTP servers and efficiently display the results with a variety of presentations.

The usual sequence is to call the open method, set any custom header information through the setRequestHeader method followed by the send method, and then to check one of the four different response properties.

The XMLHTTP object is supported in Microsoft Internet Explorer 5.0 or later.

Requirements

Implementation: msxml4.dll, msxml2.lib

[C/C++]

Header and IDL files: msxml2.h, msxml2.idl

Version-Dependent ProgID: Msxml2.XMLHTTP.4.0

Version-Dependent CLSID: 88D969C5-F192-11D4-A65F-0040963251E5

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

IXMLHTTPRequest Members | DOMDocument


Download de SDK