7

I need to use XmlRpc in C++ on a Windows platform. Despite the fact that my friends assure me that XmlRpc is a "widely available standard technology", there are not many libraries available for it. In fact I only found one library to do this on Windows, (plus another one that claims "you'll have to do a lot of work to get this to compile on Windows). The library I found was Chris Morley's "XmlRpc++". However, it doesn't have support for SSL.

My question therefore is: what library should I be using?

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
Tim Cooper
  • 10,023
  • 5
  • 61
  • 77

5 Answers5

9

I've written my own C++ library. It's available at sourceforge: xmlrpcc4win

The reason I wrote it rather than using Chris Morley's was that:

  • The Windows "wininet.lib" library gives you all the functionality for handling Http requests, so I'd rather use that. As a result, I only needed 1700 LOC.
  • "wininet.lib", and therefore my implementation, supports HTTPS
  • Chris Morley's use of STL containers was quite inefficient (Chris, mail me if you read this).
Tim Cooper
  • 10,023
  • 5
  • 61
  • 77
  • Thanks for this, I'm going to try that out. I have to admit though that I'm rather scared by this part in the TimXmlRpc.cpp file: #define not ! #define or || #define and && – Roel Jan 27 '10 at 11:14
  • Small update, I've been using this library with great success and it was very easy to implement. Highly recommended for anyone needing XmlRpc on Windows. – Roel Feb 12 '10 at 15:31
  • @TimCooper Does it support any way to make non-sync xmlrpc calls ? – Pit Digger Dec 31 '12 at 15:55
  • 1
    I've just tried Tim's "XmlRpc C++ for Windows" with Infusionsoft and by golly it works! Gotta pay close attention to how Infusionsoft nests structs within arrays, though. – Pierre Oct 03 '13 at 00:04
  • Thanks for sharing your lib! It doesn't seem to support Unicode though. Encoding is not specified in XML tag (hence defaults to UTF8). Client program must then convert strings to/from UTF8 before passing to the lib. Not very convenient. Also, the Release version of the project does not compile. I guess this one is not big an issue though since we use the source code only (and not the project). There are also strcpy / sprintf calls subject to buffer overflow. – Serge Wautier Jun 17 '15 at 12:50
4

Until I wrote my own library, (see above) here was my answer:

Currently, the XmlRpc++ library by Chris Morley is the only public domain/LPGL XmlRpc implementation for C++ on Windows.

There are a couple of C++ implementations for Linux, either of which could be presumably easily ported to Windows, but the fact seems to be that no-one has yet done so and made it publicly available. Also, as eczamy says, "The XML-RPC specification is somewhat simple and it would not be difficult to implement your own XML-RPC client."

I'm using Chris Morley's library successfully, despite having had to find and fix quite a number of bugs. The Help Forum for this project seems to be somewhat active, but no-one has fixed these bugs and done a new release. I have been in correspondence with Chris Morley and he has vague hopes to do a new release, and he has contributed to this stackOverflow question (see below/above) and he claims to have fixed most of the bugs, but so far he has not made a release that fixes the many bugs. The last release was in 2003.

It is disappointing to me that a supposed widely supported (and simple!) protocol has such poor support on Windows + C++. Please can someone reading this page pick up the baton and e.g. take over XmlRpc++ or properly port one of the Linux implementations.

Tim Cooper
  • 10,023
  • 5
  • 61
  • 77
1

I was able to get Tim's version of xml rpc working with https and with basic username / password authentication.

For the authentication:

1) the username and password need to be passed to the InternetConnect(...) function

2) an http request header of "Authorization: Basic base64encoded(user:pass)" needs to be added prior to sending the HttpSendRequest(...) command.

highvelcty
  • 131
  • 1
  • 4
  • can you send me your modified source code? I'll review and then put into the sourceforge version. You can reach me on tim@edval.com.au – Tim Cooper Feb 08 '13 at 23:54
1

Just wanted to note a couple of items:

  • The source in the cvs repository for XmlRpc++ has support for OpenSSL (although I have not tried it, it was contributed by another developer).

  • Most of the reported bugs are fixed in cvs; I don't have access to a linux machine at the moment, so I haven't made an official release.

  • XmlRpc++ is not public domain. It is copyrighted and licensed (LGPL).

Thanks, Chris Morley

Chris Morley
  • 891
  • 6
  • 16
1

There are dozens of implementations of the XML-RPC implementations, some in C++, but most in other languages. For example, besides XmlRpc++ there is also XML-RPC for C and C++. Here is a HOWTO on how the XML-RPC for C and C++ library can be used.

The XML-RPC specification is somewhat simple and it would not be difficult to implement your own XML-RPC client. Not to mention, it would also be possible to take an existing XML-RPC implementation in C and bring into your C++ project.

The XML-RPC home page also provides a lot of useful information.

eczarny
  • 389
  • 3
  • 7
  • The "XML-RPC for C and C++" library does not work on Windows - I quote: "...but the fact is that it probably won't work out-of-the-box on your Windows system." That means that there's only one library for C++ that runs on Windows, i.e. Chris Morley's, and it doesn't have SSL support. – Tim Cooper Sep 23 '08 at 01:49