我正在尝试构建一个简单的gsoap客户端但是卡住了。 这是代码,我写道。
CurrencyRatesSoapProxy currproxy;
std::string login = "kav120@aubg.bg";
std::string password = "mypass";
std::string from = "USD";
std::string to = "EUR";
_ns1__GetLatestRate* getrate = new _ns1__GetLatestRate;
getrate->SingleCurrencyFrom = &from;
getrate->SingleCurrencyTo = &to;
getrate->Password = &password;
getrate->UserID = &login;
_ns1__GetLatestRateResponse* resp = new _ns1__GetLatestRateResponse;
if (currproxy.GetLatestRate(getrate, resp) == SOAP_OK)
std::cout << "Works";
else {
currproxy.soap_stream_fault(std::cout);
std::cout << currproxy.error;
}
Currencyratesoapproxy:
class SOAP_CMAC CurrencyRatesSoapProxy : public soap
{ public:
/// Endpoint URL of service 'CurrencyRatesSoapProxy' (change as needed)
const char *soap_endpoint;
/// Constructor
CurrencyRatesSoapProxy();
/// Construct from another engine state
CurrencyRatesSoapProxy(const struct soap&);
/// Constructor with endpoint URL
CurrencyRatesSoapProxy(const char *url);
/// Constructor with engine input+output mode control
CurrencyRatesSoapProxy(soap_mode iomode);
/// Constructor with URL and input+output mode control
CurrencyRatesSoapProxy(const char *url, soap_mode iomode);
/// Constructor with engine input and output mode control
CurrencyRatesSoapProxy(soap_mode imode, soap_mode omode);
/// Destructor frees deserialized data
virtual ~CurrencyRatesSoapProxy();
/// Initializer used by constructors
virtual void CurrencyRatesSoapProxy_init(soap_mode imode, soap_mode omode);
/// Delete all deserialized data (with soap_destroy and soap_end)
virtual void destroy();
/// Delete all deserialized data and reset to default
virtual void reset();
/// Disables and removes SOAP Header from message
virtual void soap_noheader();
/// Get SOAP Header structure (NULL when absent)
virtual const SOAP_ENV__Header *soap_header();
/// Get SOAP Fault structure (NULL when absent)
virtual const SOAP_ENV__Fault *soap_fault();
/// Get SOAP Fault string (NULL when absent)
virtual const char *soap_fault_string();
/// Get SOAP Fault detail as string (NULL when absent)
virtual const char *soap_fault_detail();
/// Close connection (normally automatic, except for send_X ops)
virtual int soap_close_socket();
/// Force close connection (can kill a thread blocked on IO)
virtual int soap_force_close_socket();
/// Print fault
virtual void soap_print_fault(FILE*);
#ifndef WITH_LEAN
/// Print fault to stream
#ifndef WITH_COMPAT
virtual void soap_stream_fault(std::ostream&);
#endif
/// Put fault into buffer
virtual char *soap_sprint_fault(char *buf, size_t len);
#endif
/// Web service operation 'GetLatestRate' (returns error code or SOAP_OK)
virtual int GetLatestRate(_ns1__GetLatestRate *ns1__GetLatestRate, _ns1__GetLatestRateResponse *ns1__GetLatestRateResponse) { return this->GetLatestRate(NULL, NULL, ns1__GetLatestRate, ns1__GetLatestRateResponse); }
virtual int GetLatestRate(const char *endpoint, const char *soap_action, _ns1__GetLatestRate *ns1__GetLatestRate, _ns1__GetLatestRateResponse *ns1__GetLatestRateResponse);
}
和 ns1 _GetLatestRateResponse:
class SOAP_CMAC _ns1__GetLatestRate
{
public:
std::string *UnregisteredUserEmail; /* optional element of type xsd:string */
std::string *UserID; /* optional element of type xsd:string */
std::string *Password; /* optional element of type xsd:string */
std::string *SingleCurrencyFrom; /* optional element of type xsd:string */
std::string *SingleCurrencyTo; /* optional element of type xsd:string */
struct soap *soap; /* transient */
public:
virtual int soap_type() const { return 35; } /* = unique id SOAP_TYPE__ns1__GetLatestRate */
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*);
_ns1__GetLatestRate() { _ns1__GetLatestRate::soap_default(NULL); }
virtual ~_ns1__GetLatestRate() { }
};
我不知道,我做错了什么但是我收到错误12并且“没有提供用户标识符”流错误。 像这样的人:
SOAP 1.1 fault: SOAP-ENV:Client[no subcode]
"No user identifier provided"
Detail: [no detail]
我不认为“”没有提供用户标识符“是关于服务的许可证信息,因为我显然提供了用户名和密码。我做错了什么? 提前致谢