public

using savon to talk to the betfair soap api

  • Download Gist
betfair_sample_request_created_by_soapui.xml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bfex="http://www.betfair.com/publicapi/v5/BFExchangeService/"
xmlns:v5="http://www.betfair.com/publicapi/types/exchange/v5/">
<soapenv:Header/>
<soapenv:Body>
<bfex:getAllMarkets>
<bfex:request>
<header>
<clientStamp>stamp</clientStamp>
<sessionToken>token</sessionToken>
</header>
<locale>UK</locale>
<eventTypeIds>
<!--Zero or more repetitions:-->
<v5:int>1</v5:int>
</eventTypeIds>
<countries>
<!--Zero or more repetitions:-->
<v5:Country>UK</v5:Country>
</countries>
<fromDate>2010-01-10:10:10:00Z</fromDate>
<toDate>2010-11-10:10:10:00Z</toDate>
</bfex:request>
</bfex:getAllMarkets>
</soapenv:Body>
</soapenv:Envelope>
savon_request.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# solution for https://github.com/rubiii/savon/issues/68
 
client = Savon::Client.new do
wsdl.endpoint = "https://api.betfair.com/exchange/v5/BFExchangeService"
wsdl.namespace = "http://www.betfair.com/publicapi/v5/BFExchangeService/"
end
 
client.request :bfex, :get_all_markets do
soap.namespaces["xmlns:v5"] = "http://www.betfair.com/publicapi/types/exchange/v5/"
soap.body = {
"bfex:request" => {
:header => { :client_stamp => "stamp", :session_token => "token" },
:locale => "UK",
:event_type_ids => { "v5:int" => [1, 2] },
:countries => { "v5:Country" => ["DE", "UK"] },
:from_date => 1.year.ago,
:to_date => Time.now
}
}
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.