簡體   English   中英

gSoap,C ++,如何在客戶端應用程序中傳遞soapStub聲明的參數

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

包含以下摘錄的項目是一個使用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);

在我的主要()我的可讀性申報服務

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM