Hexagon Geospatial
MENU

WebGIS

Need a push in the right direction when configuring WebMap, Portal or SDI services? Looking for hints and tips, or just looking for Ideas and information? The WebGIS discussion board is where you start those discussions, connect and share information.
Showing results for 
Search instead for 
Do you mean 
Reply
Staff
Posts: 98
Registered: ‎02-10-2017
Accepted Solution

Upgrade Web Services - Batch

[ Edited ]

Hi.

 

IHAC that was over 2000 services (WMS, WFS, WMPS, etc...) in 2013 version.

We're starting to migrate the solution to 2018 version and I need to upgrade those services.

Anyone know if there is a way to do it without going to the Administration Console and manually click in the upgrade version button?

Some kind of a command line that we can use to create a batch for all services to be upgraded...

 

The Data Sources associated to those services should also be upgraded.

 

Best regards,

António

Technical Evangelist
Posts: 1,101
Registered: ‎09-11-2015

Re: Upgrade Web Services - Batch

Hi Antonio,

 

I don't think that this is possible because the upgrade button calls internal methods on the Administration Console Service and its interface isn't documented.

 

I would be very careful by doing this upgrade since it's an upgrade over 3 major versions. The web.config files may have changed fundamentally on some services and just the usage of the Upgrade button might not lead to good results. Customer should anyway test each single service after doing the upgrade. Original files are being backed up in case there appears an error.

 

Standard web services such as WMS, WFS, WMTS will be probably easy to do, but I'd be very cautious with Portals. Note that Portals need specific upgrade approach, incl. backing up the maps ans workspaces.

 

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Staff
Posts: 98
Registered: ‎02-10-2017

Re: Upgrade Web Services - Batch

Thanks Jan.

 

I'm not worried with upgrading Portals because those I'll do manually. We've some customizations that needs to be migrated, so that issue doesn't bother me.

My problem is the services. There are, like I said, over 2000 and doing it manually isn't feasible. We would spend to many days doing that.

 

Best regards,

Technical Evangelist
Posts: 1,101
Registered: ‎09-11-2015

Re: Upgrade Web Services - Batch

I found, that it's possible to do using PowerShell and web request calls to AdminConsole (verified by Fiddler)

 

You can use following sample script to call an upgrade of selected instance name:

$username = "Administrator"
$password = "Qwert123" | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username,$password)

$res = Invoke-WebRequest http://win2016/AdminConsole/App/Services/UpgradeService?serviceName=WMS -Credential $cred -MaximumRedirection 0

Only thing needed is a list of instance names and then you can run the script above in a loop. I found a nice sample for searching through registry: https://gallery.technet.microsoft.com/scriptcenter/Search-Registry-Find-Keys-b4ce08b4

 

After registering this function in PS, you simply call:

Search-Registry -Path "HKLM:\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances" -Recurse -ValueDataRegex "WMS|WFS|WMTS"

Sample output:

Key                                                                                      Reason
---                                                                                      ------
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances\WFS       ValueData
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances\WFSPOINTS ValueData
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances\WMS       ValueData
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances\WMS-SEC   ValueData
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances\WMS-US    ValueData
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances\WMSFacade ValueData

After some playing-around, you should be able to put things together.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Technical Evangelist
Posts: 1,101
Registered: ‎09-11-2015

Re: Upgrade Web Services - Batch

[ Edited ]

Resulting script would be something like this (requires some fine tuning)

function UpgradeInstances{
   $username = "Administrator"
   $password = "Qwerty123" | ConvertTo-SecureString -asPlainText -Force
   $cred = New-Object System.Management.Automation.PSCredential($username,$password)

   $Path = "HKLM:\SOFTWARE\WOW6432Node\Intergraph\Geospatial Server\Instances"
   # put your search pattern here:
   $ValueDataRegex = "WMS|WFS|WMTS" 

   foreach ($CurrentPath in $Path) { 
   Get-ChildItem $CurrentPath |  
      ForEach-Object { 
         $Key = $_ 

         if ($ValueDataRegex) {  
            Write-Verbose ("{0}: Checking ValueDataRegex" -f $Key.Name) 
    
            if (($Key.GetValueNames() | % { $Key.GetValue($_) }) -match $ValueDataRegex) {  
               Write-Verbose "  -> Match!" 
               $InstanceName = ($Key.Name).Substring(($Key.Name).LastIndexOf("\")+1,($Key.Name).Length-($Key.Name).LastIndexOf("\")-1)               
               $request = $null
               Try {
                  $request = Invoke-WebRequest "http://win2016/AdminConsole/App/Services/UpgradeService?serviceName=$InstanceName" -Credential $cred -MaximumRedirection 0 -ErrorAction SilentlyContinue
               }
               # Catching 302 redirects done by the UpgradeInstance request
               catch [System.Net.WebException] {
                  $request = $_.Exception.Response
               }
               catch {
                  Write-Error $_.Exception
                  return $null
               }
               
               return [PSCustomObject] @{                   
                  Upgraded = $InstanceName
                  Status = $request.StatusCode
               } 
            } 
         } 
      } 
   } 
}
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Staff
Posts: 98
Registered: ‎02-10-2017

Re: Upgrade Web Services - Batch

Jan,

 

Thanks for all the help.

 

I'll do some tests and let you know if it worked.

 

Best regards,

António

Staff
Posts: 98
Registered: ‎02-10-2017

Re: Upgrade Web Services - Batch

Jan,

 

Once again thanks for your inputs.

Based on your idea I created a C# command to execute the upgrade of the services.

It seems to worked. I've to finish it to put some validations and other stuff but in the tests that I did it upgraded from 16.05.0000 to 16.05.0100.

 

Best regards,

António

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.