Forum Discussion

kacole2's avatar
kacole2
New Contributor
12 years ago

Uber Complex SOAP connection to VMware Site Recovery Manager

Hi everyone,
Over the past few days, I've struggled to try and get SoapUI to connect to my VMware SRM instance. I hate asking for handouts, but i'm realizing this is no easy task and maybe i'm in over my head.

I've reviewed the documentation and it's very little help because there are only C# and Java example snippets - http://www.vmware.com/support/developer ... 50_api.pdf

I was given a Powershell script from a colleague of mine that successfully connects to my VMware Site Recovery Manager instance. Essentially, I need to take this Powershell script and figure out how I can take the pieces and create a successful connection to my VMware Site Recovery Manager. It also grabs all the protection groups and lists them.


$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

$protectionGroupList = @();

#Get Information about the ProtectionGroups and combine them
ForEach ($protectionGroup in $SrmObject.SRMService.ListProtectionGroups($SrmObject.SRMContent.Protection)) {

Write-Host "Fetching ProtectionGroupInfo"
$protectionGroupInfo = $SrmObject.SRMService.GetInfo($protectionGroup)

Write-Host "Fetching VMs for ProtectionGroup"
$protectedVms = $SrmObject.SRMService.listProtectedVms($protectionGroup)
$customProtectionGroupInfo = New-Object System.Object
$customProtectionGroupInfo | Add-Member -Name ProtectionGroupMoRef -Value $protectionGroup -MemberType NoteProperty -PassThru
$customProtectionGroupInfo | Add-Member -Name ProtectionGroupInfo -Value $protectionGroupInfo -MemberType NoteProperty -PassThru
$customProtectionGroupInfo | Add-Member -Name ProtectedVms -Value $protectedVms -MemberType NoteProperty -PassThru

$protectionGroupList += $customProtectionGroupInfo
}

Write-Host "=== Results ==="
Write-Host "-----"
ForEach ($pg in $protectionGroupList) {
Write-Host "ProtectionGroup Name: " $pg.protectionGroupInfo.name
Write-Host "Description De: " $pg.protectionGroupInfo.description
Write-Host "Replication Type: " $pg.protectionGroupInfo.type
ForEach ($vm in $pg.protectedVms) {
Write-Host " VM MoId: " $vm.vm.value
Write-Host " Protection State: " $vm.state
Write-Host " Peer State: " $vm.peerState
Write-Host " needs configuration: " $vm.needsConfiguration
Write-Host " ----"
}
Write-Host "---"
}

$srm.SrmLogoutLocale($srmSvcRef);


I can successfully import the WSDL file (https://srm-vcenter-a:8095/srm-Service?wsdl) and all the request types get populated. To do anything a successful login must be authenticated using SrmLoginLocale. However, there is one specific object that I don't understand and that is the "ManagedObjectReference". The ManagedObjectReference is necessary on almost every single operation and I'm not sure where or how to populate that information. Every time i run a SoapUI request, I get a 500 Internal Server Error.

http://kendrickcoleman.com/free/SRMsoapui.png


In an effort to assist with troubleshooting, I have opened up my VMware SRM instance to the web and opened ports 8095 and 9007. This is a home lab environment, so there's no security or confidential information to expose.

From the documentation:
8095 SOAP vCenter Server and vSphere Client SRM From the vCenter Server proxy to the SRM Server (intrasite only).
9007 TCP SRM External API Client SRM Used by external API clients for task automation.

you can access the wsdls here:
https://srmtrial.no-ip.org:8095/srm-Service?wsdl
https://srmtrial.no-ip.org:8095/srm?wsdl

I created an account for a SRM administrator. you should be able to use the following credentials. username "srmtrial" and password "srmtrial". if you need FQDN, the domain is "KENDRICKCOLEMAN".

Thanks for any and all help
  • kacole2's avatar
    kacole2
    New Contributor
    I don't believe that will work. From the documentation:

    Connecting to an SRM Server
    Programs connect to an SRM server using the SrmLoginLocale API, or to SRM servers at both the protected site and the recovery site using the SrmLoginSites API.
    Managed Object Reference
    SRM methods take a managed object reference _this, which references the SessionManager used for making method calls. Programs obtain _this by retrieving content of the ServiceInstance, which is accomplished by creating a new managed object reference of type SrmServiceInstance.
    Example 3-1. C# code to create SrmServiceInstance
    public SvcConnection(string svcRefVal)
    {
    ...
    _svcRef = new ManagedObjectReference();
    _svcRef.type = "SrmServiceInstance";
    _svcRef.Value = svcRefVal;
    }
    ...
    SrmLoginLocale
    This method logs in to the SRM server. The Connect public method requires the URL of an SRM server and authentication credentials. The SrmLoginLocale method takes the _srcRef managed object reference from SrmServiceInstance, and fails if the user name and password combination is invalid, or if the user is already logged in. In these examples, a locale string could be provided instead of the null parameter.
    Example 3-3. C# code for SRM login
    protected SrmService _service;
    protected SrmServiceInstanceContent _sic;
    protected ManagedObjectReference _svcRef;
    ...
    public void Connect(string url, string username, string password)
    {
    _service = new SrmService();
    _service.Url = url;
    _service.Timeout = 600000;
    _service.CookieContainer = new System.Net.CookieContainer();
    _sic = _service.RetrieveContent(_svcRef);
    _service.SrmLoginLocale(_svcRef, username, password, null);
    ...
    }
  • andrey64's avatar
    andrey64
    Occasional Visitor

    Where you ever able to get this developed ?

     

    I am facing the same issue where I am attempting to connect to my VMware Site Recovery Manager using Groovy but keep running into numerous issues(limited knowledge as well).

     

     

    Would really help if you can share what you ended up doing.

     

    Thank you!

    • nmrao's avatar
      nmrao
      Champion Level 3
      Can you please add the details and explain your issues clearly? Use screen shots if required.