rubyscriptingpowershellsavonsoap4r

Consuming Web Services with Ruby/Powershell


Currently I am using Ruby as the core programming language for Configuration Management support. Since the new release of Ruby (1.9.3) i was not able to use gem configuration to consume web services using NTLM authentication. This is my gem configuration using ruby 1.9.1.

httpclient (2.2.3)
nokogiri (1.5.0 x86-mingw32)
ocra (1.3.0)
rake (0.9.2.2)
rubysspi (1.3.1)
soap4r (1.5.8)
test-unit (2.4.0)
trollop (1.16.2)
win32-api (1.4.8 x86-mingw32)
win32-eventlog (0.5.2.fix)
windows-api (0.4.0)
windows-pr (1.2.1)

I always try to keep things simple but certainly i can not keep up with the updates. I was thinking instead of using a full ruby implementation for configuration management support, may be is time to use microsoft(which i dont like at all) scripting engine(powershell) to run specific microsoft task without creating dependencies to more and more gems and making it so difficult to maintain and update. Originally, i was thinking to create a c# console tool for certaing tasks but i found about powershell. I tried to use soap4r and does not work on the 1.9.3 but it works on 1.9.1(custom fixed gem). I tried savon gem but with no successful results for NTLM authentication. May be it is time to use a combination of two scripting engines to keep it maintainable. Any thoughts.


Solution

  • Only you understand your big picture, but in PowerShell, if you want to call a web service secured with NTLM, it's as easy as:

    # call webservice using the current user's credentials
    $proxy = new-webserviceproxy $url -usedefaultcredential
    $result = $proxy.method($param1, $param2)
    

    If you want to prompt for credentials, use get-credential