Results 1 to 2 of 2

Thread: Rest Web Service - Keep-alive Connection

  1. #1
    Join Date
    Mar 2015
    Posts
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Rest Web Service - Keep-alive Connection

    How to Keep-Alive Connection calling rest Web Service
    It is necessary to keep alive any TCP/HTTP while calling 2 or more Server request if so
    how to use connection:Keep-Alive , Im using that codes below:
    Qt Code:
    1. #include <QDebug>
    2. #include <QThread>
    3. #include <QtCore/QUrl>
    4. #include <QtNetwork/QNetworkAccessManager>
    5. #include <QtNetwork/QNetworkRequest>
    6. #include <QtNetwork/QNetworkReply>
    7. #include <QtNetwork/QNetworkProxy>
    8. #include <QtXml/QDomDocument>
    9.  
    10. MainWindow::MainWindow(QWidget *parent,) :
    11. QDialog(parent),
    12. ui(new Ui::afterbarcode)
    13. {
    14. ui->setupUi(this);
    15. }
    16. MainWindow::~MainWindow()
    17. {
    18. delete ui;
    19. }
    20.  
    21. void MainWindow::on_pushButton_clicked()
    22. {
    23.  
    24. QString url="http://127.0.0.1:8085/";
    25. QString Webmethod="ValidationRequest?SessionKey=12345678";
    26. QString REQUEST_URL =url+Webmethod;
    27.  
    28. m_network = new QNetworkAccessManager (this);
    29. QNetworkRequest request;
    30.  
    31. request.setUrl(QUrl(REQUEST_URL));
    32.  
    33. QNetworkReply *reply = m_network->get(request);
    34. QObject::connect(m_network, SIGNAL(finished(QNetworkReply *)),
    35. SLOT(RequestFinished(QNetworkReply *)));
    36.  
    37. }
    38.  
    39. void MainWindow::RequestFinished(QNetworkReply *reply){
    40.  
    41. QByteArray data = reply->readAll();
    42. doc.setContent(data);
    43. qDebug()<<"<XML>"<<doc.toString()<<"</XML>";
    44. QDomNodeList ValidationResponse = doc.elementsByTagName("ValidationResponse");
    45. QDomNodeList Result = doc.elementsByTagName("Result");
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 23rd May 2015 at 14:12. Reason: missing [code] tags

  2. #2
    Join Date
    Mar 2015
    Posts
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Rest Web Service - Keep-alive Connection[solved]

    i found that:
    no needs to Connection:keep-Alive

Similar Threads

  1. Replies: 1
    Last Post: 11th September 2012, 07:33
  2. Replies: 1
    Last Post: 15th June 2012, 12:45
  3. Replies: 12
    Last Post: 22nd April 2012, 21:48
  4. QTcpSocket and keep-alive option.
    By fanat9 in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2008, 16:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.