使用带有gsoap代理类的gsoap独立服务器实现http-get

Implement http get with gsoap standalone server with gsoap proxy classes

本文关键字:gsoap 独立 服务器 实现 http-get 代理      更新时间:2023-10-16

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

有人试过这个吗?

这很难理解,你试图做什么。我将举一个小的"食谱"示例(C++版本,但C看起来是一样的),这是我不久前用写的

a) 编写正确的服务接口

$cat服务.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);

我只创建了一个简单的soap方法:commandsuccess

b) 通过soapcpp 生成服务类

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

请参阅soapcp2输出

gsoap将生成大量文件。参见文件:monService.h和monService.cpp(mon是服务名称),也参见soapH.h

c) 实现服务功能在我的例子中,我添加了monService.cpp函数

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

d) 查找函数服务或运行。为了我的服务,我在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
}

请参阅:https://freeman.svn.sourceforge.net/svnroot/freeman/other/trunk/gsoap