VMware vSphere Web Services SDK .NET (DotNet) Samples Readme

VMware logo

This document includes these topics:

Note:   Information in this document may not be current. For up-to-date information, check these VMware Web sites:
Beta or Pre-release Products VMware Beta Community
Released SDK ProductsVMware vSphere Web Services SDK

This document contains summary information only. See the Developer’s Setup Guide (Chapter 3, “Setting Up for Microsoft C# Development”) for complete information.

Requirements

Application development using the C# bindings to the vSphere API requires Microsoft Visual Studio 2005 or later, and Microsoft .NET 2.0 or later.

Building the Samples

You can build the C# (.NET) samples using Microsoft Visual C# 2005 Express or Microsoft Visual Studio 2005 or later. Visual Studio 2003 is neither recommended nor supported, due to a performance issue with .NET stubs. See Knowledge Base article 87402 (“.NET Takes a Long Time to Instantiate the VimService Class”) for a discussion of the issue.



Building the Samples Using Visual Studio 2005 or later
  • Build the .NET stubs using the information provided in the Developer’s Setup Guide (Chapter 3, “Setting Up for Microsoft C# Development”) to optimize startup performance. See Knowledge Base article 87402 for a discussion of the performance issue and how Microsoft recommends users should optimize client stubs.

  • After the stubs have been generated, open the Solution file appropriate to the Visual Studio version installed, and build the Solution.

Building the Samples Using Visual C# 2005 Express

Select the default (Full) Microsoft Visual C# 2005 Express installation.

If your Microsoft Visual C# 2005 Express installation has not been configured using default locations, you must:

  • Create a VSINSTALLDIR environment variable (System environment variable);

  • Set the VSINSTALLDIR environment variable to the locations of the Microsoft Visual Studio tools and .NET Framework 2.0. These components are in the Common7 and SDK sub-directories of the Microsoft Visual C# 2005 Express installation. By default, they are located in the following directories:

            c:\Program Files\Microsoft Visual Studio 8\Common7

            c:\Program Files\Microsoft Visual Studio 8\SDK

    Use quotation marks around directory names that have spaces in them. For example:

            “C:\apps\Microsoft Visual Studio 8”

If Visual C# Express is installed in the default location (“c:\Program Files\Microsoft Visual Studio 8”), you do not need to create or set the VSINSTALLDIR environment variable.

  • Build the .NET stubs using the information provided in the Developer’s Setup Guide (Chapter 3, “Setting Up for Microsoft C# Development”) to optimize startup performance. See Knowledge Base article 87402 for a discussion of the performance issue and how Microsoft recommends users should optimize client stubs.

  • After the stubs have been generated, open the Solution file appropriate to the Visual Studio Express version installed, and build the Solution.

See the Developer’s Setup Guide (Chapter 3, “Setting Up for Microsoft C# Development”) for complete information.

Running the Samples

The samples can be executed from within the \bin\debug directory of each project. You can also run the samples from within Visual Studio, at the .NET command prompt.

To display help text for any application, simply run the application without any parameters.

To run any sample from within Visual Studio:

  1. Set the Startup Project to any of the projects present in the solution. For example, right-mouse click on the Browser2005 Project and then select Set as Startup Project from the menu.
  2. Change the Project Properties to specify the command line arguments:
    • From the Project menu, select Properties to display the Property Pages dialog.
    • In the Project_Name Property Pages dialog, select Configuration Properties—Debugging in the left-hand pane.
    • In the right-hand pane (under Start Options), select Command Line Arguments.
    • Click OK or File > Save to save your changes.
  3. Run the sample at the command prompt.

See the Developer’s Setup Guide (Chapter 3, “Setting Up for Microsoft C# Development”) for complete information.

Some Sample Applications

SampleDescription, command-line syntax, and example...
Browser Gets contents of the Service starting at the root folder, and prints out listing. Optionally, obtain properties for a specific type, or by default, for ManagedEntity.

Command line syntax:
Browser <webserviceurl> <username> <password> [<mo type> <property name> ...]

Examples:
Browser http://my-server/sdk myuser mypaswd
Browser http://myserver/sdk myuser mypaswd VirtualMachine name

ConnectConnects to service, logs into service, and logs out of service.

Command line syntax:
Connect <webserviceurl> <username> <password>

Example:
Connect http://my-server/sdk myuser mypaswd

EventFormat

Retrieve and Format the latest event. Demonstrates Event formatting.

Command line syntax:
EventFormat <webserviceurl> <username> <password>

Example:
EventFormat http://my-server/sdk myuser mypaswd

SimpleClientCode that demonstrates connecting to service, logging on to service, obtaining service content, and logging out from service.

Command line syntax:
SimpleClient <webserviceurl> <username> <password>

Example:
SimpleClient http://my-server/sdk myuser mypaswd

VmPowerOps Retrieves a reference to a vm and invokes various power operations on it, as specified on the command line options.

Command line syntax:
VmPowerOps <webserviceurl> <username> <password> <anyvm|namedvm> <vmname> <on|off|suspend|reset> <normal|hard|softOrFail|softOrHard> <hostname>

Example:
VmPowerOps http://my-server/sdk myuser mypaswd myWin2k3_ProductionVM on normal myhost.mycompany.com

WatchVM

Monitors updates on a particular virtual machine using the PropertyCollector.

Command line syntax:
WatchVM <webserviceurl> <username> <password> <inventory-path-to-vm>

Example:
WatchVM http://my-server/sdk myuser mypaswd Datacenter1/vm/myvm

VMware Resources


Copyright © 2012 VMware, Inc. All rights not expressly granted herein are reserved.

Last updated: 10Sep2012 |  VMware vSphere Web Services SDK