我知道如何为gsoap普通代码实现http get,但是当我使用gsoap和soapcpp2 -i生成代码时,我没有可用的soap_serve函数,也不知道如何/在哪里重新实现fget/http_get回调。
有人试过这个吗?
发布于 2012-09-20 01:47:48
很难理解你想要做什么。我将给出一个小的“食谱”例子(C++版本,但C语言看起来是一样的),这是我前段时间写的
a)编写正确的服务接口
$ 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);我只创建了一个简单的soap方法:命令成功
b)通过soapcpp生成服务类
soapcpp2 -S -i -2 -I /usr/share/gsoap/import service.h 请参见soapcpp2输出
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)查找函数serve或run。对于我的服务,我用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
https://stackoverflow.com/questions/12197024
复制相似问题