iam trying to build an multihreading webservice. Single threading is working, in my main function i use this:
int main(int argc, char **argv) {
CardSoapBindingService CardSrvc;
Config Conf ;
Conf.update();
int port = Conf.listener_port;
if (!port)
CardSrvc.serve();
else {
if (CardSrvc.run(port)) {
CardSrvc.soap_stream_fault(std::cerr);
exit(-1);
}
}
return 0;
}
But i want multithreading, so i looked in the documentation and found their example, which i tried instead my code. While compiling i get this errors:
main.cpp: In function int main(int, char**)':soap_serve’ undeclared (first use this function)
main.cpp:56: error:
main.cpp:56: error: (Each undeclared identifier is reported only once for each
function it appears in.)
main.cpp: In function void* process_request(void*)':<br>soap_serve’ undeclared (first use this function)
main.cpp:101: error:
make: *** [main.o] Fehler 1
How can i get this working?
Important:
This code requires gsoap version 2.8.5 as a minimum. It was initially built on Solaris 8 with gsoap version 2.8.3, porting the code to Ubuntu and running under valgrind showed that the 2.8.3 gsoap++ library was corrupting memory which lead to a SIGSEGV. It should be noted that as of 25/11/11 the version of gsoap that Ubuntu installs using apt-get is the broken 2.8.3. A manual download and build of the latest version of gsoap was required (make sure to install flex and bison before you configure the gsoap build!).
Using gsoap 2.8.5 the code below happily creates threads and serves SOAP messages to multiple clients, valgrind now reports 0 errors with the memory allocation.
Looking at your code the example you have working has been built with the -i (or -j) option to create C++ objects. The thread examples in the gsoap doumention are written in standard C; hence the reference to functions such as soap_serve() which you don’t have.
Below is my quick re-write of the multithreaded example to use the C+ objects generated. It is based on the following definition file:
The main server code then looks like this:
This is a very basic threading model but it shows how to use the C++ classes generated by gsoap to build a multithreaded server.