Skip to content

Instantly share code, notes, and snippets.

@flq flq/GetWSDLs.ps1
Created Aug 17, 2017

What would you like to do?
Acccess discovery service, download all WSDLs for listed services
function indent([parameter(ValueFromPipeline)]$Content)
$StringWriter = New-Object System.IO.StringWriter
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter
$xmlWriter.Formatting = "indented"
$xmlWriter.Indentation = 2
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

This comment has been minimized.

Copy link
Owner Author

flq commented Aug 17, 2017

Parallel to this script there is a config.json file that contains the properties user, pwd and the discovery url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.