savon gem和特殊字符的问题

问题描述 投票:0回答:1

我正在为连接到名为yardi的特殊数据库的soap服务实现一个ruby接口。为了做到这一点,我使用savon宝石。

许多必需的服务已经实施。但是,yardi中的某些服务需要作为参数提供符合给定xd的给定范围的完整XML。我遇到了这些服务的问题。

问题从根本上说是savon改变了收到的xml并改变了一些字符;例如<>"等。

这是传递给服务的xml的一个真实示例:

<YsiTran xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns=""><Charges><Charge><Amount>100.0</Amount><AccountId>49610000</AccountId><ChargeCodeId>rentr</ChargeCodeId><Date>2017-01-23T00:00:00</Date><Notes>Charge with segments</Notes><PersonId>t0001306</PersonId><PostMonth>2017-04-01</PostMonth><PropertyId>385pa</PropertyId><Reference>Internet</Reference><UnitId>B3</UnitId><Segment1>collect</Segment1><Segment2>Technical</Segment2><Segment3>After due date</Segment3><Segment4>NA</Segment4><Segment5>IT</Segment5><Segment6>Owner</Segment6><Segment7>Testing</Segment7><Segment8>Testing</Segment8><Segment9>Employee</Segment9><Segment10>Sigma</Segment10><Segment11>January</Segment11><Segment12>Block 1</Segment12></Charge></Charges></YsiTran>

我很确定这个xml是正确的,因为我已经使用SoapUI测试了它。也就是说,当我使用给定的xml将xml放到SoapUI时,服务会正确响应。

现在,当我将前一个xml放到savon并且我看到请求时,我注意到xml被转换为

&lt;YsiTran xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns=&quot;&quot;&gt;&lt;Charges&gt;&lt;Charge&gt;&lt;Amount&gt;100.0&lt;/Amount&gt;&lt;AccountId&gt;49610000&lt;/AccountId&gt;&lt;ChargeCodeId&gt;rentr&lt;/ChargeCodeId&gt;&lt;Date&gt;2017-01-23T00:00:00&lt;/Date&gt;&lt;Notes&gt;Charge with segments&lt;/Notes&gt;&lt;PersonId&gt;t0001306&lt;/PersonId&gt;&lt;PostMonth&gt;2017-04-01&lt;/PostMonth&gt;&lt;PropertyId&gt;385pa&lt;/PropertyId&gt;&lt;Reference&gt;Internet&lt;/Reference&gt;&lt;UnitId&gt;B3&lt;/UnitId&gt;&lt;Segment1&gt;collect&lt;/Segment1&gt;&lt;Segment2&gt;Technical&lt;/Segment2&gt;&lt;Segment3&gt;After due date&lt;/Segment3&gt;&lt;Segment4&gt;NA&lt;/Segment4&gt;&lt;Segment5&gt;IT&lt;/Segment5&gt;&lt;Segment6&gt;Owner&lt;/Segment6&gt;&lt;Segment7&gt;Testing&lt;/Segment7&gt;&lt;Segment8&gt;Testing&lt;/Segment8&gt;&lt;Segment9&gt;Employee&lt;/Segment9&gt;&lt;Segment10&gt;Sigma&lt;/Segment10&gt;&lt;Segment11&gt;January&lt;/Segment11&gt;&lt;Segment12&gt;Block 1&lt;/Segment12&gt;&lt;/Charge&gt;&lt;/Charges&gt;&lt;/YsiTran&gt;

有人注意到,因为我忽视savon的原因改变了一些符号。

我正在执行这样的请求:

client.call(service_name.intern, 
            message: { # other parameters
                       'TransactionXml' => transaction_xml })

client是一个savon对象,transaction_xml是一个包含xml的红宝石字符串。

任何线索,提示?提前致谢

ruby xml savon
1个回答
1
投票

如果您有一条XML消息并且无法使用它与Savon的ruby对象一起工作,那么您可以像这样发送逐字XML:

client.call(service_name.intern, xml: "<tag1>values</tag1>")

详细信息在文档http://savonrb.com/version2/locals.html中描述

© www.soinside.com 2019 - 2024. All rights reserved.