簡體   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