繁体   English   中英

wash_out | 有效负载中的XML具有<>而不是<>

[英]wash_out | XML in payload has &lt; &gt; instead of < >

wash_out (0.9.0)对我在Rails(3.1)应用程序中实现SOAP服务非常有帮助。 我面临的一个小问题是,对于SOAP正文中的XML有效负载, < >&lt; &gt;代替了&lt; &gt; &lt; &gt;

这是我的代码段

render :soap => "<person><firstname>larry</firstname></person>"

输出是

<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://www.w3.org/2001/12/soap-envelope"> <soap:Body> <tns:index_response> <value xsi:type="xsd:string">&lt;person&gt;&lt;firstname&gt;larry&lt;/firstname&gt;&lt;/person&gt;</value> </tns:index_response> </soap:Body> </soap:Envelope>

这是错误还是我可以通过一些配置或其他代码来解决。 请帮助。

试试这个(没有测试):

render :soap => "<person><firstname>larry</firstname></person>".html_safe

我能够解决这个问题。 我做错了一件事情。

我正在使用savon客户端来调用我的SOAP服务。 我在做
client = Savon::Client.new(wsdl: "")
result = client.call(...)
puts result

这是显示&lt; &gt;

就我而言,访问响应内容的正确方法是
result.body[:index_response][:value]
result.body返回哈希

使用Nokogiri我可以做到doc = Nokogiri::XML(result.body.to_xml)

这与有效负载中的XML很好地配合。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM