如何在 Ruby 中将数组作为参数传递给 SOAP
目前我正在使用 Savon 来使用 ruby 中的 WebService。 它工作得很好,但我很难传递参数 SOAP 数组类型的参数。以下代码无法正常工作:
ids = [0,1,2]
client.do_get_items { |soap| soap.body = {
'item-list' => ids
}
如果您能解决我的问题或提出替代方案,我将不胜感激 ruby&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
}
I would appreciate if you can solve my problem or propose an alternative
library for ruby&soap
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚偶然发现了同样的问题,对我有用的临时解决方法如下:
名称“item1”、“item2”根本不重要。
我使用以下辅助方法将常规数组转换为 SOAP 混乱:
I just stumbled on the same problem and the temporary workaround that worked for me is as follows:
The names "item1", "item2" shouldn't matter at all.
I use the following helper method to convert regular arrays into SOAP mess:
我有类似的问题。我必须发送字符串数组作为请求的两个参数。我使用 Savon 版本 2。我的最终解决方案如下所示:
帮助我找到正确解决方案的是下载 SOAP UI 并检查正确的请求应该是什么样子。
I had a similar problem. I had to send array of strings as two of the request's arguments. I used Savon version 2. My final solution looks like this:
What helped me to find the right solution was downloading SOAP UI and checking how proper requests should look like.