How do I access a web service from PowerShell?

.net, powershell, web-services, windows

Solution

# Working example of how to use PowerShell (version >= 2) to access a web service.
$svc = New-WebServiceProxy –Uri ‘http://www.webservicex.net/stockquote.asmx?WSDL’

$svc | Get-Member  # Use Get-Member to discover the interface of a web service.
# Get stock quotes. 
$svc.GetQuote(‘BA’)   # Boeing
$svc.GetQuote(‘AMZN’) # Amazon
$svc.GetQuote(‘SBUX’) # Starbucks

Problem

I'd like to access a web service with a given (simple) WSDL from within Windows PowerShell. Is there an easy way to do this?

Original source