在 ruby1.8.x 版本中,可以这样发送短信,换了 1.9.x 版本后,报错 no such file to load "soap/wsdlDriver" 查了一下,ruby1.9 版本把它去掉了 求助,在 1.9.x 中有其他的解决方案吗?
require "soap/wsdlDriver"
def self.send_message(mobile_phone, msg)
wsdl = "http://sms.xxx?WSDL"
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
ret = driver.SendSms(:mobile=>mobile_phone, :text=>msg, :username=>"username", :password=>"passworld")
end
解决方案: gem 'soap4r-ruby1.9' bundle install 切换到 gem soap4r-ruby1.9 目录下 执行 ruby setup.rb all
$ irb
ruby-1.9.2-p0 > require 'soap/rpc/driver'
=> true
ruby-1.9.2-p0 > require 'xsd/qname'
=> false
ruby-1.9.2-p0 > require 'soap/wsdlDriver'
=> true
ruby-1.9.2-p0 > require 'fileutils'
=> true