How to call a Rest Service in C++?

19,846

Solution 1

On Linux, you probably could use curl library (and I guess it is ported to Windows). Curl is a library providing HTTP client functionality to a C or C++ program.

Solution 2

Use Casablanca. This should be helpful for people looking for this answer in 2013. CURL is perfectly appropriate but if you're doing C++ in Windows and using MS stuff, Casablanca seems fit.

Solution 3

I tried gsoap myself but it became difficult to maintain cross platform versions of my app. Instead i went the HTTP request route. For cross platform and C++ i found this Call Rest Web Services from C++

Solution 4

Hope the following articles might be of help to you

1. Accessing an XML Web Service Using C++

2. SOAP client for C++

Share:
19,846
adnangohar
Author by

adnangohar

Updated on June 20, 2022

Comments

  • adnangohar
    adnangohar almost 2 years

    I want to call a rest service written in WCF (which can support both XML and JSON Web Message Formats) from my C++ application.

    What is the best solution to achieve this ? I have seen some utilities (gsoap) which create proxy classes for you to be used to call web services.

    Can I achieve the same functionality without using any intermediate utility ? As its a rest service and it works using GET/PUT functions which are basic HTTP functions, is there any C++ library/Solution which could be used to invoke these function directly from a c++ application ?

  • pavloskkr
    pavloskkr over 12 years
    This sounds sensible to me - CURL is a pretty powerful library for HTTP programming.
  • jstuardo
    jstuardo over 7 years
    Casablanca does not seem to work for C++, but only for C++.NET
  • Dalinaum
    Dalinaum about 6 years
    No. It also supports macOS, iOS, Linux and Android. github.com/Microsoft/cpprestsdk/wiki
  • pixel
    pixel over 3 years
    It works for C++, I am just going through examples and have no issues. VS2017