0

我下载了 gsoap 2.8.14,使用以下命令配置和安装:

./configure --disable-ssl --enable-samples --enable-debug
make
make install

我试图编译 gsoap 示例“你好”。所以我从示例中获取了 wsdl 文件并执行了以下操作:

wsdl2h -s -o hello.h h.wsdl
soapcpp2 hello.h

我将生成的文件复制到一个新的 eclipse c++ 项目中并排除了soapClientLib.cpp 和soapServerLib.cpp,因为我收到了类似的错误

多重定义......

然后我创建了一个 helloserver.cpp,这是内容:

#include "soapH.h"
#include "Service.nsmap"

int main() 
{
  return soap_serve(soap_new);
}

int __ns1__hello(struct soap *soap, char* helloReq, char* &helloResponse)
{
  return SOAP_OK;
}

当我在 Eclipse 中构建时,我收到一个错误:

...soapServer.cpp:77 undefined reference to __ns1__hello(soap*,_ns2_hello*, _ns__helloResponse*)

当我跟踪到soapServer.cpp 时,这一行出现错误:

soap->error=__ns1_hello(soap,soap_tmp___ns1_hello.ns2__hello,&ns2__helloResponse);

为什么我会收到此错误?我使用来自 gsoap 的示例 hello wsdl

4

1 回答 1

1

正如您从错误消息(和soapServer.cpp 代码)中看到的那样,您应该编写一个函数

int __ns1__hello(struct soap *soap, 
    _ns2_hello* helloReq, 
    _ns__helloResponse* helloResponse)
{
  return SOAP_OK;
}

不是你写的函数。

于 2013-05-08T09:30:12.197 回答