试图理解 gsoap
我正在使用 gsoap 创建我的第一个 Web 服务客户端。我能够运行 gsoap 提供的 calc 示例。
现在我尝试从 WCF Web 服务访问 String GetData() 函数。我执行了 wsdl2h 和soocpp2 步骤并生成了 .h 文件。在xxxxproxy.h中我看到GetData的原型如下
/// Web service operation 'GetData' (returns error code or SOAP_OK)
virtual int GetData(_ns1__GetData *ns1__GetData, _ns1__GetDataResponse *ns1__GetDataResponse);
Can someone tell me what should I write in my main.cpp to access GetData. I have following code in main.cpp
#include <QtCore/QCoreApplication>
#include "soapWSHttpBinding_USCOREIAquaLinkProxy.h"
#include "WSHttpBinding_USCOREIAquaLink.nsmap"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
WSHttpBinding_USCOREIAquaLinkProxy webService;
std::cout <<"Sent request"<<std::endl;
std::string result;
if(webService.GetData(?????? )==SOAP_OK)
{
std::cout << "Returned "<< ????? <<std::endl;
}
else
{
webService.soap_stream_fault(std::cerr);
}
return a.exec();
}
谢谢。
I am creating my first web service client using gsoap. I was able to the run the calc example provided with gsoap.
Now I am trying to access String GetData() function from WCF Webservice. I did the wsdl2h and soapcpp2 steps and have generated the .h file. In xxxxproxy.h I see that the prototype of GetData is as follows
/// Web service operation 'GetData' (returns error code or SOAP_OK)
virtual int GetData(_ns1__GetData *ns1__GetData, _ns1__GetDataResponse *ns1__GetDataResponse);
Can someone tell me what should I write in my main.cpp to access GetData. I have following code in main.cpp
#include <QtCore/QCoreApplication>
#include "soapWSHttpBinding_USCOREIAquaLinkProxy.h"
#include "WSHttpBinding_USCOREIAquaLink.nsmap"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
WSHttpBinding_USCOREIAquaLinkProxy webService;
std::cout <<"Sent request"<<std::endl;
std::string result;
if(webService.GetData(?????? )==SOAP_OK)
{
std::cout << "Returned "<< ????? <<std::endl;
}
else
{
webService.soap_stream_fault(std::cerr);
}
return a.exec();
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
函数
GetData
中的第一个参数_ns1__GetData
是请求参数,第二个参数是响应参数。您应该尝试以下操作:我不知道 WCF Web 服务。但我想你必须用一些值填充请求实例。让我想知道的是,类名
_ns1__GetData
和_ns1__GetDataResponse
以下划线开头。我使用 gSoap 很长时间了,并且名称总是没有以下划线开头。The first argument
_ns1__GetData
in the functionGetData
is the request argument, the second is the response argument. You should try following:I don't know the WCF Webservice. But I guess that you have to fill the request instance with some values. What makes me wonder is, that the class names
_ns1__GetData
and_ns1__GetDataResponse
begin with an underscore. I'm using gSoap for a long time and the names were always without beginning underscore.