0

我知道如何为 gsoap 普通代码实现 http get,但是当我使用 gsoap 和 生成代码时soapcpp2 -i,我没有可用的 soap_serve 函数,我不知道如何/在哪里重新实现 fget/http_get 回调

有没有人试过这个?

4

1 回答 1

1

It is hard to understand, what you try to do. I will give small "cookbook" example (C++ version, but C is looks the same), that i wrote some time ago with

a) write correct service interface

$ cat service.h

//gsoap ns service name:    mon Simple monitor service
//gsoap ns service encoding: literal 

//gsoap ns service namespace:   http://feniksa.dnsalias.com/hlanmon.wsdl
//gsoap ns service location:    http://feniksa.dnsalias.com:8888

//gsoap ns schema namespace:    urn:mon

#import "stlvector.h"


int ns__commandsuccess(std::string secret, int commandid, bool& status);

I created just one simple soap method: commandsuccess

b) generate service classes via soapcpp

soapcpp2 -S -i -2 -I /usr/share/gsoap/import service.h 

See soapcpp2 output

gsoap will generate a lot of files. See files: monService.h and monService.cpp (mon is name of service), also see soapH.h

c) implement service function For my example, i add to monService.cpp function

int monService::commandsuccess(std::string secret, int commandid, bool &status)
{
   // some logic here
    return SOAP_OK;
}

d) find function serve or run. For my service i wrote such code in main.cpp

#include "monService.h"

// other includes here

int main(int argc, char* argv[])
{
        // init code
        monService service;
       // other code here 
       service.serve();               // <- haha, i am here
      // other code
}

See this: https://freeman.svn.sourceforge.net/svnroot/freeman/other/trunk/gsoap

于 2012-09-19T17:47:48.123 回答