简体   繁体   中英

gSoap, c++, how to pass a soapStub declared argument in client application

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

You are dereferencing null pointers.

Should work better with:

_ns9__accountsResponse Result;
_ns7__accounts Input;

...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM