XmlRpc client

Find and share HowTos to various installations / configurations!
5 posts • Page 1 of 1
jcbaar
Posts:34
Joined: Fri Sep 02, 2011 12:20 pm

XmlRpc client

Post by jcbaar »

Im am a little confused with xmlrpcClient() and related methods. Is it necessary to call a method on a XmlRpc server by doing:

xmlrpcClient();
xmlrpcConnectToServer();
xmlrpcCall();
xmlrpcCloseServer();

Each and every time you call a function on the server or do we just need to call xmlrpcClient(), xmlrpcConnectToServer() and xmlrpcCloseServer() once in a control session? I.E.:

xmlrpcClient();
xmlrpcConnectToServer();

..

xmlrpcCall();
xmlrpcCall();
xmlrpcCall();

..
xmlrpcCloseServer();

The documentation is not really clear on this. Both versions seem to work but I would like to know what the best practise is.
I am writing a control library wrapper for a xml-rpc service.

Regards,
Jan

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: XmlRpc client

Post by Gertjan van Schijndel »

The best solution also depends on the server and other network components. They might disconnect idle connections, so it requires extra function calls (and/or the tcp keepalive option).

In my experience with web services it is best to establish a new connection when there is a longer period of time between the function calls.

jcbaar
Posts:34
Joined: Fri Sep 02, 2011 12:20 pm

Re: XmlRpc client

Post by jcbaar »

Gertjan,

Thanks for the information. I'll open/close the connection on each method call to make sure.
One more question though. It will not be a problem to call xmlrpcClient() multiple times? I.E.

Code: Select all

void libFunc1()
{
  xmlrpcClient();
  xmlrpcOpenConnection();
  xmlrpCall();
  xmlrpcCloseConnection();
}

void libFunc1()
{
  xmlrpcClient();
  xmlrpcOpenConnection();
  xmlrpCall();
  xmlrpcCloseConnection();
}

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: XmlRpc client

Post by Gertjan van Schijndel »

It is no problem calling 'xmlrpcClient()' multiple times, but it is only required once.
With multiple concurrent connections you need to make sure that the connections use a different id.

By the way the xmlrpc control extension will call the function 'xmlrpcOnConnectionClose(string id)', when the connection has been closed.

jcbaar
Posts:34
Joined: Fri Sep 02, 2011 12:20 pm

Re: XmlRpc client

Post by jcbaar »

Gert-Jan,

Thanks for the information!
With these tips I am now confident that I am doing things in the correct manner.

Regards,
Jan

5 posts • Page 1 of 1