kolo / xmlrpc

Implementation of XMLRPC protocol in Go language.
MIT License
159 stars 94 forks source link

How can I use "system.multicall" to call more than one methods ? #39

Open luxin88 opened 8 years ago

luxin88 commented 8 years ago

I am a golang new user.

but I don't know how can I call more than one methods at the same time, by using "system.multicall".

thanks alot.

luxin88 commented 8 years ago

the xml request looks like this

<?xml version="1.0"?>
<methodCall>
    <methodName>system.multicall</methodName>
    <params>
        <param>
            <value>
                <array>
                    <data>
                        <value>
                            <struct>
                                <member>
                                    <name>methodName</name>
                                    <value>main.get_trx_state</value>
                                </member>
                                <member>
                                    <name>params</name>
                                    <value>
                                        <array>
                                            <data>
                                                <value><nil/></value>
                                            </data>
                                        </array>
                                    </value>
                                </member>
                            </struct>
                        </value>
                        <value>
                            <struct>
                                <member>
                                    <name>methodName</name>
                                    <value>main.get_frequency</value>
                                </member>
                                <member>
                                    <name>params</name>
                                    <value>
                                        <array>
                                            <data>
                                                <value><nil/></value>
                                            </data>
                                        </array>
                                    </value>
                                </member>
                            </struct>
                        </value>
                        <value>
                            <struct>
                                <member>
                                    <name>methodName</name>
                                    <value>rig.get_mode</value>
                                </member>
                                <member>
                                    <name>params</name>
                                    <value>
                                        <array>
                                            <data>
                                                <value><nil/></value>
                                            </data>
                                        </array>
                                    </value>
                                </member>
                            </struct>
                        </value>
                        <value>
                            <struct>
                                <member>
                                    <name>methodName</name>
                                    <value>rig.get_bandwidth</value>
                                </member>
                                <member>
                                    <name>params</name>
                                    <value>
                                        <array>
                                            <data>
                                                <value><nil/></value>
                                            </data>
                                        </array>
                                    </value>
                                </member>
                            </struct>
                        </value>
                    </data>
                </array>
            </value>
        </param>
    </params>
</methodCall>
xmo-odoo commented 1 year ago

Fundamentally there's nothing special to system.multicall, while it can have dedicated support in the library (as in python) it's not necessary.

It does need to be implemented in the server, but aside from that it's just a regular function which takes an array of {methodName, params} structs, and returns the corresponding responses array, where each response is either the result of calling the method, or a {faultCode, faultString} struct.

So yes, if the server you're accessing supports system.multicall you can call it by crafting the multicall by hand.