dzień dobry!
jestem początkującym w rubim i mam problem z tworzeniem xmla przez gem Savon.
Ot, ćwiczę na API z allegro Sandbox i korzystam z SoapUI, który generuje mi taki xml i to działa:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:SandboxWebApi">
<soapenv:Header/>
<soapenv:Body>
<urn:DoGetCountriesRequest>
<urn:countryCode>1</urn:countryCode>
<urn:webapiKey>xxx</urn:webapiKey>
</urn:DoGetCountriesRequest>
</soapenv:Body>
</soapenv:Envelope>
Chcę dokładnie taki xml wygenerować w railsach, ale nie wychodzi.
Mój kod w railsach:
WSDL_URL = 'https://webapi.allegro.pl.webapisandbox.pl/service.php?wsdl'
client = Savon.client(wsdl: WSDL_URL,
log: true,
log_level: :debug,
pretty_print_xml: true)
xml_message = {"countryCode" => 1, "webapiKey" => 'xxx'}
client.call(:do_get_countries, message: xml_message)
w konsoli widzę, że to tworzy taki xml:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:SandboxWebApi" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<tns:doGetCountries>
<tns:countryCode>1</tns:countryCode>
<tns:webapiKey>xxx</tns:webapiKey>
</tns:doGetCountries>
</env:Body>
</env:Envelope>
Wywala błąd: INVALID XML
Domyślam się że chodzi o namespaces w tym xmlu, ale nie wiem jak to naprawić.