使用SoapUI调用Vsphere Web Service
项目中经常需要调用Webservice进行验证测试,下面就介绍下如何使用测试工具SoapUI调用Vsphere vcenter的 Web Service
VSphere的Webservice地址默认为 https://vcenterip/sdk/vimService
1 首先要进行认证。使用Login方法,获取合法Cookie
Request内容如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header/>
<soapenv:Body>
<urn:Login>
<urn:_this type="SessionManager">SessionManager</urn:_this>
<urn:userName>administrator@vsphere.local</urn:userName>
<urn:password>密码</urn:password>
<!--Optional:-->
<urn:locale>?</urn:locale>
</urn:Login>
</soapenv:Body>
</soapenv:Envelope>
Response内容如下:
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<LoginResponse xmlns="urn:vim25">
<returnval>
<key>52c8ab58-eb03-e526-c733-5051d62652b6</key>
<userName>VSPHERE.LOCAL\Administrator</userName>
<fullName>Administrator vsphere.local</fullName>
<loginTime>2016-08-15T09:19:39.526713Z</loginTime>
<lastActiveTime>2016-08-15T09:19:39.526713Z</lastActiveTime>
<locale>?</locale>
<messageLocale>zh_CN</messageLocale>
<extensionSession>false</extensionSession>
<ipAddress>10.200.108.92</ipAddress>
<userAgent>Apache-HttpClient/4.1.1 (java 1.5)</userAgent>
<callCount>0</callCount>
</returnval>
</LoginResponse>
</soapenv:Body>
</soapenv:Envelope>
注意:需要记录response中的header信息,用于后面设置header,我这里的header信息如下
Set-Cookie vmware_soap_session="52f2ce6a-8ce9-94cc-bd62-3f750d61cd4f"; Path=/; HttpOnly; Secure;
2 然后我使用FindByDnsName方法,获取一台机器的ManagedObjectID
Request内容如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<urn:FindByDnsName>
<urn:_this type="SearchIndex">SearchIndex</urn:_this>
<!--Optional:-->
<urn:dnsName>testupgrade</urn:dnsName>
<urn:vmSearch>true</urn:vmSearch>
</urn:FindByDnsName>
</soapenv:Body>
</soapenv:Envelope>
注意上面xml中<urn:_this type="SearchIndex">SearchIndex</urn:_this>红色字体是根据文档中的定义填写的
然后添加header,作为认证信息,此处的cookie中填写的是,认证时response中的Set-Cookie ,具体如下图

执行成功,Response的内容如下:
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<FindByDnsNameResponse xmlns="urn:vim25">
<returnval type="VirtualMachine">vm-2823</returnval>
</FindByDnsNameResponse>
</soapenv:Body>
</soapenv:Envelope>
3 调用VSphere 其他的Webservice的方式也一样
如果你设置的Header不对,那么系统将会报错:
faultstring:The session is not authenticated
参考:
soapUI: faultstring: The session is not authenticated
使用SoapUI调用Vsphere Web Service的更多相关文章
- 翻译-使用Spring调用SOAP Web Service
原文链接: http://spring.io/guides/gs/consuming-web-service/ 调用SOAP web service 本指南将指导你使用Spring调用一个基于SOAP ...
- Spring Boot发布和调用RESTful web service
Spring Boot可以非常简单的发布和调用RESTful web service,下面参考官方指导体验一下 1.首先访问 http://start.spring.io/ 生成Spring Boot ...
- IGS_学习笔记08_IREP通过soapUI测试客户化Web Service调用(案例)
20150819 Created By BaoXinjian
- SoapUI软件-测试Web Service接口
一.新建项目 New SOAP Project Project Name填入项目名称:Initial WSDL中填入接口地址,或后缀为.wsdl的文件:OK: 添加后可在左侧看到接口详情: 二.测试接 ...
- Java与WCF交互(二):WCF客户端调用Java web service【转】
原文:http://www.cnblogs.com/downmoon/archive/2010/08/25/1807982.html 在上篇< Java与WCF交互(一):Java客户端调用WC ...
- 转载——Java与WCF交互(二):WCF客户端调用Java Web Service
在上篇< Java与WCF交互(一):Java客户端调用WCF服务>中,我介绍了自己如何使用axis2生成java客户端的悲惨经历.有同学问起使用什么协议,经初步验证,发现只有wsHttp ...
- VMware 虚拟化编程(3) —VMware vSphere Web Service API 解析
目录 目录 前文列表 VMware vSphere Web Services API VMware vSphere Web Services SDK vSphere WS API 中的托管对象 Man ...
- cxf动态调用外部web service 报告异常java.lang.NoSuchFieldError: QUALIFIED
原因:cxf 依赖的xmlschema-core 与xfire-all依赖的xmlschema冲突.(百度搜索亦得知:cxf 依赖的xmlschema-core 与axis2-kernel依赖的xml ...
- cxf动态调用外部web service 报告异常java.lang.NoSuchFieldErr
原因:cxf 依赖的xmlschema-core 与axis2-kernel依赖的xmlschema冲突. 解决方法:因为在项目中只用cxf即可,所以删除axis2的依赖.
随机推荐
- sqlserver资源
1.数据库“高可用性”和“灾难恢复”技术 参考: niyi0318的专栏
- 云服务器 远程mysql 无法连接
问题:mysql不管是用免安装版的,还是用直接安装的,还是用phpStudy直接发布的mysql服务.都只能用localhost登录,不能用服务器的ip进行远程访问 遇到这个问题.按照网上大家介绍的方 ...
- Chris Richardson微服务翻译:构建微服务之使用API网关
Chris Richardson 微服务系列翻译全7篇链接: 微服务介绍 构建微服务之使用API网关(本文) 构建微服务之微服务架构的进程通讯 微服务架构中的服务发现 微服务之事件驱动的数据管理 微服 ...
- zz:linux下rz,sz的安装方法
zz:http://xukaizijian.blog.163.com/blog/static/1704331192011611104631875/ wget http://ohse.de/uwe/re ...
- 借助Redis做秒杀和限流的思考
最近群里聊起秒杀和限流,我自己没有做过类似应用,但是工作中遇到过更大的数据和并发. 于是提出了一个简单的模型: var count = rds.inc(key); if(count > 1000 ...
- Zabbix实战-简易教程--拓扑图(Maps)
一.拓扑图(Maps) 二话不说,有图有真相,先看看效果,再详细讲解配置过程: 图1:全国网络质量图 图2 核心机房网络质量图 二.详细配置 1.添加 map 选择 系统管理-->基础配置-- ...
- 工具:从一个文件夹中复制jar到另一个文件夹中
工具类:从一个文件夹中复制jar到另一个文件夹中 需要的小伙伴可以试一试,很爽哦,有时候真的很需要! 需求:当我们拿到一个maven项目时,而maven项目的jar包都是通过pom.xml文件管理的, ...
- MQTT Server搭建(apache-apollo)和MQtt Client搭建
目标 本文就MQTT server和client搭建做以下总结,方便测试及开发使用,能基于MQTT软件发送和接收消息. 介绍 MQTT是基于tcp的消息发送,目前JAVA方面有两种实现,分别是mqtt ...
- poj 3261
Milk Patterns Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 13249 Accepted: 5894 Ca ...
- 2017"百度之星"程序设计大赛 - 复赛1001&&HDU 6144 Arithmetic of Bomb【java大模拟】
Arithmetic of Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...