FlightXML2 WSDL is 301 redirecting without useful feedback


#1

From using the suggested savon gem setup like so …

client = Savon.client(
wsdl: 'http://flightxml.flightaware.com/soap/FlightXML2/wsdl', 
basic_auth: [username, password], 
follow_redirects: :true, 
log: true, 
log_level: :debug, 
pretty_print_xml: true)

message = {
	:airport_code => 'KJFK',
	:include_ex_data => 0,
	:type => 'enroute',
	:howMany => 10
}

response = client.call(:airport_boards, message: message)

I get the following error …

irb(main):299:0>  response = client.call(:airport_boards, message: message)
D, [2017-10-29T03:51:44.736884 #4] DEBUG -- : HTTPI GET request to flightxml.flightaware.com (excon)
D, [2017-10-29T03:51:44.885191 #4] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/wsdl'.
D, [2017-10-29T03:51:44.890905 #4] DEBUG -- : HTTPI GET request to flightaware.com (excon)
D, [2017-10-29T03:51:44.987112 #4] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/wsdl'.
D, [2017-10-29T03:51:45.000242 #4] DEBUG -- : HTTPI GET request to flightaware.com (excon)
D, [2017-10-29T03:51:45.094621 #4] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/wsdl'.
D, [2017-10-29T03:51:45.095679 #4] DEBUG -- : HTTPI GET request to flightaware.com (excon)
Savon::HTTPError: HTTP error (301)
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:27:in `rescue in ensure_exists!'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:22:in `ensure_exists!'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:15:in `create'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:32:in `operation'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:36:in `call'
	from (irb):299
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:110:in `start'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:9:in `start'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
	from /app/bin/rails:9:in `require'
	from /app/bin/rails:9:in `<main>'

Not really sure what to do here as our setup was working perfectly until about October 27th at 8pm Eastern Time - Thanks for your assistance - hoping we can figure this out!


#2

Can you try switching the URL protocol to https instead of http?


#3

After updating the above statements to …

client = Savon.client(
wsdl: 'https://flightxml.flightaware.com/soap/FlightXML2/wsdl', 
basic_auth: [username, password], 
follow_redirects: :true, 
log: true, 
log_level: :debug, 
pretty_print_xml: true)

message = {
	:airport_code => 'KJFK',
	:include_ex_data => 0,
	:type => 'enroute',
	:howMany => 10
}

response = client.call(:airline_flight_schedules, message: message)

The following is returned on client call …

irb(main):428:0> response = client.call(:airline_flight_schedules, message: message)
I, [2017-10-29T05:10:45.355100 #4]  INFO -- : SOAP request: http://flightxml.flightaware.com/soap/FlightXML2/op
I, [2017-10-29T05:10:45.355214 #4]  INFO -- : SOAPAction: "FlightXML2:AirlineFlightSchedules", Content-Type: text/xml;charset=UTF-8, Content-Length: 586
D, [2017-10-29T05:10:45.355452 #4] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:FlightXML2="http://flightxml.flightaware.com/soap/FlightXML2" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <FlightXML2:AirlineFlightSchedulesRequest>
      <FlightXML2:airportCode>KJFK</FlightXML2:airportCode>
      <FlightXML2:includeExData>0</FlightXML2:includeExData>
      <FlightXML2:type>enroute</FlightXML2:type>
      <FlightXML2:howMany>10</FlightXML2:howMany>
    </FlightXML2:AirlineFlightSchedulesRequest>
  </env:Body>
</env:Envelope>

D, [2017-10-29T05:10:45.355736 #4] DEBUG -- : HTTPI POST request to flightxml.flightaware.com (excon)
D, [2017-10-29T05:10:45.451366 #4] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/op'.
D, [2017-10-29T05:10:45.451620 #4] DEBUG -- : HTTPI POST request to flightaware.com (excon)
D, [2017-10-29T05:10:45.537049 #4] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/op'.
D, [2017-10-29T05:10:45.539163 #4] DEBUG -- : HTTPI POST request to flightaware.com (excon)
D, [2017-10-29T05:10:45.633600 #4] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/op'.
D, [2017-10-29T05:10:45.633912 #4] DEBUG -- : HTTPI POST request to flightaware.com (excon)
I, [2017-10-29T05:10:45.724650 #4]  INFO -- : SOAP response (status 301)
D, [2017-10-29T05:10:45.724799 #4] DEBUG -- :
Savon::HTTPError: HTTP error (301)
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:86:in `raise_soap_and_http_errors!'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:14:in `initialize'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `new'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `create_response'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:58:in `call'
	from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:36:in `call'
	from (irb):428
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:110:in `start'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:9:in `start'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
	from /app/bin/rails:9:in `require'
	from /app/bin/rails:9:in `<main>'

Hope this provides some more insight … but it looks like the redirect issue is still present


#4

Based on your logs, savon appears to possibly be using the wrong target URL: http://flightaware.com/soap/FlightXML2/op It should use the hostname flightxml.flightaware.com, as specified by the WSDL file:

<wsdl:port name="FlightXML2Soap" binding="FlightXML2:FlightXML2Soap">
<soap:address location="http://flightxml.flightaware.com/soap/FlightXML2/op"/>
</wsdl:port>

Did you upgrade your version of savon, or any other packages?


#5

@bovineone that sounds right - but we aren’t being redirected to that endpoint anymore.

There have been no changes to the app or packages running in production for the past week actually so the current app was working up until around October 27th at ~8pm.

Did Flightaware have a proxy change, certificate update, or some networking update recently?


#6

Here’s a test script that we can use to help test. We’re using ruby 2.2.4 and savon-2.11.1.

#!/usr/bin/env ruby

require 'rubygems'
require 'savon'

SOAP_URL = 'http://flightxml.flightaware.com/soap/FlightXML2/wsdl'
USERNAME = username
API_KEY = api_key

client = Savon.client(
  wsdl: 'https://flightxml.flightaware.com/soap/FlightXML2/wsdl',
  basic_auth: [USERNAME, API_KEY],
  log: true,
  log_level: :debug,
  pretty_print_xml: true
)

message = {
	:airport_code => 'KJFK',
	:include_ex_data => 0,
	:type => 'enroute',
	:howMany => 10
}

response = client.call(:airline_flight_schedules, message: message)

puts response

We see that we’re sent to flightxml.flightaware.com, but are still redirected

$ ./test.rb
D, [2017-10-29T12:07:35.225904 #97994] DEBUG -- : HTTPI GET request to flightxml.flightaware.com (excon)
I, [2017-10-29T12:07:35.850520 #97994]  INFO -- : SOAP request: http://flightxml.flightaware.com/soap/FlightXML2/op
I, [2017-10-29T12:07:35.850574 #97994]  INFO -- : SOAPAction: "FlightXML2:AirlineFlightSchedules", Content-Type: text/xml;charset=UTF-8, Content-Length: 586
D, [2017-10-29T12:07:35.851776 #97994] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:FlightXML2="http://flightxml.flightaware.com/soap/FlightXML2" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <FlightXML2:AirlineFlightSchedulesRequest>
      <FlightXML2:airportCode>KJFK</FlightXML2:airportCode>
      <FlightXML2:includeExData>0</FlightXML2:includeExData>
      <FlightXML2:type>enroute</FlightXML2:type>
      <FlightXML2:howMany>10</FlightXML2:howMany>
    </FlightXML2:AirlineFlightSchedulesRequest>
  </env:Body>
</env:Envelope>

D, [2017-10-29T12:07:35.852018 #97994] DEBUG -- : HTTPI POST request to flightxml.flightaware.com (excon)
I, [2017-10-29T12:07:35.953624 #97994]  INFO -- : SOAP response (status 301)
D, [2017-10-29T12:07:35.953694 #97994] DEBUG -- :
/Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:86:in `raise_soap_and_http_errors!': HTTP error (301) (Savon::HTTPError)
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:14:in `initialize'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `new'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `create_response'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:58:in `call'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:36:in `call'
	from ./test.rb:30:in `<main>'

If we allow our client to follow redirects like so …

client = Savon.client(
  wsdl: 'https://flightxml.flightaware.com/soap/FlightXML2/wsdl',
  basic_auth: [USERNAME, API_KEY],
  follow_redirects: true, 
  log: true,
  log_level: :debug,
  pretty_print_xml: true
)

Then we get the following …

$ ./test.rb
D, [2017-10-29T12:11:35.133282 #98135] DEBUG -- : HTTPI GET request to flightxml.flightaware.com (excon)
I, [2017-10-29T12:11:35.636052 #98135]  INFO -- : SOAP request: http://flightxml.flightaware.com/soap/FlightXML2/op
I, [2017-10-29T12:11:35.636117 #98135]  INFO -- : SOAPAction: "FlightXML2:AirlineFlightSchedules", Content-Type: text/xml;charset=UTF-8, Content-Length: 586
D, [2017-10-29T12:11:35.636347 #98135] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:FlightXML2="http://flightxml.flightaware.com/soap/FlightXML2" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <FlightXML2:AirlineFlightSchedulesRequest>
      <FlightXML2:airportCode>KJFK</FlightXML2:airportCode>
      <FlightXML2:includeExData>0</FlightXML2:includeExData>
      <FlightXML2:type>enroute</FlightXML2:type>
      <FlightXML2:howMany>10</FlightXML2:howMany>
    </FlightXML2:AirlineFlightSchedulesRequest>
  </env:Body>
</env:Envelope>

D, [2017-10-29T12:11:35.636562 #98135] DEBUG -- : HTTPI POST request to flightxml.flightaware.com (excon)
D, [2017-10-29T12:11:35.752481 #98135] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/op'.
D, [2017-10-29T12:11:35.752682 #98135] DEBUG -- : HTTPI POST request to flightaware.com (excon)
D, [2017-10-29T12:11:35.908854 #98135] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/op'.
D, [2017-10-29T12:11:35.909081 #98135] DEBUG -- : HTTPI POST request to flightaware.com (excon)
D, [2017-10-29T12:11:36.012241 #98135] DEBUG -- : Following redirect: 'http://flightaware.com/soap/FlightXML2/op'.
D, [2017-10-29T12:11:36.012526 #98135] DEBUG -- : HTTPI POST request to flightaware.com (excon)
I, [2017-10-29T12:11:36.147092 #98135]  INFO -- : SOAP response (status 301)
D, [2017-10-29T12:11:36.147154 #98135] DEBUG -- :
/Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:86:in `raise_soap_and_http_errors!': HTTP error (301) (Savon::HTTPError)
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:14:in `initialize'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `new'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `create_response'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:58:in `call'
	from /Users/anthcor/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:36:in `call'
	from ./test.rb:26:in `<main>'

Thanks so much for your help - hoping we can solve this soon!

Just thinking to past experiences - was there a reverse proxy change somewhere for FlightXML2 perhaps?


#7

From the following commands and output;

$ curl -I flightxml.flightaware.com
HTTP/1.1 302 Found
Location: http://flightaware.com/commercial/flightxml/
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1
Accept-Ranges: bytes
Date: Mon, 30 Oct 2017 00:57:09 GMT
X-Varnish: 89374994
Age: 0
Via: 1.1 varnish
Connection: keep-alive
Server: FlightAware/3.1
X-FA-Cache: MISS
cache-control: max-age=5, must-revalidate

$ curl -I http://flightaware.com/commercial/flightxml/
HTTP/1.1 200 OK
X-FA-Backend: welbo
Vary: Accept-Encoding
Content-Type: text/html;charset=utf-8
Date: Mon, 30 Oct 2017 00:57:18 GMT
X-Varnish: 334346255 333793048
Age: 1815
Via: 1.1 varnish
Connection: keep-alive
Server: FlightAware/3.1
X-FA-Cache: HIT
cache-control: max-age=5, must-revalidate

It appears that we’re being redirected back to flightaware.com … this doesn’t seem like desired behavior?


#8

In that particular case it’s because you’re requesting the root page of flightxml.flightaware.com, which isn’t expected to be used by anything - so you get redirected to info on FlightXML. Try it with the WSDL URL.


#9

That looks much better! Still unclear why savon is redirecting us though

$ curl -I https://flightxml.flightaware.com/soap/FlightXML2/wsdl
HTTP/1.1 200 OK
Server: nginx/1.12.1
Date: Mon, 30 Oct 2017 01:20:56 GMT
Content-Type: text/html
Connection: keep-alive
Vary: Accept-Encoding
Accept-Ranges: bytes
X-Varnish: 89808919
Age: 0
Via: 1.1 varnish
X-FA-Cache: MISS
cache-control: max-age=5, must-revalidate

#10

Yeah, there is an odd interaction somewhere in there; I can’t reproduce the redirect you see.