PHP XML-RPC server return code/error do not show in Perl XML-RPC client

565 views Asked by At

I am having a strange issue with XML-RPC.

I need to use an existing commercial XML-RPC API, written in PHP (extremely poorly, I must add, with horrible documentation), from a Perl script. I have tried with all Perl XML-RPC modules i could find (Frontier::Client, XML::RPC, RPC::XML), but generally this happens:

  • When my call is successful, i get the result, nothing wrong.

  • When it isn't (for whatever reason - failed authentication, missing/wrong parameters), i get nothing. An empty response(when using Frontier::Client, it says 500 Internal Server Error), without any error code/message.

  • But when I use the PHP test file the vendor of the commercial API have sent me, using the same methods and parameters, I get a response code and a response message(rarely useful, but nonetheless).

What could be the explanation of that? The library they use on the server side outputs the errors in some weird way? (Note: I think they use xmlrpc-2.2.2, at least that's what's used on the client side in the test PHP file). This is an example XML response with an error I get from the PHP client.

<?xml version="1.0" ?>
<methodResponse>
    <params>
        <param>
        <value>
            <struct>
                <member>
                    <name>demande</name>
                    <value>
                        <struct>
                            <member>
                                <name>0</name>
                                <value>
                                    <struct>
                                        <member>
                                            <name>codeReponse</name>
                                            <value>
                                                <int>-28</int>
                                            </value>
                                        </member>
                                        <member>
                                            <name>messageReponse</name>
                                            <value>
                                                <string>Verifiez l&apos;adresse email de validation</string>
                                            </value>
                                        </member>
                                    </struct>
                                </value>
                            </member>
                        </struct>
                    </value>
                </member>
            </struct>
        </value>
        </param>
    </params>
</methodResponse>

It's in French, but you would get the gist. Why does that appear properly in the PHP, but not in my Perl script, whatever library I use? And is there any way to remedy this, without telling the vendor of the API to rewrite their code properly?

1

There are 1 answers

0
Adrian Todorov On

Okay, turns out that the XML-RPC server is pretty picky and requires a set of headers and cookies to work(most of whom useless), otherwise it just outputs nothing.