Extracting VMware Web Service Proxies for .NET

The current VMware 5.1 SDK no longer redistributes pre-built .NET proxies, just the source WSDL. If you follow the documentation you are directed to complete a complicated procedure to generate and your own signed proxies.

Fortunately, there is an easier way to extract official signed assemblies from a VMware PowerCLI (PowerShell extensions) installation. This is much better than the previous method as you are using original DLLs provided (and supported by) VMware.

  1. Download and install the current VMware PowerCLI.
  2. Install the PowerCLI which includes the VMware VIX infrastructure components.
  3. Although the PowerCLI documentation suggests you reference VMware.Vim.dll in the program files infrastructure path, we won’t do this because some additional files are missing and we want a full stand-alone copy. The VMware VIX setup installs everything primarily in the GAC. So we will run one command to extract  the files we need from the GAC and copy them into the source so they can be referenced locally and checked-in. Change the “.” at the end of the following command to your own target path, else it copies into the current directory:
    for /f %i in ('dir %WinDir%\assembly\GAC_MSIL\*Vim*.dll /s /b') do copy %i .
  4. This will find several files of which the following are necessary to call VMware web services:
    VimService25.dll
    VimService25.XmlSerializers.dll
    VimService40.dll
    VimService40.XmlSerializers.dll
    VimService41.dll
    VimService41.XmlSerializers.dll
    VimService50.dll
    VimService50.XmlSerializers.dll
    VimService51.dll
    VimService51.XmlSerializers.dll
    VMware.Vim.dll
  5. Add a reference to VMware.Vim.dll then use the proxy classes there to call the web services, according to the VMware Web Services SDK documentation. Note that the main VIM assembly will load the relevant VimService## proxy according to the version it detects when connecting to the server (factory pattern), so you need them all including the XML serialization assemblies (it’s hard-coded, they are not optional)!

As a best practice I like to check-in all stand-alone dependencies into a “Dependencies” folder of the solution/checked-in source tree. Make sure you also redistribute these files with your application. I prefer this “local copy” method because this enables your code to compile on any developer PC or build server and be deployed as a stand-alone package.

8 thoughts on “Extracting VMware Web Service Proxies for .NET”

  1. Thanks for the tip! Just a small point I had to look at the source HTML to be able to see the entire command in FF 🙂

    for /f %i in (‘dir %WinDir%\Microsoft.NET\assembly\GAC_MSIL\*Vim*.dll /s /b’) do copy %i .

    The copy %i . isn’t visible 🙂

  2. Unfortunately there are no such files in the folder you’ve mentioned. I’ve just installed the newest Version of PowerCLI: 5.1.0.5375 and tried to find the files under the GAC_MSIL folder, but they’re gone. And they’re also not found in the PowerCLIs own folders.

    1. Hi Kjellski, Thanks for the information there was a mistake in the copy command. It should have used the legacy assembly directory below %WinDir% not the new one below the Microsoft.NET subdirectory. The post has been corrected now. Good luck with your VMware code! Tony

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s