From: Patrick Chanezon Date: 2005-07-02T17:46:56+09:00 Subject: Re: Adding a header to a SOAP request something like that works: that's what I use for the Google Adwords API. The soap4r sample for adwords has a bug, but the code below works. Just adapt it to your needs for the paypal headers. In my code headers is a hash with tag, value pairs. I load it from a yaml file but you can set it up the way you want. I hope this helps. --- wsdl = 'https://adwords.google.com/api/adwords/v2/CampaignService?WSDL' class HeaderHandler < SOAP::Header::SimpleHandler def initialize(tag, value) super(XSD::QName.new(nil, tag)) @tag = tag @value = value end #the initial handler from the sample was wrong, it generated 2 level of tags def on_simple_outbound @value end end require 'defaultDriver.rb' require 'yaml' prefs = YAML::load( File.open('adwords.yaml', 'r')) headers = prefs['headers'] drv = CampaignService.new() #problem: http protocol properties set in soap/property from rubyhome are not picked up drv.loadproperty('soap/property') #problem: wiredump_dev does not output anything when running in SSL mode #drv.wiredump_dev = STDOUT #the file based logger works drv.wiredump_file_base = "log" headers.each {|key, value| drv.headerhandler << HeaderHandler.new(key, value)} --- P@ On 6/27/05, David Teare wrote: > Hi all, > > I want to use ruby to integrate my site with PayPal's new Website > Direct Pro API. I tried the code below, and it seems to work once I > upgraded to soap4r-1_5_4: > > require 'soap/wsdlDriver' > server = SOAP::WSDLDriverFactory.new("http:// > www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl") > @driver = server.createDriver > > One problem I'm having is Paypal requires that I set a header in the > request (user id & password). How do I add this before performing a > request? > > Any help or pointers to some SOAP/WSDL ruby documentation would be > greatly appreciated. > > Thanks! > --Dave. > >