ns1___x00d0_x0094_x00d0_x00be_x00d0_x00ba_x00d1_x0083_x00d0_x00bc_x00d0_x00b5_x00d0_x00bd_x00d1_x0082
myWsServiceClassGeneratedByGSOAP server(SOAP_IO_DEFAULT|SOAP_C_UTFSTRING);
QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForCStrings (codec); QTextCodec::setCodecForTr(codec); QTextCodec *codec2 = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(codec2);
QString returnRussianString; updateEvent.eventData= returnRussianString.toStdString();//uses CodecForCStrings
//this string have to be included for ability to import STL types#import "stllist.h"//это технические указания кодогенератору! не удалять!!// File: ws_interface_defenition.h//gsoap ns service name: myWsServiceClassGeneratedByGSOAP //gsoap ns service namespace: urn:myWsServiceClassGeneratedByGSOAP //gsoap ns service location: http://127.0.0.1:8080///-------------------------------------------------------------------------------// UTF-8 encoded//-------------------------------------------------------------------------------// структуры //-------------------------------------------------------------------------------class ns__session //Сессия {public: std::string guid; std::string userName; std::string userGroups; std::string startime; };class ns__result //результат {public: int code; std::string descriptin; std::list<ns__session> sessions; //пример того, как определить список в структуре };//-------------------------------------------------------------------------------// функции//-------------------------------------------------------------------------------int ns__login( std::string user, std::string pass, ns__session& session ); //int ns__sessions( ns__session session, ns__result& result ); // пример того, как определить сервис принимающий на входе структуру
soapcpp2 -s -t -x -i -S -IC:\ws\gsoap-2.8\gsoap\;C:\ws\gsoap-2.8\gsoap\import\; .\ws_interface_defenition.h
//#define DEBUG */ /* Uncomment to debug sending (in file SENT.log) receiving (in file RECV.log) and messages (in file TEST.log) */
...QString cRawReceive;QString cRawSend;int my_fPrepareInitSend(struct soap* _soap) { cRawSend=""; return _soap->error; //return SOAP_OK; };int my_fPrepareInitRecv(struct soap* _soap) { cRawReceive=""; return _soap->error; //return SOAP_OK; };int my_fPrepareSend(struct soap* _soap, const char* _buf, size_t _size) { cRawSend += QString::fromUtf8(QByteArray(_buf,_size)); return _soap->error; //return SOAP_OK; };int my_fPrepareRecv(struct soap* _soap, const char* _buf, size_t _size) { cRawReceive += QString::fromUtf8(QByteArray(_buf,_size)); return _soap->error; };int my_fPrepareFinalRecv(struct soap* _soap) //успешно отослали запрос { //qDebug() << QString(" ->() :%1: Raw Receive Data: \n%2\n").arg(QDateTime::currentDateTime().toString("yyyy.MM.dd_hh:mm:ss_zzz")).arg(cRawReceive); return _soap->error; };int my_fPrepareFinalSend(struct soap* _soap) //успешно приняли ответ { //qDebug() << QString(" <-() :%1: Raw Send Data: \n%2\n").arg(QDateTime::currentDateTime().toString("yyyy.MM.dd_hh:mm:ss_zzz")).arg(cRawSend); return _soap->error; };...main(){... myServiceSoapBindingProxy soapObj(SOAP_IO_DEFAULT|SOAP_C_UTFSTRING); //обработчики для перехвата сырых данных ввода-вывода последнего зароса. На всякий случай. soapObj.fpreparerecv = my_fPrepareRecv; //для данных получения обычно этого достаточно soapObj.fpreparesend = my_fPrepareSend; //а вот это вызывается часто и по немногу... soapObj.fprepareinitsend = my_fPrepareInitSend; soapObj.fprepareinitrecv = my_fPrepareInitRecv; soapObj.fpreparefinalsend = my_fPrepareFinalSend;; soapObj.fpreparefinalrecv = my_fPrepareFinalSend;;... int rez=soapObj.callMyWSFunction(..., ...); if (rez==SOAP_OK) {... } else { qDebug() << " ERROR DUE SOAP ASKING. Err code = [" << rez << "]. Debug Data is: "; qDebug() << " \n Last Raw Send Data: " << cRawSend ; qDebug() << " \n Last Raw Receive Data: " << cRawReceive ; };...}