Browse DevX
Sign up for e-mail newsletters from DevX


Developing Web Services in C++

A lot of press surrounds the Web services market today. But almost all of the information available for programmers is concentrated around Java and C#. This article intends to address this deficit by showing how to create a C++ Web Service (aka SOAP) client for Google's Web Service-enabled search API.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

omewhere north of a million. That, last time you counted, is the number of lines of C and C++ code keeping your organization running. And that is the number that runs through your head as you examine the literature surrounding Web services. The reason, of course, is that the bulk of information available on the subject is focused on developing Web services with Java, C#, Visual Basic, and other languages which, frankly, doesn't do you much good at all. Web services promises to make it easy to integrate C++ legacy systems with pretty much anything else, except for one catch: theres precious few products that support creating and deploying C++ Web services. This article provides an answer to this problem.

This article demonstrates how to write a SOAP client in C++. The client will exercise Google's SOAP-enabled search API, a service that accepts and answers search queries.

Resources for this Article
Before you begin writing any source code, it is necessary to get your house in order. You'll need to get a copy of Systinet's WASP Server for C++ that is appropriate for your environment, and Google's Developer's Kit. Both are free.

  • WASP Server for C++
    WASP is available for a variety of operating systems and compilers as a free download from Systinet's Web site. Even more appealing is that WASP is available for free deployment on single CPU machines. Purchasing a license is only necessary for deployment on multi-CPU hardware.
  • Google Developer's Kit

  • You will need to download Google's developer's kit, although all youll really use from that is the WSDL file that describes their services and the license key. It takes only moments and costs you nothing to register with Google. It goes without saying that you'll need a C++ compiler. In my case, I am using Red Hat Linux 7.3 and gcc 2.96.
A Brief Introduction to Web Services
Unfortunately, this is not the place for an in-depth discussion of SOAP and WSDL. If you are unfamiliar with both, we recommend looking at the whitepaper, "Introduction to Web Services," or you can check out the Related Resources in the left-hand sidebar.

Briefly, SOAP (Simple Object Access Protocol) is the core protocol underlying Web services. It defines an XML envelope in which a developer can place an XML payload. This envelope can be delivered to a service over a variety of transports, such as HTTP and SMTP. Further, SOAP, WSDL, and the development environment you use help define a mechanism for delivering this payload in such a way as to mimic remote procedure calls (RPC). SOAP also specifies a means of encoding data in a language neutral format. WSDL (Web Services Description Language) is the key to SOAP interoperability. It defines the "what, how, and where" of your Web services. Technically, it's a published, static XML document that describes the data types your service consumes and returns (like arrays and structures), the allowed input and output messages, the various services available, and the URLs where they can be found.

Google has made a series of SOAP services that, among other things, provide access to Google's search functionality. Technically, thats all you need to know up front. Everything else you can glean from their WSDL document as you proceed with this tutorial.

Editor's Note: Peter Lacey is an engineer for Systinet Corp.

Thanks for your registration, follow us on our social networks to keep up-to-date