> I'm stuck trying to understand a "Missing authorization header" error
> when I try to access a VMware SOAP service using Ruby.
> First I fetched the wsdl from our Lab Manager machine to my local
> machine and ran wsdl2ruby.rb. It generated a bunch of files that I,
> being new to SOAP, don't really understand. I copied some code from
> the generated sample client and cut it back to a simple "list
> configurations" call. First it complained about "certificate verify
> failed", so I disabled certificate checking for the moment via this
> line.
> obj.optionshttp://'protocol.http.ssl_config.verify_mode' =
> OpenSSL::SSL::VERIFY_NONE
> I'll get back to certificates later (I tell myself), but now I've
> "missing authorization header" error. I haven't edited any of the
> generated code. I believe the namespace is "http://vmware.com/
> labmanager", but lines like this
> SOAPAction: "http://vmware.com/labmanager/ListConfigurations"
> make nervous. I found a class called AuthenticationHeader, but I can't
> figure out how/where to use it. The C# examples indicate the
> AuthenticationHeader should be part of the driver object.
> //**
> //** Allocate AuthenticationHeader object to hold caller’s
> //** username and password
> //**
> binding.AuthenticationHeaderValue = new
> LabManagerSoap.AuthenticationHeader();
> But I can't figure out how to translate that to the Ruby code
> generated by wsdl2ruby.rb.
> Here's the program...
> #!/usr/bin/env ruby
> require 'rubygems'
> gem 'soap4r'
> require 'defaultDriver.rb' #generated by wsdl2ruby.rb
> endpoint_url = nil
> obj = VMware_interfaceSoap.new(endpoint_url)
> obj.wiredump_dev = STDOUT #print all requests/repsonses to stdout
> obj.optionshttp://'protocol.http.ssl_config.verify_mode' =
> OpenSSL::SSL::VERIFY_NONE #disable certificate checking
> puts obj.listConfigurations(nil)
> Here's the request/response trace.
> = Request
> ! CONNECT TO x.y.com:443
> ! CONNECTION ESTABLISHED
> at depth 0 - 20: unable to get local issuer certificate
> POST /LabManager/SOAP/LabManager.asmx HTTP/1.1
> SOAPAction: "http://vmware.com/labmanager/ListConfigurations"
> Content-Type: text/xml; charset=utf-8
> User-Agent: SOAP4R/1.5.8 (/187, ruby 1.8.6 (2007-09-24)http://universal-darwin9.0)
> Date: Wed, 30 Apr 2008 23:44:50 GMT
> Content-Length: 373
> Host: x.y.com
> <?xml version="1.0" encoding="utf-8" ?>
> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <env:Body>
> <n1:ListConfigurations xmlns:n1="http://vmware.com/labmanager"
> xsi:nil="true"></n1:ListConfigurations>
> </env:Body>
> </env:Envelope>
> = Response
> HTTP/1.1 500 Internal Server Error
> Date: Wed, 30 Apr 2008 23:47:29 GMT
> Server: Microsoft-IIS/6.0
> X-Powered-By: ASP.NET
> X-AspNet-Version: 2.0.50727
> Cache-Control: private
> Content-Type: text/xml; charset=utf-8
> Content-Length: 370
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/
> XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</
> faultcode><faultstring>Missing authorization header</
> faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
> : Missing authorization header (SOAP::FaultError)