zoukankan      html  css  js  c++  java
  • vmware开发包之vSphere Management SDK

    原文地址:http://www.cnblogs.com/yuefei/p/3600441.html

    原文写的挺好的,我这里增加了一些细节。来帮助像我这样的小白,明明按照说明来,可还是不对

    准备:

    vSphere Management SDK

    Microsoft Visual Studio 2008

    Web Services Enhancements (WSE) 3.0 for Microsoft .NET

    .net framework v2.0 sdk

     MicrosoftSqlServerSString

    注意:

        .net framework v2.0 sdk 不是 .net framework v2.0
        .net framework v2.0 sdk要安装自己的对应版本,如64位系统,安装32的.net framework v2.0 sdk是没有用的
        安装Web Services Enhancements (WSE) 3.0 for Microsoft .NET选择custom
        

     

    Management SDK说明:

    vSphere Management SDK关于vmware管理等相关功能的.net和java的代码示例。

    在其5.5的解压包中

    eam:esx agent management表示esx虚机生产环境的代理

    sms:storage monitoring management存储监控

    spbm:storage policy based management存储策略

    ssoclient:客户端单点登录验证

    vsphere-ws:web service api

    当打开sample解决方案时会发现缺失一些dll文件。

    对于Microsoft.Web.Services3.dll是微软wse3.0中的一个dll文件,可以用它来生产安全的web服务。

    安装Web Services Enhancements (WSE) 3.0 for Microsoft .NET后叹号即可消失

    解决办法:

    Vim25Service.dll

    Vim25Service.XmlSerializers.dll

    当然在vSphere Management SDK开发包中也提供了基于web的服务接口,在...SDKvsphere-wswsdlvim25目录下,可以通过wse工具生成dll文件。

    关于wse工具安装配置,安装运行时、工具集和vs工具这三个选项。

    这里提供两种编译方式,一种是通过tool工具中的WseWsdl3.exe,一种是vs扩展工具。

     安装完成后,打开vs的dos窗口,依次执行下方几个步骤。

    生成Vim25Service.dll和Vim25Service.XmlSerializers.dll

    1.生成cs文件。

    wsdl.exe /n:Vim25Api /o:d:sdkdllVimService.cs d:sdkdllvimService.wsdl d:sdkdllvim.wsdl

    2.编译cs文件(生成Vim25Service.dll)。

    csc /t:library /out:d:sdkdllVim25Service.dll d:sdkdllVimService.cs

    3.生成序列化文件(Vim25Service.XmlSerializers.dll)。这一过程需要比较长的时间。

    sgen /p d:sdkdllVim25Service.dll

    4.到这里还没有结束

    我们打开wsdl编译的文件VimService.cs:

     
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="VimBinding", Namespace="urn:vim25")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(ReadEnvironmentVariableInGuestRequestType))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(TerminateProcessInGuestRequestType))]
    ......
    public partial class VimService : System.Web.Services.Protocols.SoapHttpClientProtocol{
     

    于是我们注释掉所有[System.Xml.Serialization.XmlIncludeAttribute(typeof...,

    此步可以使用vs的全部替换功能来完成,大概有6478项,一定要用工具

    然后我们在

    public partial class VimService : System.Web.Services.Protocols.SoapHttpClientProtocol

    前面增加一行,内容如下

    [System.Xml.Serialization.XmlSerializerAssembly(AssemblyName = "VimService25.XmlSerializers")]。 

    生成STSService.dll

    1.cd到wse工具。

    cd C:Program Files (x86)Microsoft WSEv3.0Tools

    2.生成cs文件。此处在末尾加上所有wsdl文件。

    WseWsdl3.exe /o:c:STSService.cs /type:webClient c:	estSTSService.wsdl c:	estprofiled-saml-schema-assertion-2.0.xsd c:	estprofiled-saml-schema-assertion-2.0-extensions.xsd c:	estprofiled-saml-schema-assertion-2.0-types.xsd c:	estprofiled-sstc-saml-delegation.xsd c:	estprofiled-wsse-header.xsd c:	estprofiled-wss-wssecurity-utility-1.0.xsd c:	estprofiled-ws-trust.xsd c:	estws-addr.xsd c:	estws-trust-1.4-extensions.xsd c:	estxmldsig-core-schema.xsd

    3.编译cs文件。此处需要引用Microsoft.Web.Services3.dll。

    csc /t:library /out:c:STSService.dll c:STSService.cs /reference:"C:Program Files (x86)Microsoft WSEv3.0Microsoft.Web.Services3.dll"

    在编译STSService.dll的过程中可能会出现下图警告。这代表需要安装.net framework v2.0 sdk这么个东西,注意并非.net framework 2.0。

    安装完成重新引用生产的dll文件,这时候有点要注意,sample里面的项目采用.net framework 3.5,这取决于你编译dll的版本,可以更改项目版本或者采用对应的编译环境即可。

    另外在sample中有两种客户端登录方式。一种被称为过时的,实际上VMA代理实例,另一种就是SSO。

    不过SSO在sample的wsdl提供的api中却没有提供sso的接口。缺少部分类方法。所以注释掉sso的验证代码。

  • 相关阅读:
    [git 学习篇]自己在github创建一个远程服务器创库
    [git 学习篇]远程创库
    [git 学习篇]删除文件
    [git 学习篇] git checkout 撤销修改
    [git 学习篇]git管理的是修改,并非文件
    log4net面面观之Repository
    log4net面面观之工作原理
    asp.net获取当前页面文件名,参数,域名等方法。统一session验证和权限验证的方法
    C#使用Log4Net记录日志
    SharePoint 2010中的客户端AJAX应用——ASP.NET AJAX模板
  • 原文地址:https://www.cnblogs.com/wanghongxu/p/4613972.html
Copyright © 2011-2022 走看看