我是肥皂新手,但几天来我一直在努力解决这个问题,我不知道自己哪里出了问题。我正在尝试使用Ruby与VMware站点恢复管理器对话
我有一个powershell脚本,可以成功地用于登录。我想用这个powershell脚本用红宝石重写它。
以下是wsdl文件:
https://srm-vcenter-a:8095/srm?wsdlhttp://pastebin.com/xJ6AwLaC
https://srm-vcenter-a:8095/srm-Service?wsdlhttp://pastebin.com/nmH5mzdH
powershell代码
$Server = "srm-vcenter-a"
$UserName = "administrator"
$Password = "mypw"
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
Write-Host "Connecting to SRM"
$webSvc = New-WebServiceProxy ("https://" + $Server + ":8095/srm-Service?wsdl") -Namespace SRM
$srm = New-Object SRM.SrmService
$srm.Url = "Https://" + $Server + ":9007"
$srm.Timeout = 600000
$srm.CookieContainer = New-Object System.Net.CookieContainer
$srmSvcRef = New-Object SRM.ManagedObjectReference
$srmSvcRef.Type = "SrmServiceInstance"
$srmSvcRef.Value = $srmSvcRef.Type
$srmSvcContent = $srm.RetrieveContent($srmSvcRef)
$srm.SrmLoginLocale($srmSvcRef, $UserName, $Password, $null)
$srmObject = New-Object System.Object
$srmObject | Add-Member -Type NoteProperty -value $Server -Name SRMServer
$srmObject | Add-Member -Type NoteProperty -value $srm -Name SRMService
$srmObject | Add-Member -Type NoteProperty -value $srmSvcContent -Name SRMContent
...我试过使用Savon、soap4r和handsoap,我不知道我错过了什么。
以下是不起作用的Savon代码。
require 'savon'
require 'rubygems'
client = Savon.client do
wsdl "https://srm-vcenter-a:8095/srm?wsdl"
#endpoint "https://srm-vcenter-a:8095/srm-Service?wsdl"
endpoint "http://srm5-vcenter-a:9007"
namespace "https://srm-vcenter-a/sdk/srm"
#proxy "https://srm-vcenter-a:8095/srm-Service?wsdl"
ssl_version :TLSv1
ssl_verify_mode :none
convert_request_keys_to :lower_camelcase
end
message = { username: 'administrator', password: 'mypw' }
response = client.call(:srm_login_locale, message: message)提前感谢您的帮助
发布于 2013-12-11 00:38:21
简单地看了一下您的代码之后,在PowerShell中您似乎已经
$srm.SrmLoginLocale($srmSvcRef, $UserName, $Password, $null)而在Ruby你有
message = { username: 'administrator', password: 'mypw' }
response = client.call(:srm_login_locale, message: message)在PowerShell代码中,有4个值传递给SrmLoginLocale方法:
在ruby代码中,您在调用中缺少了第一个参数和第四个参数。尝试在红宝石中创建等效的$srmSvcRef。我不是一个ruby程序员,但我认为代码应该类似于:
srm_svc_ref = { value: 'SrmServiceInstance', type: 'SrmServiceInstance'}
message = { _this: srm_svc_ref, username: 'administrator', password: 'mypw', locale: nil}
response = client.call(:srm_login_locale, message: message)https://stackoverflow.com/questions/20437950
复制相似问题