3

我正在使用带有 rails 2.3.11、savon 1.1.0、芥末 2.5.0、httpi 1.1.1 和 httpclient 2.2.7 的 ruby​​ 1.8.7

每当我运行我的脚本时:

#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'savon'

client = Savon::Client.new do |wdsl, http|
      wdsl.document = 'https://www.atmosfair.de:8443/service/AtmosfairEmissionService3?wsdl'
      http.auth.ssl.verify_mode = :none
      http.auth.basic "user", "password"
end

client.request :wdsl, "getFlightEmission" do
    soap.body = {
         :departure => "VIE",
         :arrival => "DUB"
    }
end

我明白了:

HTTPI 使用 httpclient 适配器执行 HTTP GET /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient/session.rb:300:in `connect': SSL_connect 返回=1 errno=0 state=SSLv2/v3 读取服务器问候 A:sslv3 警报意外消息 (OpenSSL::SSL::SSLError)

来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient/session.rb:300:in ssl_connect' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient/session.rb:757:inconnect' 来自 /usr/local/rvm/gems/ruby -1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient/timeout.rb:131:in timeout' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient/session.rb:748:inconnect' 来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient- 2.2.7/lib/httpclient/session.rb:606:in query' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient/session.rb:161:inquery' 来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient.rb:1070 :in do_get_block' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient.rb:873:indo_request' 来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient.rb:966:in protect_keep_alive_disconnected' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient.rb:872:indo_request' 来自 /usr/local/rvm/gems /ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient.rb:760:in request' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpclient-2.2.7/lib/httpclient.rb:663:inget' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpi- 1.1.1/lib/httpi/adapter/httpclient.rb:24:inget' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpi-1.1.1/lib/httpi/adapter/httpclient.rb:64:indo_request' 来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpi-1.1.1/lib/httpi/adapter/httpclient.rb:23:in get' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpi-1.1.1/lib/httpi.rb:86:inget' 来自 /usr/local/rvm /gems/ruby-1.8.7-p370/gems/httpi-1.1.1/lib/httpi.rb:193:in with_adapter' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/httpi-1.1.1/lib/httpi.rb:84:inget' 从 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/ savon-1.1.0/lib/savon/wasabi/document.rb:34:in resolve_document' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/savon-1.1.0/lib/savon/wasabi/document.rb:15:inxml' 来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/wasabi-2.5.0/lib/wasabi /document.rb:131:in parse' from /usr/local/rvm/gems/ruby-1.8.7-p370/gems/wasabi-2.5.0/lib/wasabi/document.rb:118:inparser' 来自 /usr/local/rvm/gems/ruby-1.8.7-p370/gems/wasabi-2.5.0/lib/wasabi/document.rb:61:in `soap_actions'来自脚本/atmosfair.rb:28

而 SoapUI 给了我:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns1:FlightEmission xsi:type="ns1:FlightEmissionData" xmlns:ns1="http://www.atmosfair.de/2009/07/travel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <CO2>0.19</CO2>
         <offset>5.0</offset>
         <distance>1733</distance>
         <CO2PerPkm>0.0</CO2PerPkm>
         <CO2InCriticalAltitudes>0.13</CO2InCriticalAltitudes>
         <CO2RFI2>0.32</CO2RFI2>
         <CO2RFI27>0.41</CO2RFI27>
         <CO2RFI3>0.45</CO2RFI3>
         <CO2RFI4>0.59</CO2RFI4>
         <keroseneConsumption>0.06</keroseneConsumption>
         <keroseneConsumptionInCriticalAltitudes>0.04</keroseneConsumptionInCriticalAltitudes>
         <specificFuelConsumptionAverage>4.31</specificFuelConsumptionAverage>
         <offsetCO2RFI2>8.0</offsetCO2RFI2>
         <offsetCO2RFI27>11.0</offsetCO2RFI27>
         <offsetCO2RFI3>11.0</offsetCO2RFI3>
         <offsetCO2RFI4>15.0</offsetCO2RFI4>
      </ns1:FlightEmission>
   </soapenv:Body>
</soapenv:Envelope>

任何想法,我做错了什么?

4

1 回答 1

0

我通过使用遏制而不是httpclient解决了它:

#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'iconv'
require 'curb'
require 'savon'

HTTPI.adapter = :curb

   client = Savon::Client.new do |wdsl, http|
      http.headers = { "Content-Length" => "0", "Connection" => "Keep-Alive" }
      http.auth.basic "user", "password"
      wdsl.document = 'https://www.atmosfair.de:8443/services/AtmosfairEmissionService3?wsdl'
    end

    client.http.auth.ssl.verify_mode = :none

    response = client.request :wdsl, "getFlightEmission" do
       soap.body = {
         :departure => "VIE",
         :arrival => "DUB"
    }
end

现在一切正常!

于 2012-10-24T16:37:13.733 回答