Modifying Item Property Values (WebDAV)

Modifying Item Property Values (WebDAV)

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 to construct the body of a WebDAV PROPPATCH Method request by using the Microsoft XML (MSXML) 2.0 Component Object Model (COM) component. In the XML Document Object Model (DOM) object model, you use the AppendChild method to create nodes and add them to the XML document. After the request body has been constructed as an XML DOM Document, you then pass a reference to an XMLHTTP COM object and send the PROPPATCH Method request to the server. See Constructing Exchange Store HTTP URLs and Authentication and Security Using WebDAV for more information.

The following example illustrates the results of an HTTP request. (The code has been formatted for clarity.)

PROPPATCH /public/docs/myFile.doc HTTP/1.1
Content-Type: text/xml;   charset="UTF-8"
Content-Length: XXX
...

<?xml version="1.0" encoding="UTF-8"?>
<d:propertyupdate xmlns:d="DAV:">
  <d:set>
   <d:prop>
     <o:Author
        xmlns:o="urn:schemas-microsoft-com:office:office"
      >
        Jun Cao
     </o:Author>
   </d:prop>
  </d:set>
</d:propertyupdate>

If the request was successful, a message box displays the XMLHTTP.StatusText property, followed by the XML of the XML DOM object that is returned from the XMLHTTP object.

VBScript

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>PROPPATCH</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 "PROPPATCH", "http://myServer/public/docs/myfile.doc", False, "TheDomain\Administrator", "thepassword"

req.SetRequestHeader "encoding", "utf-8"


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

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

Set PUpdate = Domin.CreateNode(1, "d:propertyupdate", "DAV:")
domin.AppendChild PUpdate

Set DSet = Domin.CreateNode(1, "d:set", "DAV:")
PUpdate.AppendChild DSet

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

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

Set AuthorName = Domin.CreateTextNode("Jun Cao")
Author.AppendChild AuthorName

MsgBox domin.XML, ,"IN: PROPPATCH"

req.Send Domin

MsgBox req.StatusText, ,"PROPPATCH"

Set domback = Req.ResponseXML
MsgBox domback.XML, ,"OUT: PROPPATCH"
//-->
</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.