我正在为连接到名为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被转换为
<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>
有人注意到,因为我忽视savon的原因改变了一些符号。
我正在执行这样的请求:
client.call(service_name.intern,
message: { # other parameters
'TransactionXml' => transaction_xml })
client
是一个savon对象,transaction_xml
是一个包含xml的红宝石字符串。
任何线索,提示?提前致谢
如果您有一条XML消息并且无法使用它与Savon的ruby对象一起工作,那么您可以像这样发送逐字XML:
client.call(service_name.intern, xml: "<tag1>values</tag1>")
详细信息在文档http://savonrb.com/version2/locals.html中描述