6.0
Table Of Contents
- vSphere Web Services SDK Developer’s Setup Guide
- Contents
- About the vSphere Web Services SDK
- Knowledge Required for Using the vSphere Web Services SDK
- Programming Languages Supported by the vSphere Web Services SDK
- Types of Applications That You Can Build Using This SDK
- Downloading the vSphere Web Services SDK
- vSphere Web Services SDK Package Contents
- SDK Versions and VMware vSphere Product Compatibility
- Setting Up for Java Development
- Setting Up for Microsoft C# Development
- vSphere Server Certificates
- Scripting the C# DLL Build
- Index
vSphere Web Services SDK Developer’s Setup Guide
20 VMware, Inc.
Building the C# vSphere DLLs
In the vSphere Web Services SDK, VMware supplies sample vSphere clients for Visual Studio 2008. The SDK
includes a project (.csproj) file for each sample, and a solution (.sln) file for the whole set of samples. The
project files reference the DLLs through which a client communicates with the Web service.
XML Serializers
For best performance, precompile the XML serializers to a separate DLL. If you precompile the XML serializers
and modify the class declaration to use the precompiled serializer DLL, the SDK samples require a shorter
initialization time when they instantiate the VimService class.
See the MSDN documentation for more details about XML serialization and startup performance.
Build the C# vSphere DLLs
Before you can run the SDK samples, you must build the DLLs that provide common services to the samples.
Prerequisites for Building the C# vSphere DLLs
Install a C# development environment, as described in “Setting Up for C# Development” on page 17.
Open a Visual Studio command shell window and set environment variables as described in “Set
Environment Variables To Build C# DLLs and Samples” on page 18.
For an example of how to script this procedure using a Windows batch file, see “Scripting the C# DLL Build”
on page 31.
To build the C# vSphere DLLs
1 Open a Visual Studio Tools command shell.
2 Navigate to the .NET subdirectory for vSphere client samples.
cd %WS_SDK_HOME%\vsphere-ws\dotnet\cs\samples
3 Generate the VimService.cs file from the WSDL, using the following command syntax with the WSE
WSDL tool:
wsewsdl3.exe /n:Vim25Api /type:webClient /l:CS %WSDLHOME%\vim.wsdl %WSDLHOME%\vimService.wsdl
This command generates VimService.cs, the default output file, in the current directory, using the
Vim25Api namespace.
4Compile VimService.cs to a library, using the following command syntax:
csc /t:library /out:Vim25Service.dll /r:"%WSE_HOME%\Microsoft.Web.Services3.dll" VimService.cs
This command generates a serializer assembly, a DLL.
5Use the sgen tool to pregenerate and compile the XML serializers, using the following command syntax:
sgen /p Vim25Service.dll
This command outputs the Vim25Service.XmlSerializers.dll file in the current directory. This DLL
file contains pregenerated XML serializer code.
6 Using a source code editor, find occurrences of the following string in the VimService.cs file that you
generated in Step 3.
[System.Xml.Serialization.XmlIncludeAttribute
Replace occurrences of the string with
// [System.Xml.Serialization.XmlIncludeAttribute
This will prevent .NET from processing the Xml.Serialization.XmlIncludeAttribute attributes that
are the main cause of the slow instantiation of the Vim25Service class.