VMware {code} Community
deVreez11
Contributor
Contributor

How do I get started with the Web Service SDK in C#

Hi All,

Where can I find usefull information about the use of VMware.Vim in C# .NET.

Sofar I've setup an application with the use of VimClient.FindEntityViews but find it extreemly slow. So I'm looking for an alternative. I also found the PropertyCollector and some examples, but again these examples make use of the VimApi implementation and I'm having trouble porting this to VMware.Vim.

So a couple of questions

1. Why is VimClient.FindEntityViews slow, I found some comments about Certificate Validation but did not find any examples of how to handle this in the VMware.Vim implementation.

3. How do I use the PropertyCollector implemented in VMware.Vim, please don't point me to the VimApi examples, I already have a ton of them

4. I'm also looking for a better explanation of the TraversalSpec, difficult stuff.

Any help is highly appreciated

Regards Alfred

0 Kudos
14 Replies
tos2k
Expert
Expert

Hi!

Building the webservice stubs is described here: http://communities.vmware.com/message/1848913

3) PropertyCollector is used to monitor jobs. There is one intially on each vCenter/ESX host. You can/should create your own PropertyCollectors by using CreatePropertyCollector as described here: http://communities.vmware.com/message/1752888

4) TraversalSpec is a pain - but necessary in .NET - for Java checkout vijava over here: http://vijava.sourceforge.net/

HTH,

Tos2k

0 Kudos
deVreez11
Contributor
Contributor

Hi Tos2K,

Thanks for the reply, at last someone repsonds. I guess the timing of posting the question wasn't the right one with regard to the VMworld going on. Anyway.

Do I need to build the stubs. I followed the instructions of using VMware.Vim as a reference in my C# Project and what I'm doing sofar works fine, eventhough the calls take a while.

In your link to the description on how to use the CreatePropertyCollector, I can't seem to find any explanation or code examples on how to use the CreatePropertyCollector.

Thanks for the pointer to the java stuff, but I do need it for .NET in C#.

Regards Alfred

0 Kudos
tos2k
Expert
Expert

Hi!

Here is my first try, working on that too right now Smiley Happy

MOref propColl = service.CreatePropertyCollector(Service.PropertyCollector)

//do the updates/wait for changes using the created propColl

service.CreateFilter(propColl, ...)

service.WaitForUpdates(propColl, ...)

//when job is done, destroy the propColl

service.DestroyPropertyCollector(propColl)

HTH, Tos2k

0 Kudos
deVreez11
Contributor
Contributor

Hi Tos2K,

How do you instanciate the service object.

Regards Alfred

0 Kudos
tos2k
Expert
Expert

Did you check the samples that are provided by VimSDK at all?

VimService service = new VimService(...

Some more over here: http://communities.vmware.com/thread/216836

Good luck!

Tos2k

0 Kudos
Kjellski
Contributor
Contributor

Maybe you can answer the question I've already posted here: http://communities.vmware.com/message/1832303#1832303

Where is the VMware.Vim.dll gone? It was so perfectly nice to use it! I've already started to check this dll in because I don't want to loose this convenience anymore...

It really sucks that the dev team is not looking in the community that is using their software at the lower level...

And, once again, where is that damn dll gone to?

"Greetings",

Kjellski

0 Kudos
deVreez11
Contributor
Contributor

Hi,

I can imagine you would want to keep this assembly safe. Good idea

Regards Alfred

0 Kudos
deVreez11
Contributor
Contributor

Hi Tos2k,

Yes i did check the sample, but they are based on the use of VimApi I'm using VMware.Vim in my using clause of my C# Project.

Did you actualy try this, in my case there is no VimService to be found in the VMware.Vim assembly. The only VimService I have found is the VMware.Vim.VimClient.VimService which is a getter of the SoapHttpClientProtocal Smiley Sad

The link where some speudo code is referenced does not tell me where to get the VimService or whatever I need to get to the PropertyCollector stuff.

Regards Alfred

0 Kudos
tos2k
Expert
Expert

When adding Vim25Service*.dll to your project, you get Vim25Api namespace. Here you can find VimService class.

I agree: The vSphere 5 SDK is the most confusing and crappy release VMware did so long.

VimService you can find over at: ...\VMware-vSphere-SDK-5.0.0-429209\SDK\vsphere-ws\dotnet\cs\samples\AppUtil\SvcConnectionV25.cs

Those samples are just confusing for new-beginners, anyway a search on VimService would have given the file to you Smiley Happy

Tos2k

0 Kudos
tos2k
Expert
Expert

Your post is to long and confusing for me Smiley Happy

Please build the dlls for VimSDK as described in this thread, follow the links...

Tos2k

0 Kudos
deVreez11
Contributor
Contributor

Hi,

I've built the stubs in Visual Studio 2010 but get the following error.

What is going on, frustrating,,,

Regards Alfred

[ 26-10-2011 21:12:57 ] Begin Log.
Started
Caught Exception :  Name : WebException Message : The request failed with the error message:
--
<HTML><BODY><H1>301 Moved Permanently</H1></BODY></HTML>
--. Trace :    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebRespon
se response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at VimApi.VimService.RetrieveServiceContent(ManagedObjectReference _this)
   at AppUtil.SvcConnection.Connect(String url, String username, String password) in X:\Libraries\Downloads\VMware-vSphe
re-SDK-5.0.0-429209\SDK\vsphere-ws\dotnet\cs\samples\AppUtil\SvcConnection.cs:line 63
   at AppUtil.ServiceUtil.ClientConnect() in X:\Libraries\Downloads\VMware-vSphere-SDK-5.0.0-429209\SDK\vsphere-ws\dotne
t\cs\samples\AppUtil\ServiceUtil.cs:line 36
Exception running : Connect
Caught Exception :  Name : WebException Message : The request failed with the error message:
--
<HTML><BODY><H1>301 Moved Permanently</H1></BODY></HTML>
--. Trace :    at AppUtil.ServiceUtil.ClientConnect() in X:\Libraries\Downloads\VMware-vSphere-SDK-5.0.0-429209\SDK\vsph
ere-ws\dotnet\cs\samples\AppUtil\ServiceUtil.cs:line 46
   at AppUtil.AppUtil.connect() in X:\Libraries\Downloads\VMware-vSphere-SDK-5.0.0-429209\SDK\vsphere-ws\dotnet\cs\sampl
es\AppUtil\AppUtil.cs:line 652
[ 26-10-2011 21:13:28 ] End Log.

Connection Unsuccessfull
Press enter to exit.

0 Kudos
tos2k
Expert
Expert

Hi!

Google gave me that one: http://www.vmware.com/support/developer/vc-sdk/SetupGuide.pdf (search move permanently)

You can also try to point your application directly to an ESX host.

Same here: http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/visdk25setupguide.pdf

Looks as this has been posted before too: http://communities.vmware.com/thread/70331

Tos2k

0 Kudos
deVreez11
Contributor
Contributor

Hi,

I was running the Connect2010 Sample from the SDK. I connect to my vCenter Server.

Regards Alfred

0 Kudos
Kjellski
Contributor
Contributor

Since the dlls are back in the PowerCLI for me this continues to be the best way.

And, I've been able to upgrade to 5.0 _without_ rewriting any code!

Look here for further details:

HowTo: Beginners Advice for using the vSphere APIs in C#

0 Kudos