我正在尝试用Ruby构建一个web服务客户端。
当我尝试调用以下soap4r-ruby脚本来生成web服务客户端代码时:
wsdl2ruby.rb --wsdl *[web_service_url]* --type client
我得到以下错误:
忽略的属性:{http://www.w3.org/2006/05/addressing/wsdl}行动I、 〔2011-06-09T17:16:01.012268#10104〕信息-应用程序:创建类定义。I、 〔2011-06-09T17:16:01.012268#10104〕信息-应用程序:创建文件SessionService.rb’。F、 〔2011-06-09T17:16:01.014268#10104〕致命-应用程序:检测到异常。停止ping。。。未定义的方法
collect' for #<String:0x32260c8> (NoMethodError) C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/codegen/gensupport.rb:2 39:in
trim_eol'C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib.xsd/codegen/gensupport.rb:227:在format' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/codegen/commentdef.rb:2 7:in
转储注释中'C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib.xsd/codegen/classdef.rb:51:在dump_comptype'中的dump' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.r b:118:in
块中C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.rb: 116:在collect' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.r b:116:in
dump_comptype'中C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.rb: 60:在create_classdef中的dump' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:77:i n
块中C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:171:在block in write_file' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:170: in
打开'C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:170:在write_file' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:76:i n
create_classdef中C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:62:increate_file' C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:42:i n
运行'C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:46:inrun' C:/Ruby192/lib/ruby/1.9.1/logger.rb:691:in
start'C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:137:在<top ( required)>' C:/Ruby192/bin/wsdl2ruby.rb:19:in
加载中'C:/Ruby192/bin/wsdl2ruby.rb:19:在"中I、 〔2011-06-09T17:16:01.016268#10104〕信息-应用程序:应用程序结束。(状态:-1)
当,我尝试调用以下代码来动态生成web服务客户端:
require 'soap/wsdlDriver'
WSDL_URL = "http://*[web_service_url]*"
factory = SOAP::WSDLDriverFactory.new(WSDL_URL)
driver = factory.create_rpc_driver
我得到以下错误:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:在
initialize': The requested service provider could not be loaded or initialized. - socket(2) (http://*web_service_url*) (Errno::E10106) from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:in
new中C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:在connect'中的create_socket' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:705:in
块中C:/Ruby192/lib/ruby/1.9.1/timeout.rb:57:intimeout' from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in
超时'来自C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:704:在connect' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:568:in
查询中'来自C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:158:在query' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:1057:in
do_get_block'中C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:866:inblock in do_request' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:953:in
protect_keep_live_disconnected从…起C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:865:indo_request' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:938:in
follow_redirect'来自C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:577:inget_content' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:73:in
从C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:36:inimport' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/importer.rb:18:in
从导入C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:146:inimport' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:32:in
从初始化C:/DevProjects/applicationdevelopmentenvironment/UwsSampleRuby/blah.rb:6:innew' from C:/DevProjects/application-development-environment/UwsSampleRuby/blah.rb:6:in
'
当我尝试调用上面相同的代码,但使用不同的URL(生产URL而不是测试环境URL)时,我会得到不同的错误:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:在initialize': getaddrinfo: A non-recoverable error occurred during a database lookup. (https://[prod_url]:443) (SocketError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:in
新'来自连接中的create_socket'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:705:in
块中的C:\Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:来自C:/Ruby192/lib/ruby/1.9.1/timeout.rb:57:在timeout'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in
timeout'来自C:\Ruby192/lib/rube/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:704:在connect'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:568:in
查询中'来自C:\Ruby192/lib/rube/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:158:在query'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:1057:in
do_get_block'中来自C:\Ruby192/lib/rube/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:866:在block in do_request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:953:in
protect_keep_live_disconnected中来自C:/Ruby192/lib/rube/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:865:在do_request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:938:in
follow_redirect'中来自C:\Ruby192/lib/rube/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:577:在get_content'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:73:in
fetch'来自C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:36:in import'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/importer.rb:18:in
import'来自C:\Ruby192/lib/rube/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:146:在import'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:32:in
初始化中'来自C:/DevProjects/applicationdevelopmentenvironment/UwsSampleRuby/blah.rb:6:在new'
from C:/DevProjects/application-development-environment/UwsSampleRuby/blah.rb:6:in
'中
为什么我会出现这些错误,以及如何解决这些错误?我知道web服务已经开始运行了,因为我可以在C#.Net中构建web服务客户端。
soap4r在Ruby 1.9中存在许多已知问题。您应该考虑使用一个较新的SOAP工具包,例如savon或handsoap。