如何处理 Savon Responses?
我不明白那些更喜欢 Savon 而不是 Soap4r 的人。
如何获取 Savon 响应中返回对象的属性?使用soap4r,它就像调用吸气剂一样干净!
显然,在 Savon 中我需要显式解析响应并遍历 response_hash。这比soap4r 方法要糟糕得多。我是不是搞错了,还是Savon只是质量较差的soap4r?
编辑:这个问题是由于 savon 没有正确支持 multi_ref 响应,如答案评论中所述。
I do not understand the people who prefer Savon to Soap4r.
How can I get the attributes of the returned object in a Savon response? With soap4r it's as clean as invoking a getter!
Apparently, in Savon I need to explicitly parse the response and walk the response_hash. This is way worse than the soap4r approach. Am I getting something wrong, or is Savon just a worse-quality soap4r?
edit: this question was due to savon not properly supporting multi_ref responses, as stated in an answer comment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 https://github.com/raldred/savon/blob/ master/lib/savon/response.rb
所以你应该能够调用 hash[:object] 它将返回属性。
您不需要遍历响应对象,只需调用 to_hash 即可。
From https://github.com/raldred/savon/blob/master/lib/savon/response.rb
So you should be able to call hash[:object] which would return attribute.
You dont need to walk the response object just call to_hash.