Using SOAP Webservices

by Nov 29, 2021

Even though SOAP hasn’t been used widely for public webservices (in favor of more simplistic REST services), internally many companies do use SOAP for their webservices.

PowerShell comes with excellent SOAP support so you don’t need a lot of complex code to connect to and utilize SOAP webservices. Here is one of the few remaining free public SOAP webservices (translating a German “bankleitzahl” into the bank details):

$o = New-WebServiceProxy -Uri

As you see, to get started with SOAP webservices you need the WSDL URL provided by the webservice. This web page returns the entire interface definition in XML format, and New-WebServiceProxy creates all the code from this information that you need to wrap the SOAP data types.

Once you have access to a (any) SOAP webservice, you can use the code below to examine its methods:

$o = New-WebServiceProxy -Uri

# common methods
$blacklist = 'CreateObjRef', 'Dispose', 'Equals', 'GetHashCode', 'GetLifetimeService', 'InitializeLifetimeService', 'ToString', 'GetType'

# exclude async and common methods
$o | Get-Member -MemberType *method | 
Where-Object Name -notlike '*Async*' | 
Where-Object Name -notlike 'Begin*' | 
Where-Object Name -notlike 'End*' |
Where-Object { $_.Name -notin $blacklist }

Twitter This Tip! ReTweet this Tip!