4.0

Table Of Contents
VMware, Inc. 13
Chapter 2 Getting Started with the Lab Manager SOAP API
Simple and Advanced C# Code Samples
Reviewthesetuprequirementson“RequirementsforDevelopinganApplication”onpage 11.
YoucantestbasicAPIprogrammingconnectivitybetweenyourdevelopmentworkstationandyour
Lab ManagerWebservicebyusingthe“SimpleC#ExampleConsoleApplication.”Ifyouareusinga
programminglanguageotherthanC#andaWebservicesdevelopment
environmentotherthanMicrosoft
VisualStudio2005,seetheappropriatedocumentationformoreinformation.
Thiscodesampleperformsseveralsimpletasks.Thefirsttwotasksarerequiredofanyapplicationthatmakes
callstoaLab ManagerWebservice.
BindstotheLab ManagerSOAPAPI.
SetsuptheusernameandpasswordformakingaSOAPcall.
SetsuptheServicePointManagercertificatepolicytoaccepttheSSLcertificate.ToconnecttotheYoumust
setupthecertificatepolicytoacceptallcertificates.
Makesacalltogetaconfigurationobjectbasedontheobject’sname.
Displaysallconfigurationfieldsintheconsole.
Simple C# Example Console Application
CopythissamplecodeandpasteitintoyourMicrosoftVisualStudio2005environment.
using System;
using System.Net;
namespace LMConsoleApplication1
{
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
//
//** Bind to the Lab Manager SOAP API
//
LabManagerSoap.LabManagerSOAPinterface binding =
new LabManagerSoap.LabManagerSOAPinterface();
//
//** Enter the URL for your system here
//
binding.Url ="https://10.6.1.248/LabManager/SOAP/LabManager.asmx”;
binding.Timeout = 10 * 60 * 1000; // 10 minutes
ServicePointManager.CertificatePolicy = new CertificateAccepter();
//**
//** Allocate AuthenticationHeader object to hold caller’s
//** user name and password
//**
binding.AuthenticationHeaderValue = new
LabManagerSoap.AuthenticationHeader();
//
//** Substitute a real user’s user name, password, organization, and workspace
name here
NOTEVMwareassumesyouarefamiliarwithbasicprogrammingconceptsandalreadyhaveaprogramming
developmentenvironmentsetuponyourcomputer.