In this technote, I will show you step by step how to create a complete VI client with Tomcat and the VI Java API (http://vijava.sf.net). The Java servlet sample code demos how to parse the URL sent from the VI client and connect back to the VC server to retrieve information and more.
Comments |
|
Aug 21, 2008 3:53 PM
Steve Jin
Andrew is leading a DotNet version of API. I will have him to post the link here. -Steve
Aug 21, 2008 4:14 PM
bruce.downs says:
in response to: Steve Jin
The relevant VIJ code that needs porting is in the ServiceInstance constructor.
public ServiceInstance(URL url, String sessionStr, boolean ignoreCert) throws ServiceException, RemoteException { if(url == null || sessionStr ==null) { throw new NullPointerException("None of url, session string can be null."); } if(ignoreCert==true) { this.ignoreCertificate(); } setMOR(SERVICE_INSTANCE_MOR); VimServiceLocator serviceLocator = new VimServiceLocator(); serviceLocator.setMaintainSession(true); VimPortType vimService = serviceLocator.getVimPort(url); ((org.apache.axis.client.Stub)vimService).setTimeout(1200000); //optional ((VimBindingStub) vimService).setMaintainSession(true); VimBindingStub vimStub = (VimBindingStub) vimService; vimStub._setProperty(org.apache.axis.transport.http.HTTPConstants.HEADER_COOKIE, sessionStr ); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); setServerConnection(new ServerConnection(url, vimService, this)); UserSession userSession = (UserSession) getSessionManager().getCurrentProperty("currentSession"); getServerConnection().setUserSession(userSession); }
Aug 21, 2008 4:23 PM
Steve Jin
The definition of the HEADER_COOKIE is:
Aug 21, 2008 4:32 PM
akutz says:
Check out the VI Toolkit for .NET at http://vitfordotnet.sourceforge.net/
Aug 22, 2008 9:04 AM
bruce.downs says:
in response to: akutz
Cool. I'm trying it out.
Aug 22, 2008 9:36 AM
Steve Jin
Thanks a lot Bruce. I filed a bug for you:
Aug 22, 2008 9:44 AM
Steve Jin
VI Java API does not have this issue. So forwarding it to Andrew to take a look. -Steve
Aug 22, 2008 11:36 AM
bruce.downs says:
in response to: Steve Jin
I logged this and another bug for vitfordotnet on sourgeforge.
Feb 21, 2009 6:11 PM
Steve Jin
VI Java API 2.0 was released. http://communities.vmware.com//thread/192910
Jul 16, 2009 5:28 AM
acnsys says:
in response to: Steve Jin
Please help, i am trying my best to get it work but each time i deploy the war project i get: type Status report message /ViClientWebApp/TestServlet description The requested resource (/ViClientWebApp/TestServlet) is not available I see the tab in the VICLient and i have cut and paste your code (Web.xml and TestServlet.java) from the PDF but it wont work... I also get that error with XML Spy: Tomcat 6.0\webapps\ViClientWebApp\WEB-INF\Web.xml is not valid. The element declaration was not found for root element <Web-app>. Error location: Web-app Details cvc-elt.1: The element declaration was not found for root element <Web-app>. The web.xml i used is the one you provide in the tuto: <?xml version="1.0" encoding="ISO-8859-1"?> <Web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>VI Client Plugin Demo App</display-name> <description> VI Client Plugin Demo App with Tomcat and VI Java API</description> <servlet> <servlet-name>TestServlet</servlet-name> <servlet-class>TestServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>TestServlet</servlet-name> <url-pattern>/TestServlet</url-pattern> </servlet-mapping> </Web-app> I get this warning too in Eclipse: Description Resource Path Location Type The serializable class TestServlet does not declare a static final serialVersionUID field of type long TestServlet.java /ViClientWebApp/WEB-INF/src line 16 Java Problem
Jul 16, 2009 6:51 AM
acnsys says:
in response to: acnsys
Nevermind, found the answer myself.
Jul 29, 2009 12:30 PM
gilsharon says:
Can you please add the xml file to use when registering this extension?
Aug 11, 2009 12:46 PM
ejohannes says:
There are a couple of capitalization problems in the document related to the web.xml file that caused me some difficulties. |
Great guide. Do you have or know of a version for DotNet? I'm looking for code to 1) login with the given SessionId and 2) MorUtil.createExactManagedEntity.