Erik Lenaerts

Do, or do not. There is no try.

January 2007 - Posts

Extending a Virtual PC Harddisk (VHD)

Since I have my new laptop at work (a Core Duo 2) I decided to create my Virtual PC demo environments on my development machine.

I read that Virtual PC 2007 (Beta tho) is optimized for this type of processors and I definitely can confirm this. It is amazingly fast compared to my previous laptop running Virtual PC 2004.

So, I started a new Virtual environment with only 6 GB of Harddisk space :(. Don't ask me why I didn't took more space than that... Soon after installing Windows 2003 R2 and some other stuff I ran out of disk space.

After browsing the web I found this small utility to extend a VHD file which works great even with VPC 2007. Basically, you redefine the size of the VHD which results into unpartitioned space. Then u need to extend the initial disk with the unpartitioned space like explained on the website of XtraLogic.

Tip: If you are building a SharePoint demo environment check out this serie.

Posted: Jan 12 2007, 02:03 AM by ErikL | with no comments
Filed under:
IE Developer Toolbar Beta 3

The latest version of the developer toolbar is available here. I really like it a lot because it takes up less space (no menu bar anymore) and it adds lots of new features geared towards CSS investigation.

A must have for every Web Developer!

You can get it here and read the announcement on the IE blog here.

Posted: Jan 10 2007, 01:17 AM by ErikL | with no comments
Filed under: ,
Uploading a document to a SharePoint Document Library

After some hours browsing the web I found several techniques to upload a document to a SharePoint Document Library.

  1. Using a Network share
    This option is really simple but mapping a network share on every client PC is perhaps not an option. However, no meta information can be set using this option.
  2. Using the Object Model explained here or via a web service wrapper like here or here
    The object Model requires development on the server and thus doesn't provide remote development scenario's. That's why some add a WS wrapper, however this ain't a good approach when working with huge files.
  3. You can also use the AddAttachement method of the Lists Web Service of SharePoint, described here.
    A standard way to add files using the SharePoint Web Services. Again, not recommended for large files.
  4. WebDAV is another way to upload a document this is used by the bulk upload utility from spsdev.com. (This is also used by Windows Explorer and the explorer view of a document library)
    This offer better performance and support for larger files, however it doesn't support the versioning aspects of SharePoint.
  5. FrontPage RPC is the hardest but imo best way to upload documents. Read a post and get the code here.
    This approach is good for large files and it supports all the SharePoint features, in fact Office Client apps itself uses this. They combine FPRPC together with the SharePoint Web Services (for the SharePoint Task Panel).

if you want to read a good overview of these technologies, check out the powerpoint presentation from Patrick here.

Posted: Jan 08 2007, 08:46 AM by ErikL | with no comments
Filed under: , , ,
Start developing WSS 3.0 Webservice

My goal was to programmatically create a view on a document library. In my previous post I briefly described how to develop WSS using the Object Model directly.

In this post I wanna talk about the Web services wrapped around WSS. You can get more info in the WSS SDK or the online version here.

This link provides an overview of the different web services.

Lets start with a simple console example here.

 

        static void Main(string[] args)

        {

            string listUrl = "http://bsend3/Docs/_vti_bin/Lists.asmx";
            string list = "{834741CC-5486-4E29-86C9-E23F5126F53B}";

 

            try

            {           

                PrintLists(listUrl);

                PrintListProps(list, listUrl);

            }

            catch (System.Web.Services.Protocols.SoapException ex)

            {

                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine("Error: " + ex.Message);

                Console.WriteLine("Detail: " + ex.Detail.InnerText);

                Console.ForegroundColor = ConsoleColor.White;

            }

 

            Console.ReadKey();

        }

We do want to catch exceptions. Basically the exception that could occur when using the webservice is: 'Microsoft.SharePoint.SoapServer.SoapServerException'. However since I'm developing on a development machine and not on a server has WSS installed, my environment doesn't recognize this exception object. When we browse the documentation, we'll see that this exception is derived from the .NET known 'System.Web.Services.Protocols.SoapException'.

Below we'll print all SharePoint Lists retrieved from the List Webservice. Programming in .Net against a web service requires a web reference. Read this post for the specific WSS details. After we have a web reference (in our case its called 'list_ws') you can execute this code:

        private static void PrintLists(string url)

        {

            Console.WriteLine("PrintLists");

            Console.WriteLine("----------");

 

            list_ws.Lists listService = new list_ws.Lists();

            listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            listService.Url = url;

 

            XmlNode ndLists = listService.GetListCollection();

 

            foreach (XmlNode ndList in ndLists)

            {

                Console.WriteLine("Title: " + ndList.Attributes["Title"].Value);

                Console.WriteLine("ID: " + ndList.Attributes["ID"].Value);

                Console.WriteLine("Desc: " + ndList.Attributes["Description"].Value);

                Console.WriteLine("".PadRight(50, '-'));

                Console.ReadKey();

            }

        }

 

When calling this function, we'll pass an url. This url is the place from where the GetListCollection will start looking for lists. In our case its on our WSS server (BSEND3) in the Docs subsite (this one exists in a default installation of SharePoint 2007). Note that the result is an Xml Node as described in the documentation.

In the next function we'll print the properties of one list:

        static private void PrintListProps(string listId, string url)

        {

            Console.WriteLine("PrintListProps");

            Console.WriteLine("--------------");

 

            list_ws.Lists listService = new list_ws.Lists();

            listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            listService.Url = url;

 

            XmlNode ndList = listService.GetList(listId);

 

            Console.WriteLine("Title: " + ndList.Attributes["Title"].Value);

            Console.WriteLine("ID: " + ndList.Attributes["ID"].Value);

            Console.WriteLine("Desc: " + ndList.Attributes["Description"].Value);

            Console.WriteLine("".PadRight(50, '-'));

            Console.ReadKey();

        }

The code of this function is quit similar with the previuos one, however we pass an additional listId. This is the Id of the List for which we'll want to display details for. Now this is in my opinion the hard part when working with the webservices. How do we retrieve the original IDs?

I figured, that there must be some tool to browse in the structure of a WSS/SharePoint environment and just easily retrieve the propper ID's. The original SharePointExplorer tool isn't updated to WSS 3.0 or SharePoint 2007 yet (and no, it doesn't work at all on the new versions, I tested it).

Another tool is SharePoint Inspector, but at the time of writing I couldn't download it.

So, today I just use the Webservice features like GetListCollection and look into the results to retrieve the ID's. I know, its not a very smart way, but I don't want to write an explorer tool when there are some other tools comming around the corner, right?

grtz

Start developing for SharePoint 2007

In SharePoint 2003, we needed to develop webparts on a server where SharePoint was installed. So, either you installed Visual Studio on a development server together with sharepoint or you created a complete new virtual environment on your dev machine.

Unfortunately developing in sharepoint is still the same. In fact the base problem is that the SDK (for either WSS v3.0 and SharePoint 2K7) are still help files only.

Hopefully microsoft releases a real SDK with the necessary binaries so we can just develop on our local dev machine... but imw we continue as be4.

more readings in this Thread

grtz