Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

Calling Web Services from Qt 4.5 using GSoap

3.25/5 (9 votes)
13 May 2009CPOL1 min read 65.2K   1.9K  
Calling Web Services from Qt 4.5 using GSoap.

Introduction

Looked around for a Qt with GSoap working sample straight-out-of-a-tar file, I failed to find one. So I thought I'd put one together. This is not a beginner tutorial for someone who wants to use Qt, nor does it give any introduction to GSoap. It is for folks who are quite conversant with Qt and Web Services, and want to use GSoap.

Overview

I am using: XUbuntu 8.10, with QT 4.5, GSoap 1.2.9l.

In my reckoning, there is nothing much to explain here. The code is pretty much self explanatory. I guess we need to pay particular attention to the .pro file and the files that need to be included.

Qt provides QtSoap to achieve something on the lines of GSoap. Well, with many using it, and GSoap being around for sometime and quite mature, I decided to go ahead with it.

The .pro file

I noticed much ado was about how the .pro file should look like. Well, here it is:

# -------------------------------------------------
# Project created by QtCreator 2009-05-04T22:46:55
# -------------------------------------------------
TARGET = qtQuote
TEMPLATE = app
 QT += xml\
xmlpatterns
INCLUDEPATH += /usr/include/gsoap
LIBS += -lgsoap++
SOURCES += main.cpp \
    mainwindow.cpp \
    soapC.cpp \
    soapStockQuoteSoapProxy.cpp
HEADERS += mainwindow.h \
    soapStockQuoteSoapProxy.h \
    soapStub.h \
    soapH.h
FORMS += mainwindow.ui

Application screenshot

The window which takes in the stock symbol will spit out the XML onto the text area below.

QtGsoap

Fairly basic, but what I wanted to show was a scaffolding to hold Qt and GSoap together. With QXmlQuery/QDom/SAX, we get the desired data-point out of the XML response.

Points of interest

Funnily though, even after I'd installed GSoap using Synaptic, I had to locally place the SoapCpp2.h, error2.h to make the app run. Also, we will have to see how it is going to build on OS X and Windows.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)