Rails – Savon设置了多个名称空间

我正在使用savon版本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只放置最后一个命名空间

  

我没有在Savon Git项目中找到任何关于此的文档。

有没有人有这个问题的解决方法?

PS-我还检查一个可能的解决方案是将所有xml请求(信封)设置为请求但是……嗯…太像黑客了。

如果这是不可能的,还有其他好的gem可以做到这一点,请告诉我=)

我发现不可能(现在)在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 

更多信息在这里和这里 。

这个问题将通过以下代码在Savon 2的下一个版本中得到解决:

 namespaces( "xmlns:first" => "http://someURL.pt/Test1", "xmlns:two" => "http://someURL.pt/Testweewqwqeewq" ) 

从Savon 2.1.0开始 ,可以通过使用namespaces空间定义的哈希设置namespaces键来完成:

 Savon.client({ ... namespaces: { 'xmlns:first' => 'http://someURL.pt/Test1', 'xmlns:second' => 'http://someURL.pt/Test2', 'xmlns:nth' => 'http://someURL.pt/TestN' } })