[SR-Users] RPC, XMLRPC or other

Kristofer Signer kristofer.signer at gmail.com
Tue Nov 13 14:29:43 CET 2012


Thank you all for you questions.

On Tue, Nov 13, 2012 at 1:51 PM, Carlos Ruiz Díaz
<carlos.ruizdiaz at gmail.com> wrote:
> If you write your own parser you will be writing your own implementation of
> the xmlrpc decoder which I believe could be very complicated not even
> mentioning that it's close to reinventing the wheel.
>
> I think Carsten's solution is the best right now. I'll try his approach
> myself.


Another solution is to use the 'mi' method together with the 'ul_dump'
mi-command
<?xml version='1.0'?>
<methodCall>
<methodName>mi</methodName>
<params>
<param>
<value><string>ul_dump</string></value>
</param>
</params>
</methodCall>

This call will return an array which is xmlrpc-correct Then I can use
any xmlrpc parser to get the data and when the xmlrpc library is done
I'll have an string array where every string is a key-value pair which
I can take care of.

It is similar to Carstens solution but you don't need to serialize it
to CVS format.

./Kristofer






>
> Best Regards.
>
> --
> Carlos
> http://caruizdiaz.com
> +595981146623
>
> On Tue, Nov 13, 2012 at 8:24 AM, Kristofer Signer
> <kristofer.signer at gmail.com> wrote:
>>
>> Hello,
>>
>>
>> On Tue, Nov 13, 2012 at 5:03 AM, Carlos Ruiz Díaz
>> <carlos.ruizdiaz at gmail.com> wrote:
>> > Hello,
>> >
>> > I've been through this problem a few weeks ago with my module that
>> > exports
>> > nested structures through xmlrpc. Apparently, there's a limitation in
>> > the
>> > technology itself that makes the nested structures to be overwritten
>> > everytime the response XML is parsed, if you look closely, you will
>> > notice
>> > that this makes sense since the structures are indexed by the name of
>> > the
>> > field, which is the same for every record. That's the reason of only one
>> > row
>> > being displayed even though the whole recordset was sent out.
>>
>> Yes, I have noticed this. And the problem is that a struct is just a
>> key-value-pair datatype which in normal situation does not support
>> multiple key with the same name.
>>
>> A more correct implementation would be to represent the AoRs in an array.
>>
>> I think I will also write a work around for this. just parsing the return
>> xml.
>>
>>
>>
>>
>> >
>> > I tried with three different php libraries, even with xmlrpc_decode()
>> > that
>> > is the official function for decoding xmlrpc responses in php.
>> >
>> > I didn't find a solution but I ended up using a workaround sending the
>> > values using CSV format which was later parsed by the PHP in charge of
>> > displaying the data.
>> >
>> > Regards.
>> >
>> > Carlos.
>> >
>> > On Mon, Nov 12, 2012 at 11:43 PM, Daniel-Constantin Mierla
>> > <miconda at gmail.com> wrote:
>> >>
>> >> Hello,
>> >>
>> >> I am not a python parameter, but seems a limitation of the
>> >> xmlrpc_test2.py
>> >> tool, the tcp dump shows that the records are sent back in the xmlrpc
>> >> response.
>> >>
>> >> You will have to look inside/troubleshoot the xmlrpc_test2.py and see
>> >> why
>> >> it fails.
>> >>
>> >> Cheers,
>> >> Daniel
>> >>
>> >>
>> >> On 11/12/12 9:58 AM, Kristofer Signer wrote:
>> >>
>> >> Hello,
>> >>
>> >> running kamailio 3.3.2.
>> >>
>> >> On Mon, Nov 12, 2012 at 1:48 PM, Daniel-Constantin Mierla
>> >> <miconda at gmail.com> wrote:
>> >>>
>> >>> Hello,
>> >>>
>> >>>
>> >>> On 11/12/12 10:02 AM, Kristofer Signer wrote:
>> >>>>
>> >>>> Hello,
>> >>>>
>> >>>> I'm trying to dig in to the kamailio XMLRPC interfaces and the
>> >>>> limitations I read in
>> >>>>
>> >>>> http://www.kamailio.org/docs/modules/stable/modules/xmlrpc.html#xmlrpc.implementation.limitations
>> >>>>
>> >>>> is really a no go for us.
>> >>>
>> >>> which one is a 'no go'? Nested structures are supported in the last
>> >>> version, iirc, the readme does not seem to be updated for this case.
>> >>
>> >> the 'no go' is the structure {AoR, HashID, Contact, AoR, HashID,
>> >> Contacts,
>> >> ...}
>> >>>
>> >>>
>> >>>
>> >>>>
>> >>>> For example, when to retrieve user locations and list of dialogs we
>> >>>> get
>> >>>> a xml document which is not so well formatted and we can not
>> >>>> successfully
>> >>>> parse it in an xmlrpc-parser.
>> >>>>
>> >>>> Is there other options for xmlrpc module?
>> >>>
>> >>>
>> >>> If the body is not successfully parsed, it is a bug. The limitation is
>> >>> about not supporting all the data types, but when a reply is xmlrpc
>> >>> sent, it
>> >>> should be valid. Can you test it with 1-2 location records that fail
>> >>> and
>> >>> post the xmrpc here as well as the log error messages from the xml
>> >>> parser?
>> >>
>> >>
>> >> Actually, I don't get any errors. I'm using the python example provided
>> >> in
>> >> kamailio src and that example will only parse out one record.
>> >>
>> >>
>> >> [krsi at vera examples]$ python xmlrpc_test2.py ul.dump foo
>> >> {'Domain': 'location', 'Stats': {'Records': 2, 'Max-Slots': 1}, 'AoRs':
>> >> {'HashID': 1731621673, 'AoR': 'jkp-01', 'Contacts': {'Contact':
>> >> {'Ruid':
>> >> 'uloc-50a0ea3c-124bf-1', 'Received': '[not set]', 'Path': '[not set]',
>> >> 'Reg-Id': 0, 'Expires': 99, 'Flags': 0, 'User-Agent': 'Jitsi1.0-Linux',
>> >> 'Q':
>> >> 0.0, 'Instance': '[not set]', 'State': 'CS_SYNC', 'CSeq': 11,
>> >> 'Methods':
>> >> 18446744073709551615L, 'CFlags': 0, 'Address':
>> >>
>> >> 'sip:jkp-01 at 192.168.0.214:25060;transport=udp;registering_acc=foo_bar_com',
>> >> 'Call-ID': '61ac73a44826f3887a5db2371b044275 at 0:0:0:0:0:0:0:0',
>> >> 'Socket':
>> >> 'udp:192.168.0.82:5060'}}}, 'Size': 512}
>> >>
>> >> As you can see,. there should be two records but only one is parsed.
>> >>
>> >>
>> >> Here is the response body from tcpdump
>> >>
>> >> <?xml version="1.0"?>
>> >> <methodResponse>
>> >> <params>
>> >> <param>
>> >> <value><struct>
>> >>
>> >>
>> >> <member><name>Domain</name><value><string>location</string></value></member>
>> >>   <member><name>Size</name><value><int>512</int></value></member>
>> >>   <member>
>> >>     <name>AoRs</name>
>> >>     <value><struct>
>> >>
>> >> <member><name>AoR</name><value><string>jkp-02</string></value></member>
>> >>
>> >>
>> >> <member><name>HashID</name><value><int>1731621670</int></value></member>
>> >>       <member>
>> >>         <name>Contacts</name>
>> >>         <value><struct>
>> >>           <member>
>> >>             <name>Contact</name>
>> >>             <value><struct>
>> >>
>> >>
>> >> <member><name>Address</name><value><string>sip:jkp-02 at 192.168.0.214:35060</string></value></member>
>> >>
>> >> <member><name>Expires</name><value><int>768</int></value></member>
>> >>
>> >> <member><name>Q</name><value><double>0.000000</double></value></member>
>> >>
>> >>
>> >> <member><name>Call-ID</name><value><string>rcilzqsjfpnuihl at vera.foo.com</string></value></member>
>> >>
>> >> <member><name>CSeq</name><value><int>383</int></value></member>
>> >>
>> >>
>> >> <member><name>User-Agent</name><value><string>Twinkle/1.4.2</string></value></member>
>> >>               <member><name>Received</name><value><string>[not
>> >> set]</string></value></member>
>> >>               <member><name>Path</name><value><string>[not
>> >> set]</string></value></member>
>> >>
>> >>
>> >> <member><name>State</name><value><string>CS_SYNC</string></value></member>
>> >>
>> >> <member><name>Flags</name><value><int>0</int></value></member>
>> >>
>> >> <member><name>CFlags</name><value><int>0</int></value></member>
>> >>
>> >>
>> >> <member><name>Socket</name><value><string>udp:192.168.0.82:5060</string></value></member>
>> >>
>> >> <member><name>Methods</name><value><int>6111</int></value></member>
>> >>
>> >>
>> >> <member><name>Ruid</name><value><string>uloc-50a0ea3c-124c0-1</string></value></member>
>> >>               <member><name>Instance</name><value><string>[not
>> >> set]</string></value></member>
>> >>
>> >> <member><name>Reg-Id</name><value><int>0</int></value></member>
>> >>             </struct></value>
>> >>           </member>
>> >>         </struct></value>
>> >>       </member>
>> >>       <member>
>> >>         <name>AoR</name><value><string>jkp-01</string></value></member>
>> >>
>> >>
>> >> <member><name>HashID</name><value><int>1731621673</int></value></member>
>> >>         <member>
>> >>           <name>Contacts</name>
>> >>           <value><struct>
>> >>             <member>
>> >>               <name>Contact</name>
>> >>               <value><struct>
>> >>
>> >>
>> >> <member><name>Address</name><value><string>sip:jkp-01 at 192.168.0.214:25060</string></value></member>
>> >>
>> >> <member><name>Expires</name><value><int>185</int></value></member>
>> >>
>> >> <member><name>Q</name><value><double>0.000000</double></value></member>
>> >>
>> >>
>> >> <member><name>Call-ID</name><value><string>61ac73a44826f3887a5db2371b044275 at 0:0:0:0:0:0:0:0</string></value></member>
>> >>
>> >> <member><name>CSeq</name><value><int>12</int></value></member>
>> >>
>> >>
>> >> <member><name>User-Agent</name><value><string>Jitsi1.0-Linux</string></value></member>
>> >>                 <member><name>Received</name><value><string>[not
>> >> set]</string></value></member>
>> >>                 <member><name>Path</name><value><string>[not
>> >> set]</string></value></member>
>> >>
>> >>
>> >> <member><name>State</name><value><string>CS_SYNC</string></value></member>
>> >>
>> >> <member><name>Flags</name><value><int>0</int></value></member>
>> >>
>> >> <member><name>CFlags</name><value><int>0</int></value></member>
>> >>
>> >>
>> >> <member><name>Socket</name><value><string>udp:192.168.0.82:5060</string></value></member>
>> >>
>> >>
>> >> <member><name>Methods</name><value><int>18446744073709551615</int></value></member>
>> >>
>> >>
>> >> <member><name>Ruid</name><value><string>uloc-50a0ea3c-124bf-1</string></value></member>
>> >>                 <member><name>Instance</name><value><string>[not
>> >> set]</string></value></member>
>> >>
>> >> <member><name>Reg-Id</name><value><int>0</int></value></member>
>> >>               </struct></value>
>> >>             </member>
>> >>           </struct></value>
>> >>         </member>
>> >>       </struct></value>
>> >>     </member>
>> >>     <member>
>> >>       <name>Stats</name>
>> >>       <value><struct>
>> >>
>> >> <member><name>Records</name><value><int>2</int></value></member>
>> >>
>> >> <member><name>Max-Slots</name><value><int>1</int></value></member>
>> >>       </struct></value>
>> >>     </member>
>> >>   </struct></value>
>> >> </param>
>> >> </params>
>> >> </methodResponse>
>> >>
>> >>
>> >>
>> >> and for reference, the same command from kamctl:
>> >>
>> >>  [krsi at sipproxy1 ~]$  kamctl mi ul_dump
>> >> Domain:: location table=512 records=2 max_slot=1
>> >>         AOR:: jkp-02
>> >>                 Contact:: sip:jkp-02 at 192.168.0.214:35060 Q=
>> >>                         Expires:: 1961
>> >>                         Callid:: rcilzqsjfpnuihl at vera.foo.se
>> >>                         Cseq:: 383
>> >>                         User-agent:: Twinkle/1.4.2
>> >>                         State:: CS_SYNC
>> >>                         Flags:: 0
>> >>                         Cflag:: 0
>> >>                         Socket:: udp:192.168.0.82:5060
>> >>                         Methods:: 6111
>> >>                         Ruid:: uloc-50a0ea3c-124c0-1
>> >>                         Reg-Id:: 0
>> >>         AOR:: jkp-01
>> >>                 Contact:: sip:jkp-01 at 192.168.0.214:25060 Q=
>> >>                         Expires:: 298
>> >>                         Callid::
>> >> 61ac73a44826f3887a5db2371b044275 at 0:0:0:0:0:0:0:0
>> >>                         Cseq:: 10
>> >>                         User-agent:: Jitsi1.0-Linux
>> >>                         State:: CS_SYNC
>> >>                         Flags:: 0
>> >>                         Cflag:: 0
>> >>                         Socket:: udp:192.168.0.82:5060
>> >>                         Methods:: 4294967295
>> >>                         Ruid:: uloc-50a0ea3c-124bf-1
>> >>                         Reg-Id:: 0
>> >>
>> >>
>> >> Thanks
>> >> ./Kristofer
>> >>
>> >>>
>> >>> For example, siremis uses the xmlrpc interface and all is ok with
>> >>> handling the replies. It uses a library from php pear.
>> >>>
>> >>> Cheers,
>> >>> Daniel
>> >>>
>> >>> --
>> >>> Daniel-Constantin Mierla - http://www.asipto.com
>> >>> http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
>> >>>
>> >>
>> >>
>> >> --
>> >> Daniel-Constantin Mierla - http://www.asipto.com
>> >> http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
>> >>
>> >>
>> >> _______________________________________________
>> >> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> >> sr-users at lists.sip-router.org
>> >> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>> >>
>> >
>
>
>
>
> --
> Carlos
> http://caruizdiaz.com
> +595981146623
>



More information about the sr-users mailing list