Last Updated: February 25, 2016
·
841
· dcdieci

How to consume hotel.de API with ruby

Recently I had to access the xml webservice of hotel.de which caused a lot of headache due to a very few documentation docs.

So first of all it was hard to find a documentation about the service itself. Here it is.
http://www.hotel.de/media/downloads_public/hotelde_FreeHotelSearchWebService_V2_8.pdf

In order to the the spec of the service you might wanna take a look at a wsdl viewer:

http://services.w3.org/xslt?xslfile=http://tomi.vanek.sk/xml/wsdl-viewer.xsl&xmlfile=http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc?WSDL&transform=Submit#op.d3e64

Since I did not want to come up with a self written api consumer it decided to to ahead by using the savon gem (Version 2) http://savonrb.com/ .

Here is my constructor to get the client running

 @client = Savon.client(
   wsdl: "http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService_ServiceContract.wsdl",
   endpoint: "http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc?WSDL",
   namespace_identifier: :v2,
   env_namespace: :soapenv,
   pretty_print_xml: true  ,
   log_level: :debug ,
   log:                     true,
 )


@client.operations 

will give you an overview of the available methods.

since the child elements in the soap envelope body do not inherit the namespace identifier you might want to use nil

namespace_identifier: nil