A
A
Anton Ivanov2015-06-22 10:05:21
Ruby on Rails
Anton Ivanov, 2015-06-22 10:05:21

Why is Savon generating invalid xml?

Hello.
The situation is this. There is a service with which it is necessary to communicate on the SOAP protocol.
PHP script works correctly. When I send a request from ruby, it is not accepted by the server.
Made a dump of both xml that are sent.
PHP:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ServiceName" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <ns1:soap_function>
            <params xsi:type="ns1:RequestType">
                ... список параметров
            </params>
        </ns1:soap_function>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Ruby (Savon):
<?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:typens="urn:ServiceName" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <typens:soap_function>
        ... список параметров
    </typens:soap_function>
  </env:Body>
</env:Envelope>

As you can see, in PHP the list of parameters is wrapped in one more tag, params. Savon does not.
If in the code, when calling the SOAP function, you wrap the parameters with your hands, then everything works correctly.
That is, do not a
client.call(:soap_function, message: params)
client.call(:soap_function, message: {params: params})

In this case, I had a working example before my eyes. And if it wasn't? Climb into wsdl? I hope that I just created the client in savon somehow wrong. Or perhaps another gem should already be used? :)
I create a client like this:
client = Savon.client(
        wsdl:             WSDL,
        ssl_verify_mode:  :none,
        pretty_print_xml: true,
        log_level:        :debug,
        raise_errors:     true,
        logger:           Rails.logger,
        log:              true)

Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai, 2015-06-22
@j_wayne

Savon is a very good SOAP gem. I think your best bet is to create an issue in the savon repository. It will explain if it's a feature or a bug.

J
Jeiwan, 2015-06-22
@Jeiwan

client.call(:soap_function, message: params) - why should it be wrapped in a params tag? It converts the hash to XML - what hash you pass, you get such XML tags

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question