Supporting tables in web design
Jan 12 11:23:28
Test site availability from around the globe
Nov 7 0:53:22
Clamshell - an OpenID server
Jun 20 5:33:06
Writing Strategic Initiatives
Mar 6 3:08:15
Writing a strategy document
Mar 6 3:00:53
In response to a question from a reader, Tim, this is a follow-up from an earlier article on SharePoint, SOAP and VBScript. This time, we'll look at how to do more complex calls to SharePoint web services in VBScript
Some web services in SharePoint require passing XML as parameters. Unfortunately, you can't pass an XML document, it has to be an XML node element, and this takes a bit of effort to construct in VBScript.
The example we'll use is making a call to
GetListItems, which returns all items in a SharePoint library, optionally matching a query formatted using a special XML syntax.
To correctly call this web service, create a VBScript file with the following lines:
Dim xmlDoc, SOAPClient Set xmlDoc = CreateObject("MSXML2.DOMDocument.5.0") xmlDoc.async = False xmlDoc.loadXML( _ "<Document>" + _ " <Query><Where><Gt><FieldRef Name=""ID"" />" + "<Value Type=""Counter"">1</Value></Gt></Where></Query>" + _ " <ViewFields/>" + _ " <QueryOptions/>" + _ "</Document>") Set SOAPClient = CreateObject("MSSOAP.SOAPClient") SOAPClient.mssoapinit "http://sharepoint.alentus.com/_vti_bin/Lists.asmx?WSDL" Dim result Set result = SOAPClient.GetListItems( "Tasks", "", _ xmlDoc.getElementsByTagName("Query"), _ xmlDoc.getElementsByTagName("ViewFields"), "", _ xmlDoc.getElementsByTagName("QueryOptions"), "" ) DisplayNode result.childNodes
There are a number of ways to create and retrieve XML nodes, of course, but this way has the benefit of being fairly concise and self-explanatory.