Jen*_*nny 4 ruby soap ruby-1.9.2
所以,我最近升级到1.9.2 Ruby,永远使用1.8.7(我想尝试Rails 3).
我遇到的最大问题是我的SOAP要求语句都没有工作......我有类似的东西:
require 'soap/rpc/driver'
require 'xsd/qname'
require 'soap/wsdlDriver'
require 'ftools'
Run Code Online (Sandbox Code Playgroud)
即使是ftools也无法正常工作,但我认为(看看Ruby源代码)这成了'fileutils'?但我没有看到任何类似的SOAP .....它刚被删除?
如果是这样......我该怎么办?是否有任何插件基本上做同样的事情?
我的代码是这样的:
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
Run Code Online (Sandbox Code Playgroud)
和
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
Run Code Online (Sandbox Code Playgroud)
我没有太多的肥皂经验......我甚至不确定wsdlDriver和rpc/driver是如何有所不同的...只是我当时有充分的理由使用这两个独立的库?
如果你想继续使用Ruby 1.8的标准soap库(又名soap4r),你可以尝试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
Run Code Online (Sandbox Code Playgroud)
如果您正在使用rvm,请不要 sudo最后一个命令...而是su到root和rvm到ruby 1.9,以便setup.rb将文件放到正确的位置.
$ 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
Run Code Online (Sandbox Code Playgroud)
正如其他StackOverflow答案所建议的那样,您可能希望切换到像savon这样的gem.