Dienstag, 22. Februar 2011

Powershell test Web Service

For all of you who haven't touched it yet - Microsoft has put an interesting shell to Windows operating systems called Powershell. Following code creates a web service stub (proxy in dot.net speak) and calls a method. If you call a web service that is running on a IIS you often need some kind of authentication.
#  build credential object 
$Pass = ConvertTo-SecureString " xxxx " –AsPlaintext –Force
$Cred = New-Object System.Management.Automation.PsCredential "domain\User",$Pass

# just a simple web service tester
$wsProxy = New-WebServiceProxy -Credential $Cred -URI http://yourserver.com/path?WSDL
$result = $wsProxy.WebServiceMethod('Parameter') 
$result


To use this example you need to replace WebServiceMethod with the web service method you want to use. It is up to you to provide proper parameters. Having a look into service's WSDL file will help here.

General note, execution of unsigend srcripts needs to be activated. Please see
http://www.windowsecurity.com/articles/PowerShell-Security.html for more information.

Keine Kommentare:

Kommentar veröffentlichen