试图理解 gsoap

发布于 2024-10-30 17:27:50 字数 1052 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱娆 2024-11-06 17:27:50

函数 GetData 中的第一个参数 _ns1__GetData 是请求参数,第二个参数是响应参数。您应该尝试以下操作:

_ns1__GetData request;
request.???? = ???? // I don't know the WCF Webservice
_ns1__GetDataResponse response;
if(webService.GetData(&request, &response) == SOAP_OK)
{
    std::cout << "Returned " << response.????;
}

我不知道 WCF Web 服务。但我想你必须用一些值填充请求实例。让我想知道的是,类名 _ns1__GetData_ns1__GetDataResponse 以下划线开头。我使用 gSoap 很长时间了,并且名称总是没有以下划线开头。

The first argument _ns1__GetData in the function GetData is the request argument, the second is the response argument. You should try following:

_ns1__GetData request;
request.???? = ???? // I don't know the WCF Webservice
_ns1__GetDataResponse response;
if(webService.GetData(&request, &response) == SOAP_OK)
{
    std::cout << "Returned " << response.????;
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文