Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Savon ruby gem adds ins0 to tags

Using the savon gem, I get the following request XML:

<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:wsdl="URL" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:ins0="SOME URL">
        <soap:Body>
            <ins0:Test xmlns="SOME URL">
            </ins0:Test>
        </soap:Body>
    </soap:Envelope>

But it needs to be this instead:

<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:wsdl="URL" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <Test xmlns="SOME URL">
            </Test>
        </soap:Body>
    </soap:Envelope>

Notice ins0 was removed.

Any suggestions?

like image 873
Artem Kalinchuk Avatar asked Nov 05 '22 12:11

Artem Kalinchuk


1 Answers

The two XML documents are equivalent, so there should be no issues as long as the document is parsed by an XML compliant agent.

The Savon generated document is simply creating a namespace prefix of ins0 for the "SOME URL" namespace. This is convenient for a large SOAP document with many elements from that namespace. In this example, the prefix is not really necessary.

The only potential issue I can see is that the Savion generated document seems to declare the ins0 namespace twice - once in the soap:Envelope and then again in the soap:Body. Seems superfluous and potentially open to error.

like image 146
scaganoff Avatar answered Nov 15 '22 05:11

scaganoff