ruby-on-rails – Rails – Savon设置了多个名称空间
发布时间:2020-12-17 04:20:52 所属栏目:百科 来源:网络整理
导读:我正在使用 savon version 2(使用Ruby on Rails)来调用web服务,我需要为我的Envelope注入一些额外的命名空间.就像是: soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:add="http://schemas.xmlsoap.org/ws/2003/03/addre
我正在使用
savon version 2(使用Ruby on Rails)来调用web服务,我需要为我的Envelope注入一些额外的命名空间.就像是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:add="http://schemas.xmlsoap.org/ws/2003/03/addressing" xmlns:newNamespace1="http://someURL.pt/Test1" xmlns:newNamespace2="http://someURL.pt/Test2" xmlns:newNamespace3="http://someURL.pt/Test3" 我目前的代码是: client = Savon.client do wsdl "https://someValidURL?wsdl" namespace "http://someURL.pt/Test1" namespace "http://someURL.pt/Test2" namespace "http://someURL.pt/Test3" end response = client.call( ...the webservice call... ) …但在我的请求中,Savon只放置最后一个命名空间 <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsns="http://someURL.pt/Test3" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> 我在Savon Git project没有找到任何关于此的文档. 有没有人有这个问题的解决方法? PS-我还检查一个可能的解决方案是将所有xml请求(信封)设置为请求但是……嗯…太像黑客了. 如果这是不可能的,还有其他好的宝石可以做到这一点,请告诉我=) 解决方法
我发现不可能(现在)在Savon的第2版上设置多个名称空间.
现在我在Savon版本1上迁移我的应用程序,它工作=) begin client = Savon::Client.new do wsdl.document = "https://someURL?wsdl" end @response = client.request :service do soap.namespaces["xmlns:test1"] = "http:/someURLtest1" soap.namespaces["xmlns:test2"] = "http:/someURLtest2" soap.body = { #... the message.... :"test1:something" => {},:"test2:something1" => {} } end rescue Savon::Error => error log error.to_s end 更多信息here和here. 这个问题将通过以下代码在Savon 2的下一个版本中得到解决: namespaces( "xmlns:first" => "http://someURL.pt/Test1","xmlns:two" => "http://someURL.pt/Testweewqwqeewq" ) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |