|
Sadly in WSS 3/MOSSS 2007 the Client side API for SharePoint is somewhat lacking compared to the powerful and well documented Server side Object Model, luckily Visual Studio 2008 makes it fairly easy to perform basic tasks with Document Libraries from the client end. This guide will show you how to use the basic Visual Studio Web Service reference tool to add and access the DWS API. _vti_bin/DWS.asmx Making Visual Studio aware of the DWS Click on the Advanced button in the dialog that appears. Click on the Add Web Reference button. Enter in the address of your SharePoint web site (or subsite) plus the /_vti_bin/DWS.asmx URI and click Go to discover the Web Service Visual Studio will render the web page that SharePoint provides with a list of all available methods that can be used with the service. On the right side give the Web Service a useful name and click Add Reference. Your Web Service is accessible programmatically. Changing the DWS URI from App.config Creating a Folder in an existing Document Library First construct an instance of the DWS object using the code and also pass through our current credentials (as this is a web service) Construct instance myDWSService.Dws dwsInstance = new Test_Console.myDWSService.Dws(); dwsInstance.Credentials = System.Net.CredentialCache.DefaultCredentials; The next step is to call the CreateFolder method, which returns a String object which is the XML response from the Server. The URL must include the Document Library URI name and the folder we wish to create, which may be a subfolder of a folder that already exists. CreateFolder call String response = dwsInstance.CreateFolder("Test Library/new_folder"); If you wish to create folders recursively, it would be best to split/explode a String by the forward slash and create each folder recursively as you go deeper into the hierarchy. Labels |











