GSoap integration into Qt
-
I have been searching the internet and these forums for the past few days and it seems there is no complete guide to gSoap integration with Qt. Most topics get hijacked into other directions. I have been trying this for a few days now and felt the need for a complete tutorial. I am hoping this thread turns into a source that could then lead to a tutorial. So all of you who have successfully (or unsuccessfully) tried this please join in.
So far this is what I have got. I download gSoap. I then take a small wsdl server and using wsdl2h and soapcpp2 generate all the necessary files. I copy these files into the project, make changes into the .pro file and try to compile. I get a few errors, I remove some of them by including paths to different libraries in my .pro file. The error I am stuck on right now is this.
"undefined reference to 'soap_new'" - and all other functions of type soap_*
I have no idea what to do now. Please help.
My .pro file looks like this
@
QT += core
QT -= guiTARGET = soap
CONFIG += console
CONFIG -= app_bundleCONFIG += link_pkgconfig
PKGCONFIG += gsoap++TEMPLATE = app
SOURCES += main.cpp
gsoap/soapC.cpp
gsoap/soapClient.cppHEADERS +=
gsoap/soapStockQuoteSoapProxy.h
gsoap/soapH.h
gsoap/soapStub.h
gsoap/soapStockQuoteSoapObject.hOTHER_FILES +=
gsoap/StockQuoteSoap.nsmapINCLUDEPATH += C:\gsoap-2.8\gsoap
@And I have been following this tutorial to set it all up
"tutorial on forum Nokia":http://wiki.forum.nokia.com/index.php/GSoap:_SOAP_and_XML_Web_services_for_Qt_apps
-
Did you already try "this":http://lmgtfy.com/?q=undefined+reference+to+soap_init?
-
I’d suggest to use CMake, but I suppose mobile platforms are not enough flexible for it...
http://p.smar.fi/bc7f39862f0a582339e4e779b2e0bede6c96c587
And GSoap finder: http://p.smar.fi/659d361ca989819cdd123b4248899a8c8567d947
Maybe these give some idea how I implemented this.
EDIT:
also commands I’m using for generation:
@
smar@ran ~/P/pizzaohjelma> wsdl2h -o pizzawsdl.h "http://framework.ran/frontend/webservice/public/?wsdl"
smar@ran ~/P/pizzaohjelma> soapcpp2 -i -C pizzawsdl.h -I/usr/share/gsoap/import
@ -
Thank you Smar :)
Dear Volker,
I would love to indulge you (again) but I would hope that both of us have better things to do. Let me quote myself
bq. I have been searching the internet and these forums for the past few days and it seems there is no complete guide to gSoap integration with Qt
And just so that I make myself clear. Here is an extract from the links you so kindly googled for me
@
soap_init(soap1); -> soap_init() function takes an object of struct soap and
not a pointer to struct soap.Do:
soap struct soap1;
soap_init(&soap1);Or:
soap struct* soap1 = soap_new();
soap_init(soap1);
@Unfortunately, I am not making this mistake. The constructors and destructors are self generated and handle these things themselves.
Oh and from another link this is what matthew had to say
bq. Not sure about the include errors. I usually
just compile gsoap myself (that way I control the version) and link to my
compiled version. I am not sure where ubuntu puts everything. Maybe if you
send out your makefile people could see what you are doing.So now, I would very politely ask you to either look at my problem and help me solve it or just stay away. Like I already pointed out there is a dearth of good, easy to understand information on the internet regarding this topic. I have been searching for the better part of two days.
-
Then why not setup a test project that everyone that is interested in can download and try to compile it. You can have a perfectly crafted .pro file and have some errors in the code nontheless. Or the setup needs to be adapted to your specific platform.
We may guess by a single line in the .pro snippet that you are working on windows. You did not bother to give us this information (you might consider this information marginal and not neccessary, I don't know).
But to get back to the problem: If you did not install it yourself, Windows does not have pkg-config, so lines 8 and 9 of the .pro have no function. You will have to add the libs to LIBS variable manually.
-
Volker
Thank you :)
As you know, I am new and it completely slipped my mind that I should mention the platform as well (and I don't mind being told off for stuff like this). I have added a new line to my .pro file
@LIBS += C:\NokiaQtSDK\mingw\lib\libws2_32.a@
Still the error persists. I am going to look into the pkg-config thing. I have a feeling that the problem lies in there. Because I think the soap_* undefined problem stems from there.
-
And reading README and INSTALL text files of the libraries you use can also help:
[quote]README.txt:
To compile a client, all you need to do is to compile and link 'soapC.cpp', 'soapClient.cpp', and 'stdsoap2.cpp' (or the installed libgsoap++, see INSTALLATION below) with your code. [/quote]
[quote]INSTALL.txt:
You also need the following libraries (built from stdsoap2.c[pp]):
@
libgsoap++.a C++ runtime
libgsoapck++.a C++ runtime with HTTP cookie support
libgsoapssl++.a C++ runtime with cookies, zlib, and SSL
libgsoap.a C runtime
libgsoapck.a C runtime with HTTP cookie support
libgsoapssl.a C runtime with cookies, zlib, and SSL
@
Or you can use the stdsoap2.c and stdsoap2.cpp source directly, but you need to use the propoer -DWITH_X flags to enable support for 'X' (see above).
[/quote]EDIT:
To complete the things, you should add to your source list in the .pro:@
SOURCES += C:\gsoap-2.8\gsoap\stdsoap2.cpp
@And look for the WITH_XXX defines if you need SSL.
-
Gerolf - I am using windows xp and mingw compiler but my original problem has now been resolved. Thank you for your help and time.
It is my understanding that QtSoap is a paid addition and that support for it is very negligible that is why I was sticking with gSoap.
Like Volker pointed out the problem was with the pkg_config addition in my original .pro file.
It was not working. Instead of that I added the stdsoap2.cpp to my sources. The project now compiles. Both methods work, you can either add it like volker did above or you can simply copy paste it into the app folder and then add it to your sources.
There is a lot of junk in my code due to all the hit and trial. I shall post the minimum requirements to run gSoap once I sort through all of this.
Please continue this discussion with other problems that you are facing or have faced in the past.
-
QtSoap is also released under GPL and part of "QtSolutions":http://qt.gitorious.org/qt-solutions
I'm currently using it on a project and it works fine for my needs.
Hope it is of any help. -
According to the "Qt Solutions Archive":http://qt.nokia.com/products/qt-addons/solutions-archive/ page at Nokia, the Qt SOAP solution has been "relicensed under the BSD license".
-
[quote author="awasay" date="1301400187"]Gerolf - I am using windows xp and mingw compiler but my original problem has now been resolved. Thank you for your help and time.
It is my understanding that QtSoap is a paid addition and that support for it is very negligible that is why I was sticking with gSoap.
Like Volker pointed out the problem was with the pkg_config addition in my original .pro file.
It was not working. Instead of that I added the stdsoap2.cpp to my sources. The project now compiles. Both methods work, you can either add it like volker did above or you can simply copy paste it into the app folder and then add it to your sources.
There is a lot of junk in my code due to all the hit and trial. I shall post the minimum requirements to run gSoap once I sort through all of this.
Please continue this discussion with other problems that you are facing or have faced in the past.[/quote]
I remember seeing this problem too and solved it by linking the library against binary I’m compiling properly. Maybe those scripts of mine helps about that.
Are you using CPP mode or C mode of it? You need link different library regarding which way you are using.
EDIT: And yeah, Google has been for me completely useless about gsoap, and their own documentation barely mentions CPP side of this... I basically read the files myself and that way forced it to work... C side works better but it’s very annoying to use.
And using QtSoap is viable alternative if it is enough good for one’s needs; for me it was not.