Does anyone know of any really good C++ Libraries for implementing a web services api over top of existing legacy code?
I've got two portions that are in need of it:
An old-school client/server api (No, not web based, that's the problem)
An old cgi application that it integrates with the client and server.
Let me know if you've had any luck in the past implementing something like this using the library.
Microsoft has put out native code webservices API (WWSAPI) that looks pretty decent. I haven't had a chance to use it yet. We had originally ignored it, since it required Windows 7 or Server 2008, but they've finally released a runtime library for older OSs.
I would advise staying away from Microsoft's old SOAP SDK. For one, it's been deprecated; two, it's not terribly easy to distribute; and three, it's terrible to code for compared to the .NET offerings.
What we've done is written a bit of C++\CLI to interface our existing C++ codebase with .NETs webservice framework. This turned out to be remarkably easy. .NET will generate all the classes and boilerplate code you need based of of a WSDL file. Then you just write some C++\CLI code to handle the incoming data as managed classes and fill in some managed classes as responses.
You can use the Apache AXIS/C interface to build a web services interface. It has plugins for Apache and IIS (and I think FastCGI), and lets you talk web services to your legacy code.
I used gSOAP in a project and it was quite straightforward. Compared to Axis/C, I found it easier to learn and use. I never used POCO, can't give you an opinion, but it's gaining popularity recently. This is the link for gSOAP
http://www.cs.fsu.edu/~engelen/soap.html
Related
I am building a server-client application that involves heavy signal processing (e.g. FFT). I have a working application written in C++/Qt, where everything (signal processing and other calculations) is done in client and server just sends raw data. Now I feel it would be easier to implement these features on the server. So, that maintenance becomes easier.
As I am doing signal processing, I think I should stick to C++ for performance. But I am open to new ideas.
Constraints:
I need type checking so javascript is out of discussion.
Scaling includes adding more server and each server will have at the max
10-12 users. So, Hardware cost is important. I cannot use x number of
i7 processors.
No option of using cloud services.
So, right now my question is as follows:
How can I create web services using C++ for Linux server? (Although cross platform is not important, I would appreciate if I can achieve it.)
EDIT [02:09:2015]
Right now, I think the choice is between poco and C++ Rest SDK. I feel I should go for C++ Rest SDK. Mainly because it has only those features that I need. And Also it is supported by microsoft and uses boost internally. So, I feel in future, this might be well integreated with standard.
You could use cross-platform Poco library to implement HTTP server, it is really straightforward with this framework, and they have a lot of examples. You can also use JSON serialization (like rapidjson library) to implement REST service on top of HTTP - this way your Web service will be accesable by most of the modern Web frameworks.
You might want to take a look at the C++ Rest SDK, an open source, cross platform API from Microsoft.
Like #nogard suggested, I also recommend POCO for now. It's the most serious and feature-full solution. Given you mentioned Qt, I suggest you to take a look at Tufão.
EDIT:
I forgot to mention one comparison of mine on the C++ HTTP server frameworks.
If you directly handle HTTP requests, you might loose the functionality what Web Servers does well what it was build to do. I had a similar issue, what I did was wrap up my Qt c++ code inside a PHP extension. In your case you can do the same. Wrap your logic inside what ever technology you are about to use, doesn't matter it's PHP, net , Java or anything else.
I've seen a lot of topics for PayPal integration for sites, Java, C# and even Objective-C, but I can't seem to find anything on C/C++, specifically. So where can I look to get an idea of what might be necessary to go about adding PayPal into a C++ project that is intended to operate on Windows, Mac and Linux, at least?
The objective is to create an in-project store, along with an in-project donation jar of sorts. Is there a viable cross-platform solution, or does it need to be changed based on platform? Either way, is C/C++ still a possible language to write these per-platform systems?
Well, there is no official NVP library for C++ and I doubt using a third-party one (if it exists) is a good idea.
So, you should probably go with their SOAP API. Finding SOAP libs for C++ is not a problem.
Another option is simply using a webpage and opening it (that is, in the user's browser). Or you could integrate some HTML viewer.
I want to create a web application that runs with very little RAM and I think C++ can help me achieve that.
Now, many people say C++ is unsuited for web development because:
there is no easy string manipulation
is an unsafe language (overflows, etc)
long change / build / test cycles
etc.
But I'm sure the C++ community have found ways to alleviate all those (maybe not the compile time) however since I'm not a regular so it is hard for me to put a value on what I find in Google.
So I'm asking for some guidance. I would appreciate if you share what works, what tools/libs are current and alive. What strategies can help with web dev in C++? FastCGI or embedded server (Asio / POCO / Pion / etc.)? How do you address security concerns?
Thanks a lot for any help
Have you looked at http://www.tntnet.org/. They have created a... well let me cut and paste from their website:
Tntnet is a modular, multithreaded,
high performance webapplicationserver
for C++. To create webapplications
Tntnet has a template-language called
ecpp similar to php, jsp or mason,
where you can embed c++-code inside a
html-page to generate active content.
The ecpp-files are precompiled to
c++-classes called components and
compiled and linked into a shared
library. This process is done at
compiletime.
I've used it and it has quite a small overhead plus it has screamingly fast dynamic page generation. Makes PHP, Ruby etc snails in comparison because with tntnet you are running compiled C/C++ code.
There's the Wt Project. It uses a paradigm similar to Qt's signals/slots.
There is nothing wrong with trying to build a web app in C++. It's actually a lot of fun. What you need is a:
Templating system
A CGI lib
A database API wrapper, most likely, to avoid dealing with something like the low-level MySQL API
A logger
ATL Server is a library of C++ classes that allow developers to build internet based applications.
ATL Server. It's open source too! And of course there is always ISAPI. Ah, the bad old days. :)
In your other question you mention that your embedded system is openwrt. As this router firmware already comes with a embedded web server (for it's administration UI), why don't you use that for you app as well?
Our web app backend is in C++ via CGI and we use Clearsilver templates along with the HDF that comes with it.
Give us some more hints about what you're trying to do.
You can write a good old-fashioned cgi program in C++ easily enough, and run it with FastCGI. We used to do that all the time.
You could write a C++ program embedding a lightweight HTTP server as well.
Both of them are much bigger PITAs than using something like perl or ruby.
So for why C++?
Update
Okay, got it. The main thing about FastCGI is that it avoids a fork-exec to run your CGI program, but it is a little bit different API. That's good, but you still have the problem of handling the HTTP stuff.
There are, however, several very lightweight HTTP servers, like Cherokee and Lighttpd. In similar situations (building web interfaces for appliances) I've seen people use one of these and run their C/C++ programs under them as a CGI. Lighttpd in particular seems to concentrate on making CGI-like stuff fast and efficient.
Another update. I just had cgicc pointed out to me: http://www.gnu.org/software/cgicc/
That might solve some problems.
You can try Cutelyst a C++11 built with Qt, with one of the best positions on TechEmpower Benchmarks.
Even though it requires Qt 5.6+ a full CMS (CMlyst) uses around 6MB of RAM while serving around 3000 requests per seconds on a single core.
And for your string manipulation issue QString is just an amazing class for that.
My project is about to introduce SOAP. It's going to be used for C++ <-> Java and C++ <-> Flex communication. I'm responsible for refactoring our apps to take advantage of Java business rules engine and new Flex gui.
What resources are must read for C++ SOAP? I've read W3 materials. We're probably be using gSOAP on Solaris boxes.
There are some reasonably good books on SOAP, like Programming Web Services with SOAP by Snell, Tidwell, and Kulchenko; I've given that to people to introduce them to SOAP on projects in the past. I don't know of a C++-specific book, but the gSOAP site has pretty decent documentation.
I think the really key thing is probably to not dive into a complicated project right at first; there are some SOAP tutorials around, like this one, that build simple web services using gSOAP. Get the SOAP version of "Hello, world!" going firt, then maybe build that eBay client in the example, and you'll learn a lot of things you'd learn much more slowly and painfully trying to build a big example first.
Another option is to not use SOAP. Have you considered something like Protocol Buffers or Thrift?
We are looking for a C++ Soap web services framework that support RPC, preferably open source.
Any recommendations?
WSO2 Web Services Framework for C++ (WSO2 WSF/C++), a binding of WSO2 WSF/C into C++ is a C++ extension for consuming Web Services in C++.
http://wso2.org/projects/wsf/cpp
Apache Axis is an open source, XML based Web service framework. It consists of a Java and a C++ implementation of the SOAP server, and various utilities and APIs for generating and deploying Web service applications.
http://ws.apache.org/axis/
http://code.google.com/p/staff/
Staff is Web Service Framework for C++ (service/component and client-side)/JavaScript(client-side) based on Apache Axis2/C.
Open-source, released with Apache License V2.0.
Try the ffead-cpp framework, it provides in-built web-service support, rest, json and many other useful features.
We are using EasySoap (http://easysoap.sourceforge.net/)
While not FOSS another library is ATL Server library from Microsoft.
It is C++ template based with some proprietary attributes by Microsoft. i.e. not standard C++
You can check out xmlbeansxx. This is a kind of lightweight, low level solution, compared to complete frameworks. This has advantages in some cases.
Invoking SOAP WebServices using xmlbeansxx Article
Code example is here:
WsClient.cpp.
You could try gSOAP. Available under GPL and commercial licences.
I have used SWIG to make an interface from C++ to Java or Python and then used the typical web interface support for those languages.
Since Java and Python have reflection the web services frameworks that exist for them have a much easier time passing data around.
Threading wise if your C++ code is thread safe you can let the Java server manage the creation of threads for concurrent requests etc. and just call into your C++ code using JNI.
As a bonus you can test your C++ code from Python using these same SWIG interfaces.
I think the way to go is to write your service in C++ (I am assuming you did all the homework and there is a good reason you want to write in C++) and then front it using an RPC server. Use something like Thrift or Protobufs for a fast RPC implementation.
Now write your web frontend in the language of your choice - python would be mine - and make RPC calls to do all your heavy lifting.
POCO Remoting gives you a very simple way of creating web services in C++ by just annotating C++ class definitions with special comments and running a code generator over it. It's commercial, but delivered with full source code. A free eval version is available. Runs on Windows, Linux, Mac OS X, etc.
I concur with imjorge's answer and add that there's a C/C++ version of the Axis2 framework (a more flexible, extensible Axis) that does SOAP via RPC and all sorts of stuff including a bunch of the WS-* specs.
http://ws.apache.org/axis2/c/
Apache axis-c:
Simple to use, but seems abandoned.. not even download pages is working for several months
WSOF WSFCPP:
Fast quickstart dev, both binded or no-binded implementation, based on Apache AxisC and it seems most of the current developers of Apache Axis is from WSOF company. Besides the Great potential I've detected a memory leak.
I'm currently using Gsoap and It has very good performance.
Gsoap "mixed notation" between old c style and some (bad?) practices for C++ bothers me some.. but this is only code-furniture.
POCO:
Is a full-feature, modern (java?) like library. It is open source software, licensed under the Boost Software License 1.0. You'll have to write some things from scrach, but with great support, utility classes and etc great library.. Innovations from c++11+ with all boost initiatives + POCO + a new Build/Dependency system more "gradle like" will certainly bring c++ to new areas of development.