English 中文(简体)
• 如何将阿雷拉作为参数通过至鲁比的SOAP
原标题:How to pass Array as parameter to SOAP in Ruby

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
}

I would appreciate if you can solve my problem or propose an alternative library for ruby&soap

最佳回答

我对同一问题感到困惑,为我工作的临时工作如下:

ids = [0,1,2]
client.do_get_items { |soap| soap.body = {
   item-list  => {
     item1  => 0,
     item2  => 1,
     item3  => 2
  }  
}

“项目1”、“项目2”等名称根本不重要。

我使用以下助手方法将常规阵列转化为SOAP信号:

def soap_array(array)
  returning({}) do |hash|
    array.each_with_index do |e, i|
      hash["item-#{i}"] = e
    end
  end
end
问题回答

我也存在同样的问题。 作为两项请求的论点,我不得不发出一系列的论据。 我使用了萨文版本2。

class JvMatching

    CLIENT_ID =  bb_matchnig 

    extend Savon::Model

    operations :query_index

    # arg1, arg 2 - name of parameters that should be arrays of string
    def self.query_index(contents=[], constraints=[], focus= job , result_size=20)
        super(message: { arg0: CLIENT_ID, arg1: { item: contents }, arg2: { item: constraints }, arg3: focus, arg4: result_size })      
    end  

end

帮助我找到正确解决办法的是下载,并检查适当的要求。





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签