Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6842091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:03:21+00:00 2026-05-27T00:03:21+00:00

iam trying to build an multihreading webservice. Single threading is working, in my main

  • 0

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**)':
main.cpp:56: error:
soap_serve’ undeclared (first use this function)
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>
main.cpp:101: error:
soap_serve’ undeclared (first use this function)
make: *** [main.o] Fehler 1

How can i get this working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:03:22+00:00Added an answer on May 27, 2026 at 12:03 am

    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:

    // Content of file "calc.h": 
    //gsoap ns service name: Calculator 
    //gsoap ns service style: rpc 
    //gsoap ns service encoding: encoded 
    //gsoap ns service location: http://www.cs.fsu.edu/~engelen/calc.cgi 
    //gsoap ns schema namespace: urn:calc 
    //gsoap ns service method-action: add "" 
    int ns__add(double a, double b, double &result); 
    int ns__sub(double a, double b, double &result); 
    int ns__mul(double a, double b, double &result); 
    int ns__div(double a, double b, double &result);
    

    The main server code then looks like this:

    #include "soapCalculatorService.h"  // get server object 
    #include "Calculator.nsmap"     // get namespace bindings
    
    #include <pthread.h>
    
    void *process_request(void *calc) ;
    
    int main(int argc, char* argv[]) 
    { 
        CalculatorService c;
        int port = atoi(argv[1]) ;
        printf("Starting to listen on port %d\n", port) ;
        if (soap_valid_socket(c.bind(NULL, port, 100)))
        {
            CalculatorService *tc ;
            pthread_t tid; 
            for (;;)
            {
                if (!soap_valid_socket(c.accept()))
                    return c.error;
                tc = c.copy() ; // make a safe copy 
                if (tc == NULL) 
                    break; 
                pthread_create(&tid, NULL, (void*(*)(void*))process_request, (void*)tc); 
    
                printf("Created a new thread %ld\n", tid) ;
            }
        }
        else {
            return c.error;
        }
    
    } 
    
    
    void *process_request(void *calc) 
    { 
       pthread_detach(pthread_self());
       CalculatorService *c = static_cast<CalculatorService*>(calc) ;
       c->serve() ;
       c->destroy() ;
       delete c ;
       return NULL; 
    }  
    

    This is a very basic threading model but it shows how to use the C++ classes generated by gsoap to build a multithreaded server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iam trying to build a multidimensional array. public function saveRateTemplateData($RateTemplateInfo) { $RateTemplateID = $RateTemplateInfo['id'];
I am trying to build a function in C/C++ to sort an array and
Iam trying to build an Facebook Application based on PHP. The Application is running
I am trying to build a JQuery Mobile application. I want this application to
I am trying to build a web app like this using php, it has
I am trying to build my Android project with Ant. Whenever I use Eclipse
I am trying to build a messageQueue based around this messageStruct struct MessageStruct{ public:
I am trying to build a working encrypted signature for the Amazon S3 web
I am trying to build a messaging system and for this i have the
Iam currently working on a iPad project where i build my code on top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.