简体   繁体   中英

gSoap: How to set or change cookies on client in Qt?

I'am use next code for authorization on server by service, and get other service'methods using cookie identifer for authorizathion.

TerminalControllerBinding soapObj;
soap_init1(soapObj.soap, SOAP_C_UTFSTRING);
soapObj.endpoint = "http://192.168.*.*/path/to/service";

ns1__getTemplatesResponse *response = new ns1__getTemplatesResponse;

std::string auth_res = "";
soapObj.ns1__auth("user", "password", auth_res);

QString sessid = QString::fromStdString(auth_res);

qDebug() << sessid;

soapObj.soap->cookies = soap_cookie(soapObj.soap, "sessid", sessid.toAscii().data(), ".");

Server not getting cookie "sessid"

I am kind of confused by the code you posted: You allocate memory for ns1__getTemplatesResponse , then do some apparently unrelated stuff; in fact you do not reference it again at all. Furthermore soap_cookie is a struct and soap->cookies is basically a list. So there is no magic that transfers the cookies to the server here.

I think what you want is soap_set_cookie . You can find a little more information on client side cookies here , but there isn't any example code. Much more helpful however is actually the server side documentation (the handling of cookies doesn't differ much).

Also notice that you either need to compile with -DWITH_COOKIES or define the macro yourself in stdsoap.h if you haven't done so already.

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