在 Ruby 1.9.2 中使用 SOAP 和其他标准库 [英] Using SOAP and other Standard Libraries in Ruby 1.9.2
问题描述
所以,我最近升级到 1.9.2 Ruby,一直使用 1.8.7(我想尝试使用 Rails 3).
So, I recently upgraded to 1.9.2 Ruby, having used 1.8.7 for forever (I wanted to try out Rails 3).
我遇到的最大问题是我的 SOAP require 语句都没有工作......我有这样的事情:
The BIGGEST problem I'm having is that none of my SOAP require statements are working...I have things like:
require 'soap/rpc/driver'
require 'xsd/qname'
require 'soap/wsdlDriver'
require 'ftools'
即使 ftools 也不起作用,但我认为(查看 Ruby 源代码)这变成了fileutils"?但我没有看到任何类似的 SOAP ......它刚刚被删除了吗?
Even ftools isn't working, but I THINK (look at the Ruby source) that this became 'fileutils'? But I don't see anything similar for SOAP.....has it just been removed?
如果是这样……我该怎么办?有没有基本上做同样事情的插件?
If so...what should I do? Is there any plug ins that do essentially the same thing?
我的代码是这样的:
require 'soap/wsdlDriver'
def send_package
adi_url = "ftp://anonymous:ads123@#{APP_CONFIG['pcms_ip']}/#{self.id}/original/ADI.XML"
cl0 = SOAP::WSDLDriverFactory.new(APP_CONFIG['corba_bridge'])
driver = cl0.create_rpc_driver
driver.streamhandler.client.receive_timeout = 10
x = driver.exportPackage2(self.name+self.id.to_s, adi_url, "NS2.PackageFactory")
log x
if x.to_s =~ /ERROR/
raise x.to_s
end
end
和
require 'soap/rpc/driver'
require 'xsd/qname'
def get_self_offering_ids(wsdl, namespace)
ret = []
input = {"#{namespace}:includeAssetMetadata" => 'true'}
begin
driver = SOAP::RPC::Driver.new(wsdl, namespace)
driver.add_document_method('GetAllOfferingsRequest', "OpenStreamVOD#getAllOfferings", XSD::QName.new(namespace, "GetAllOfferingsRequest"), XSD::QName.new(namespace, "GetAllOfferingsResponse"))
result = driver.GetAllOfferingsRequest(input)
rescue => err
log err
end
if result
result.offering.each do |o|
if offeringIsSelf?(o)
ret << o.xmlattr_offeringId
end
end
end
return ret
end
我没有太多的肥皂经验...我什至不确定 wsdlDriver 和 rpc/driver 有什么不同...只是当时我可能有充分的理由使用这两个独立的库?
I don't have much soap experience...and I'm not even sure how wsdlDriver and rpc/driver are any different...just that I probably had a good reason for using the two separate libraries at the time?
推荐答案
如果你想继续使用 Ruby 1.8 的标准soap库(又名soap4r),你可以试试https://github.com/spox/soap4r-spox ...
If you want to keep using Ruby 1.8's standard soap library (aka soap4r), you can try https://github.com/spox/soap4r-spox ...
wget --no-check-certificate https://github.com/spox/soap4r-spox/tarball/1.5.8.4
tar -xzf spox-soap4r-spox-1.5.8.4-0-g345a6cb.tar.gz
cd spox-soap4r-spox-345a6cb/
ruby setup.rb all
如果您使用 rvm,不要 sudo 最后一个命令...而是将 su 放入 root 并将 rvm 放入 ruby 1.9,以便 setup.rb 将文件放到正确的位置.
If you're using rvm, don't sudo the last command... instead su into root and rvm to ruby 1.9 so that setup.rb puts the files into the right place.
$ 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
根据其他 StackOverflow 答案 的建议,您可能想切换到像 savon 这样的 gem.
As suggested by other StackOverflow answers, you might want to switch to a gem like savon.
这篇关于在 Ruby 1.9.2 中使用 SOAP 和其他标准库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!