gSoap,c++,如何在客户端应用程序中传递soapStub声明的参数

发布于 2024-10-20 20:55:53 字数 2236 浏览 1 评论 0原文

包含以下摘录的项目是使用 gsoap 生成的 C 绑定的客户端应用程序 ( gsoap - www.cs.fsu.edu/~engelen/soap.html ) 该项目构建良好,但在下面所示的主函数中出现断线。

在项目头文件中定义:

class SOAP_CMAC _ns7__accounts
{
public:
std::vector<std::string>accountNumber;  /* required element of type xsd:string */
std::string *requestIDTrackingForESB;   /* optional attribute */
struct soap *soap;  /* transient */
public:
virtual int soap_type() const { return 23; } /* = unique id     SOAP_TYPE__ns7__accounts */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
         _ns7__accounts(): requestIDTrackingForESB(NULL), soap(NULL) { _ns7__accounts::soap_default(NULL); }
virtual ~_ns7__accounts() { }
};

并在随附的 .cpp 文件中定义:

 int addressByAccount_ExtWS_BPELSOAPProxy::accountsBPEL(_ns7__accounts *ns7__accounts, _ns9__accountsResponse *ns9__accountsResponse);

在我的 main() 中,我声明 service 以提高可读性:

addressByAccount_ExtWS_BPELSOAPProxy service.

这是我的 main.cpp

#include <iostream>
#include "soapaddressByAccount_ExtWS_BPELSOAPProxy.h"
#include "addressByAccount_ExtWS_BPELSOAP.nsmap"
#include <winsock2.h>
using namespace std;
struct soap *soap;

int main()
{ 
    addressByAccount_ExtWS_BPELSOAPProxy service;
    _ns9__accountsResponse *pResult = 0;
    _ns7__accounts *pInput = 0; //_ns7__account is defined in .h excerpt above
    char account[] = "00000201"; //input value attempting pass to web service

    //std::vector<std::string>accountNumber; defined in .h excerpt above, 

    pInput->accountNumber.push_back(account); //breaks here - 0xC0000005 returned.

    if (service.accountsBPEL(pInput, pResult) == SOAP_OK)
    {
      cout << "soap OK!" << endl; ;
    }

    else
        service.soap_stream_fault(std::cerr);

    return 0;
}

任何人都有一个知道我将字符串分配给 pInput 时做错了什么吗?

谢谢

the project containing the following excerpts is a client application using gsoap generated c bindings ( gsoap - www.cs.fsu.edu/~engelen/soap.html )
The project builds fine, but breaks on the line in the main function indicated below.

defined in a project header file:

class SOAP_CMAC _ns7__accounts
{
public:
std::vector<std::string>accountNumber;  /* required element of type xsd:string */
std::string *requestIDTrackingForESB;   /* optional attribute */
struct soap *soap;  /* transient */
public:
virtual int soap_type() const { return 23; } /* = unique id     SOAP_TYPE__ns7__accounts */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
         _ns7__accounts(): requestIDTrackingForESB(NULL), soap(NULL) { _ns7__accounts::soap_default(NULL); }
virtual ~_ns7__accounts() { }
};

and defined in an accompanying .cpp file:

 int addressByAccount_ExtWS_BPELSOAPProxy::accountsBPEL(_ns7__accounts *ns7__accounts, _ns9__accountsResponse *ns9__accountsResponse);

In my main() I declare service for readability:

addressByAccount_ExtWS_BPELSOAPProxy service.

Here is my main.cpp

#include <iostream>
#include "soapaddressByAccount_ExtWS_BPELSOAPProxy.h"
#include "addressByAccount_ExtWS_BPELSOAP.nsmap"
#include <winsock2.h>
using namespace std;
struct soap *soap;

int main()
{ 
    addressByAccount_ExtWS_BPELSOAPProxy service;
    _ns9__accountsResponse *pResult = 0;
    _ns7__accounts *pInput = 0; //_ns7__account is defined in .h excerpt above
    char account[] = "00000201"; //input value attempting pass to web service

    //std::vector<std::string>accountNumber; defined in .h excerpt above, 

    pInput->accountNumber.push_back(account); //breaks here - 0xC0000005 returned.

    if (service.accountsBPEL(pInput, pResult) == SOAP_OK)
    {
      cout << "soap OK!" << endl; ;
    }

    else
        service.soap_stream_fault(std::cerr);

    return 0;
}

Anybody have an idea of what I am doing wrong with assigning the string to pInput ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

表情可笑 2024-10-27 20:55:53

您正在取消引用空指针。

应该更好地配合:

_ns9__accountsResponse Result;
_ns7__accounts Input;

...

if (service.accountsBPEL(&Input, &Result) == SOAP_OK)

You are dereferencing null pointers.

Should work better with:

_ns9__accountsResponse Result;
_ns7__accounts Input;

...

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