I'm implementing a ruby interface to soap services connecting to a special database called yardi. In order to do that, I use the savon gem.
Many of the required services have already been implemented. However, some services in yardi require as a parameter a full XML compliant with a given yardi provided xds. I'm having problems with these services.
The problem fundamentally is that savon changes the received xml and changes some characters; for example <
, >
, "
, etc.
This is an real example of xml passed to a service:
<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>
I'm pretty sure this xml is correct because I have tested it by using SoapUI. That is, when I put the xml to SoapUI with the given xml the service responds correctly.
Now, when I put the previous xml to savon and I see the request, I notice that the xml is transformed to
<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>
As someone could notice, for a reason that I ignore savon changed some symbols.
I'm performing the request some like this:
client.call(service_name.intern,
message: { # other parameters
'TransactionXml' => transaction_xml })
client
is a savon object and transaction_xml
is a ruby string containing the xml.
Any clue, tip? Thanks in advance
If you have a XML message and can't get it to work with Savon's ruby objects then you can send verbatim XML like this:
client.call(service_name.intern, xml: "<tag1>values</tag1>")
The details are described in the documentation http://savonrb.com/version2/locals.html