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?
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).
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.
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.
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
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.
Related
I think it is better if I explain the situation so this doesn't seem too arcane a question. I want to release some starter code for a project I want some of my students to work on. The project involves scraping through some internet webpages and as such, I want to provide them with a URLStream class that will download the html of an input url and return it as a string to them.
The issue is that I can't seem to find a particularly nice way to deal with networking in a way that will be cross platform (the students have mac/windows/linux machines). I know of libraries like Boost asio and libCurl, but the issue with using these is that I can't enforce all my students download them. So my question is twofold:
Is there any nice way to provide them this cross platform networking code?
If a library is the only way to do this, is there any way to attach the library to the starter project so that students don't have to download it? I know this might be a stupid question but I can't seem to find out if this is possible.
Boost.Asio is really not suitable for your needs as it involves huge Boost and building at least some of its non-header-only libs. You can still consider Asio lib that can be used w/o Boost and is header-only lib, so much less hassle for you and your students. As it's probably the most popular and modern networking C++ lib this exercise can provide some useful experience to the students. Asio examples also have a simple HTTP client.
As a side note, are you bound to C++ for this assignment? It would be much simpler in Python or similar languages that provide networking out of the box.
The Berkeley sockets API is the most common low-level socket API. It is supported on all POSIX platforms which means both Linux and macOS will have it.
Even Windows have it, but with a slight twist since sockets aren't descriptors like they are on POSIX systems.
Using sockets directly will lead to more boiler-plate code, but it is definitely possible to use it to make a simple HTTP client that supports only simple GET requests.
There are many tutorials and references on using sockets. Beej's Guide to Network Programming seems to be a popular tutorial, which should have notes about the tweaks needed for Windows.
cross-platform C++ library for network programming
asio is a cross-platform C++ library for network programming that provides
developers with a consistent asynchronous I/O model using a modern C++
approach. It has recently been accepted into Boost.
I copied that from the info window in Synaptic. If you're using Linux, install the library (and its documentation) thus:
sudo apt-get install libasio-dev libasio-doc
I'm coding a C++ library that, among other things, needs to:
Search for a specific service in a network using AVAHI
Publish itself as a service using AVAHI
I've been searching for existent options. I've found that the creators of POCO C++ offer a DNS-SD library integrated with POCO C++. That would work, because I'm actually using POCO C++, but it's a commercial library, and I can't afford it.
Apart from that, avahi-daemon offers a client interface that allows browsing services and publishing new ones. It also sounds good, but I need my code to be portable, and work in major Linux distributions, Mac OS X and Windows. AFAIK, this solution would only cover Linux (where avahi-daemon is available).
I guess as partial solution, I could just send a properly formatted message via socket and process the raw response. That way, I could search for services published using AVAHI. But I think that's ugly and unmaintainable.
So, is there any good-enough solution for this without buying a software? I know this can be done using Python, but I need to do it in C++.
Many thanks in advance
There is an Open Source library (released under the LGPL) available over at http://avahi.org/. It exposes a C interface that can be very easily used in a c++ program.
There are also prebuilt binary version available for all major distros.
I intend to put/get file to/from an iRODS server. iRODS provides well documented JAVA and PHP APIs, however I'm looking for a C/C++ library providing such functions.
Are there libraries or examples of code I could use ?
Not exactly what you've requested, but you might be interested in Baton, which uses the iRODS C API, and has had a lot of work put into it, so you might be able to use it as-is, depending on your use case, rather than writing your own from scratch. Failing that, it provides a lot of examples of using the API.
If you have reasons that you must write your own, then in 4.x the the iRODS docs for the C API are much improved from the earlier 3.3.1 code path.
Good luck and do try the mailing list as a previous commenter mentioned - the developers respond often.
Is there a good, simple library which allows C++ to load a webpage? I just want to grab the source as text. I'm not using any IDE or significant library, just straight command line.
Tangentially, is there something fundamental I'm missing about programming in C++? I would think any language in common use today would have droves of web-based functionality, being so central to computer usage, but I can find next to no discussion on how to accomplish it. I realise C++ significantly predates the modern internet, so it lacking any core ability in the regard is reasonable, but the fact that relevant libraries seem so sparse is baffling.
Thanks for your help.
Sure, for example libcurl is powerful and popular.
Internet-related libraries for C++ are extremely abundant -- they're just not part of the C++ standard, partly because the current version of that standard is so old, though I'm sure that's not the only reason. But turn to the world of open sources and you'll find more than you can shake a stick at.
libcurl is a popular C library for fetching HTTP and other URLs. There's also cURLpp a C++ binding .
On Windows you have the WinINet and WinHTTP APIs.
I think HTTP is a bit too complex to be part of the C++ Standard Library. The specification would have to take a lot of details into account such as proxy servers and MIME types.
What are the alternatives for SOAP development in C++? Which one do you prefer and is most supported/modern?
Check out Apache Axis. That is my all times favorite SOAP implementation. It's SOAP done right! Exists for C++ and Java.
http://ws.apache.org/axis/
And in best traditions of Apache Foundation, it is FREE and OPENSOURCE.
So, enjoy!
I had to make SOAP calls for a project a while ago and the only acceptable solution I found was GSOAP.
http://www.cs.fsu.edu/~engelen/soap.html
It supports both C and C++ code, although working with C++ is nicer and easier to understand. It worked ok although there was an incompatibility with our WCF web service which meant we had to manually edit the automagically generated source code.
I stumbled on gsoap awhile ago, but I wasn't a huge fan of its interface and code generator. And as I remember it, the documentation is significantly lacking (or at least in a very difficult format).
Sometime in the near future, though, this library may be adding sockets support. At least, I suggested it to the developer some time ago and he seemed to think it was the idea, and a few months later an XML parser showed up in the API. I'm a big fan of that library, and would definitely use it more if it wasn't GPL.
If you are writing for Windows, Microsoft has a utility that comes with the Windows 7 SDK (And visual studio 2013 and later) called WSUTIL. It generates C proxies given a WDSL file, as shown in this example.
http://msdn.microsoft.com/en-us/library/windows/desktop/gg288974.aspx
KD Soap if you are in Qt C++. This is the URL
https://www.kdab.com/kd-soap/
SmartWin++ have a side-project called SmartSOAP which is pretty neat I think, it features a pretty complete stack starting from SocketStream, working its way up to HttpRequest/Response objects. Features a small (to the job) XML DOM class abstraction and goes up to SOAP. It even comes with a WSDL parser to create proxy classes for you. It heavily uses templates and STL. And is pretty awesome C++. Works on Windows Mobile...
Though it isn't extremely rich, doesn't feature stuff like SSL and such. But since the code is pure art I would guess it could easily be understood and extended upon yourself...
License is New BSD...
Disclaimer; I implemented it...