Constructing WebDAV Requests with XMLDOM

Constructing WebDAV Requests with XMLDOM

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

This example shows how you can construct the body of a WebDAV PROPFIND Method by using the Microsoft XML (MSXML) COM component. In the XML DOM object model, you use the AppendChild method to create nodes and add them to the XML document. After the request has been constructed as an XML DOM document, you then pass a reference to an XMLHTTP Component Object Model (COM) object and send the PROPFIND Method request to the server.

See Constructing Exchange Store HTTP URLs and Authentication and Security Using WebDAV for more information.

VBScript

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>PROPFIND</TITLE>
</HEAD>
<BODY>

<SCRIPT FOR=window EVENT=onload LANGUAGE=VBScript>
<!--

Set req = CreateObject("Microsoft.XMLHTTP")
Set domin = CreateObject("Microsoft.XMLDOM")
Set domback = CreateObject("Microsoft.XMLDOM")

req.Open "PROPFIND", "http://example.com/public/docs/myFile.doc", False, "Domain\User", "thepassword"

req.setRequestHeader "Content-Type", "text/xml; charset=""UTF-8"""

Set oPi = domin.createProcessingInstruction("xml", "version='1.0'")
domin.appendChild(opi)

Set PFind = Domin.CreateNode(1, "d:propfind", "DAV:")
domin.AppendChild PFind

Set DProp = Domin.CreateNode(1, "d:prop", "DAV:")
PFind.AppendChild DProp

Set Author = Domin.CreateNode(1, "O:Author", "urn:schemas-microsoft-com:office:office")
DProp.AppendChild Author
MsgBox domin.XML, ,"IN: PROPFIND"

req.Send Domin

MsgBox req.StatusText, ,"PROPFIND"
Set domback = req.ResponseXML
MsgBox domback.XML, ,"OUT: PROPFIND"
MsgBox domback.Text, ,"OUT: PROPFIND (text)"

Set req = Nothing
Set domin = Nothing
Set domback = Nothing

' -->
</SCRIPT>



</BODY>
</HTML>


Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.