目前我正在使用 Savon 在 ruby 中使用 WebService.它工作得很好,但我很难传递参数SOAP 数组类型的参数.以下代码无法正常工作:
Currently I'm using Savon to work with WebService in ruby. It works pretty well but I have difficulty to pass parameter for argument of SOAP array type. Following code doesn't work properly:
ids = [0,1,2] client.do_get_items { |soap| soap.body = { 'item-list' => ids }如果您能解决我的问题或提出替代方案,我将不胜感激ruby&soap 库
I would appreciate if you can solve my problem or propose an alternative library for ruby&soap
推荐答案我只是偶然发现了同样的问题,对我有用的临时解决方法如下:
I just stumbled on the same problem and the temporary workaround that worked for me is as follows:
ids = [0,1,2] client.do_get_items { |soap| soap.body = { 'item-list' => { 'item1' => 0, 'item2' => 1, 'item3' => 2 } }名称item1"、item2"根本不重要.
The names "item1", "item2" shouldn't matter at all.
我使用以下辅助方法将常规数组转换为 SOAP 混乱:
I use the following helper method to convert regular arrays into SOAP mess:
def soap_array(array) returning({}) do |hash| array.each_with_index do |e, i| hash["item-#{i}"] = e end end end更多推荐
如何在 Ruby 中将数组作为参数传递给 SOAP
发布评论