Results 1 to 2 of 2

Thread: WebService

  1. #1
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default WebService

    Hii EveryOne

    We have two prog :
    1- Client that represents the interface (Created by : QtQuick/QML) for entering data
    2- Serveur Web (Java/JEE) that should menage the database

    Communication between Client(Qml, Qt/C++) and Serveur Web should be done by : Webservice : Rest

    I'm beginner in Webservice, I don't know where to start.
    How can I establish the communication?
    Steps to follow?

    Cheers,

  2. #2
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: WebService

    You can try something like this for the Client (Qt)
    (Be Aware that following code is rudimental and is not tested)
    Ist not really a howto but i think it will help you in your first steps

    Qt Code:
    1. QNetworkAccessManager networkManager;
    2. QNetworkRequest request;
    3. QString requestData = "";
    4. QString requestUrl= "www.google.at";
    5.  
    6. arr.append(requestData);
    7.  
    8. request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant( QString("text/xml;charset=UTF-8")));
    9. request.setHeader(QNetworkRequest::ContentLengthHeader, QVariant( qulonglong(arr.size()) ));
    10. request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QVariant( int(QNetworkRequest::AlwaysNetwork) ));
    11. request.setUrl(QUrl(requestUrl));
    12.  
    13. QObject::connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*)));
    14. QObject::connect(networkManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(onAuthenticationRequired(QNetworkReply*, QAuthenticator*)));
    15.  
    16. networkReply = networkManager.post(request, arr);
    17. QObject::connect(this, SIGNAL(sigCancelRequest()), networkReply, SLOT(abort()));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Usage of Webservice in QT
    By StarRocks in forum Qt Programming
    Replies: 0
    Last Post: 10th October 2012, 13:48
  2. Webservice with QT
    By BP in forum Newbie
    Replies: 9
    Last Post: 16th June 2011, 06:08
  3. Using webservice in Qt
    By mind_freak in forum Qt Programming
    Replies: 1
    Last Post: 16th May 2011, 07:50
  4. qtsoap with .net webservice
    By drbergie in forum Qt Programming
    Replies: 11
    Last Post: 12th February 2009, 09:46
  5. Calling a webservice
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 17th December 2007, 19:29

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.