Created
August 17, 2017 08:23
-
-
Save flq/353119dd5471e3e08d1b6375d2a29f8b to your computer and use it in GitHub Desktop.
Acccess discovery service, download all WSDLs for listed services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function indent([parameter(ValueFromPipeline)]$Content) | |
{ | |
$StringWriter = New-Object System.IO.StringWriter | |
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter | |
$xmlWriter.Formatting = "indented" | |
$xmlWriter.Indentation = 2 | |
$Content.WriteContentTo($XmlWriter) | |
$XmlWriter.Flush() | |
$StringWriter.Flush() | |
Write-Output $StringWriter.ToString() | |
} | |
$cfg = ConvertFrom-Json -InputObject (gc .\config.json -Raw) | |
$webclient = new-object System.Net.WebClient | |
$webclient.Credentials = new-object System.Net.NetworkCredential($cfg.user, $cfg.pwd) | |
[xml]$doc = $webclient.DownloadString($cfg.discovery) | |
$doc.discovery.contractRef.ref | % { | |
$u = $_ | |
$name = $_.Substring($_.LastIndexOf("/") + 1) | |
Write-Host "Get WSDL For $name" -ForegroundColor Cyan | |
Try { | |
[xml]$webclient.DownloadString($_) | indent | Out-File -FilePath "$name.wsdl" | |
} | |
Catch { | |
Write-Host "Could not download from $u : $_.Exception.Message" -ForegroundColor Yellow | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parallel to this script there is a config.json file that contains the properties
user
,pwd
and thediscovery
url.