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

标签 c++ gsoap

包含以下摘录的项目是使用 gsoap 生成的 c 绑定(bind)的客户端应用程序(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 时做错了什么吗?

谢谢

最佳答案

您正在取消引用空指针。

应该更好地工作:

_ns9__accountsResponse Result;
_ns7__accounts Input;

...

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

关于c++ - gSoap,c++,如何在客户端应用程序中传递 soapStub 声明的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5197389/

相关文章:

c++使用通过数据包接收的 key 加密文本? key 沙皇?

C++函数返回字符串

web-services - 如何在 Ubuntu 中部署 gSOAP Web 服务?

c++ - 检查在gcc 4.4.7中没有初始化whter atomic ptr(无nullptr)

c++ - C++11 标准中的哪个子句允许我在下面的 `A` 中删除 `return` 语句中的 `A::operator-()`?

c++ - cartTexture 成员实际上是否正确初始化?

c++ - 覆盖 gSOAP 中的命名空间

c++ - 来自自定义库的 Openssl 和 gsoap

c++ - gSoap 不发送超过 4 个字节的响应

c++ - 检查 CRL OpenSSL C