![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to call a web service from Power Shell Hello, can you give me a hint about how to call a web service using PS ? I know .NET is supposed to be integrated with web services standards and that I can access .NET objects from Power Shell Thanks in advance, Nicola Attico |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to call a web service from Power Shell "Nicola Attico" <NicolaAttico@discussions.microsoft.com> wrote in message news:F589D99A-AB34-4A00-A080-24B8D560963A@microsoft.com... > Hello, > > can you give me a hint about how to call a web service using PS ? > > I know .NET is supposed to be integrated with web services standards and > that I can access .NET objects from Power Shell In order to do this you will need to setup PS environment to enable VS 2005 tools. Just "dot" the attached PS1 script into your shell and that should work assuming you have VS 2005 installed. Now here's how to acces one particular web service. Note that the first two lines create a proxy assembly which takes care of the communication to the web service. On line 3 and 4 we load the assembly and then create the WeatherForecast proxy object. Then on line 5 we call one of its methods. It returns an XML document which we store in $forecast. BTW, you can use Reflector or VS's Object Browser to see the other methods in the assembly (or you can load up the WeatherForecast.cs file to see the nitty gritty proxy details). PoSH 1> wsdl.exe http://www.webservicex.net/WeatherForecast.asmx?WSDL PoSH 2> csc /t:library WeatherForecast.cs PoSH 3> [Reflection.Assembly]::LoadFrom("$pwd\WeatherForecast.dll") PoSH 4> $weatherService = new-object WeatherForecast PoSH 5> $forecast = $weatherService.GetWeatherByZipCode(80526) PoSH 6> $forecast Latitude : 40.54729 Longitude : 105.1076 AllocationFactor : 0.008857 FipsCode : 08 PlaceName : FORT COLLINS StateCode : CO Status : Details : {WeatherData, WeatherData, WeatherData, WeatherData...} PoSH> $forecast.Details |select Day, MaxT*F, MinT*F Day MaxTemperatureF MinTemperatureF --- --------------- --------------- Thursday, June 15, 2006 84 54 Friday, June 16, 2006 80 50 Saturday, June 17, 2006 85 55 Sunday, June 18, 2006 91 58 Monday, June 19, 2006 95 59 Tuesday, June 20, 2006 94 58 Wednesday, June 21, 2006 90 56 See it gets a bit warmer here in Colorado than some folks would suspect. :-) Enjoy! -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | RE: How to call a web service from Power Shell Mow did 3-part series on "Search with MSNSearch Web API from MSH. 1. http://mow001.blogspot.com/2006/02/s...-from-msh.html 2. http://mow001.blogspot.com/2006/02/s...om-msh_02.html 3. http://mow001.blogspot.com/2006/02/c...arch-from.html |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to call a web service from Power Shell "Keith Hill [MVP]" wrote: [..skip..] > Now here's how to acces one particular web service. [..skip..] Thanks folks! this really gave me a great insight! Nicola Attico |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Power Shell? | PowerShell | |||
| Power Shell no arranca | PowerShell | |||
| power shell in a script | PowerShell | |||
| Executing Power Shell Scripts from Windows Shell | PowerShell | |||
| power shell in x64 | PowerShell | |||