Rising Sun

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  148 随笔 :: 0 文章 :: 22 评论 :: 0 Trackbacks

 The VMware vSphere Web Services SDK includes all the components necessary to work with the VMware vSphere API, including WSDL files, sample code, and libraries. The vSphere Web Services SDK facilitates development of client applications that target the VMware vSphere API. With the vSphere Web Services SDK, developers can create client applications to manage, monitor, and maintain VMware vSphere components, as deployed on VMware®VMware vSphere®ESX®, ESXi™, and VMware®vCenter™ Server systems.

这是官方对vSphere Web Services SDK的介绍,简单来说就是提供了管理vcenter,ESXi的程序接口,目前支持JAVA和.NET平台,下面以windows 7平台为例,介绍JAVA开发环境的部署过程

一、开发环境准备

1、安装JAVA开发环境 J2SE 1.6 b22

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u22-oth-JPR

安装到c:\java下,不要安装到C:\program files下,目录中有空格,执行脚本的时候会报错

 

2、安装SOAP工具JAX-WS2.1

http://jax-ws.java.net/2.1.1/index.html

双击安装即可

 

3、下载vSphere Web Services SDK 5.1

http://communities.vmware.com/community/vmtn/developer/downloads

解压到c:\devprojects下

 

二、开发环境配置

1、设置系统变量

JAVA_HOME=C:\java\jdk1.6.0_22

JAVAHOME=C:\java\jdk1.6.0_22

SDKHOME=C:\devprojects

VMKEYSTORE=C:\VMware-Certs\vmware.keystore(稍后介绍安装过程)

WEBHOME=C:\devprojects\vsphere-ws\java\Axis\lib\wbem.jar

WS_SDK_HOME=C:\devprojects\SDK\vsphere-ws

CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;C:\devprojects\SDK\vsphere-ws\java\JAXWS\lib\samples.jar;C:\devprojects\SDK\vsphere-ws\java\JAXWS\lib\vim25.jar(这个变量很重要)

 

2、服务器认证

2.1、将ESX Server或Vcenter的证书导入本机,ESXi的证书在/etc/vmware/ssl/rui.crt;Vcenter的证书在C:/Documents and Settings/All Users/Application Data/VMware/VMware VitualCenter/SSL/rui.crt

2.2、证书拷贝到本机的C:/VMware-Certs目录下,打开windows7的命令行界面,切换到C:/VMware-Certs目录下,使用jdk的keytool工具导入证书:

keytool -import -file <certificate-filename> -alias <server-name> -keystore vmware.keystore

其中certificate-filename为rui.crt,service-name可以为服务器的机器名或IP地址,运行成功后会在C:/VMware-Certs目录下生成vmware.keystore文件。

 

3、重新编译JAX-WS

如果你的安装的版本不是JDK 1.6 b22或者SOAP不是用 JAX-WS2.1,就需要重新编译

打开CMD,切换到C:\devprojects\SDK\vsphere-ws\java\JAXWS\

运行build.bat

运行成功会出现会出现

Generating stubs from wsdl
 
Compiling stubs.
...
Done
 
三、运行简单的客户端脚本以验证安装成功
 
打开CMD,切换到C:\devprojects\SDK\vsphere-ws\java\JAXWS\
 
run.bat com.vmware.general.SimpleClient --urlhttps://yourFQDNservername/sdk --username  username --password password,如下输出表示配置SDK成功
 
 
 
四、错误调试
1、如果出现找不到类的错误,ClassNotFoundException:........,可以这样
 
打开CMD,切换到C:\devprojects\SDK\vsphere-ws\java\JAXWS\
 
java -Djavax.net.ssl.trustStore=%VMKEYSTORE% com.vmware.general.SimpleClient--url https://example.com/sdk --username pubs --password ***
 
2、如果提示JAVA虚拟机的内存不够,可以这样
 
java -Djavax.net.ssl.trustStore=%VMKEYSTORE% -Xms 512M -XMx1024M com.vmware.general.SimpleClient--url https://example.com/sdk --username pubs --password ***
posted on 2013-07-31 18:41 brock 阅读(880) 评论(0)  编辑  收藏 所属分类: 云计算

只有注册用户登录后才能发表评论。


网站导航: