SOAP Action WSDL

后端 未结 8 1202
再見小時候
再見小時候 2020-12-30 02:18

I\'m trying to implement a client for National Rail Enquiries\' SOAP Service (http://www.livedepartureboards.co.uk/ldbws/).

I stick the WSDL (http://realtime.nationa

8条回答
  •  不知归路
    2020-12-30 02:47

    I've just spent a while trying to get this to work an have a written a Ruby gem that accesses the API. You can read more on it's project page.

    This is working code in Ruby:

    require 'savon'
    client = Savon::Client.new do
      wsdl.document = "http://realtime.nationalrail.co.uk/LDBWS/wsdl.aspx"
    end
    
    response = client.request 'http://thalesgroup.com/RTTI/2012-01-13/ldb/GetDepartureBoard' do
    
      namespaces = {
        "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.xml do |xml|
        xml.soap(:Envelope, namespaces) do |xml|
          xml.soap(:Header) do |xml|
            xml.AccessToken do |xml|
              xml.TokenValue('ENTER YOUR TOKEN HERE') 
            end
          end
          xml.soap(:Body) do |xml|
            xml.GetDepartureBoardRequest(xmlns: "http://thalesgroup.com/RTTI/2012-01-13/ldb/types") do |xml|
              xml.numRows(10)
              xml.crs("BHM")
              xml.filterCrs("BHM")
              xml.filterType("to")
            end
          end
        end
      end
    end
    p response.body
    

    Hope that's helpful for someone!

提交回复
热议问题