すべてのソープコールで使用する回避策が見つかりました。私は単にルビーの%Q{}
ブロックと#{}
ルビ補間でxmlを追加することができます。
私の呼び出しは今、このようになります。
@run = Run.find_by(invoice_id: @invoice.id)
unless @run
@run = @invoice.runs.build(delivery: @delivery)
# (6.) Een PostNL SOAP-call wordt gemaakt.
@client_barcode = Savon.client(
:wsdl => 'https://testservice.postnl.com/CIF_SB/BarcodeWebService/1_1/?wsdl',
:log => true,
:pretty_print_xml => true
)
@response_barcode = @client_barcode.call(:generate_barcode, xml: %Q{
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bar="http://postnl.nl/cif/services/BarcodeWebService/" xmlns:tpp="http://postnl.nl/cif/domain/BarcodeWebService/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>devc_!R4xc8p9</wsse:Username>
<wsse:Password>#{ENV['postnl_password']}</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<bar:GenerateBarcode>
<tpp:Message>
<tpp:MessageID>1</tpp:MessageID>
<tpp:MessageTimeStamp>02-05-2014 12:00:00</tpp:MessageTimeStamp>
</tpp:Message>
<tpp:Customer>
<tpp:CustomerCode>DEVC</tpp:CustomerCode>
<tpp:CustomerNumber>11223344</tpp:CustomerNumber>
</tpp:Customer>
<tpp:Barcode>
<tpp:Type>3S</tpp:Type>
<tpp:Range>DEVC</tpp:Range>
<tpp:Serie>000000000-999999999</tpp:Serie>
</tpp:Barcode>
</bar:GenerateBarcode>
</soapenv:Body>
</soapenv:Envelope>}).to_hash
@run.barcode = @response_barcode[:generate_barcode_response][:barcode]
@run.save