Results 1 to 10 of 10

Thread: Webservice with QT

  1. #1
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X

    Default Webservice with QT

    Hi,

    I am a new bee this technology. How to access the web service and parsing before UI rendering. UI control is based on the webservice result.

    Any one help me. Thanks a lot.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Webservice with QT

    It depends on the technology used for the webservice.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Webservice with QT

    Assuming your web service uses the commonly available SOAP, you can use QtSoap

  4. The following user says thank you to squidge for this useful post:

    BP (25th September 2010)

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Webservice with QT

    Quote Originally Posted by squidge View Post
    you can use QtSoap
    I wouldn't be so sure about that. QtSoap is really broken
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    BP (25th September 2010)

  7. #5
    Join Date
    Aug 2010
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Webservice with QT

    You might want to check if the service can be accessed through http. If so, you can simply use QNetworkAccessManager to interact with the service.

  8. The following user says thank you to enlightened_j for this useful post:

    BP (25th September 2010)

  9. #6
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X

    Default Re: Webservice with QT

    Hi,

    Thanks enlightende_j.
    I am using the QNetworkAccessManager for getting the webservice. And using QJson for parse the data.Those webservice are calling by after the UI rendering. But I want to call these webservice before the UI. How to Do this one?.

    For examples, My screen have combobox. The combobox values are based on the webservice result. but , what happened here the webservice is called after the UI rendering so the combobox is empty. please help me... Thanks a lot

  10. #7
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Webservice with QT

    BP :
    I had a discussion about QNAM/SOAP usage with wysota some time ago. I recommend to search the forum for this thread, may be you will find the discussion useful. Solution that I came up with is:

    Create a class that supports event processing.

    Qt Code:
    1. class webserviceThread : public QThread.
    2. {
    3. ...
    4. private:
    5. boost::scoped_ptr<QNetworkAccessManager> _http;
    6. }
    To copy to clipboard, switch view to plain text mode 
    the main thing this class does is that it instantiates event processing.

    Qt Code:
    1. void webserviceThread::run()
    2. {
    3. exec();
    4. }
    To copy to clipboard, switch view to plain text mode 
    The way I am processing requests is that I am adding it to the queue declared in the webserviceThread and I am having timer firing every half-second to check the exitence of a new request.

    Qt Code:
    1. webserviceThread::webserviceThread(const QString& host, int port) : QThread(),_timerid(-1), _http(new QNetworkAccessManager())
    2. {
    3. ...
    4. QObject::connect (_http.get(), SIGNAL (finished (QNetworkReply *)), this, SLOT(responseReceived(QNetworkReply*)));
    5. ...
    6. _timerid = startTimer(_timerinterval);
    7. }
    To copy to clipboard, switch view to plain text mode 
    Now you can declare the instance of webserviceThread anywhere and use it for communicating with your web server. In my case I have this:

    Qt Code:
    1. class datamanager : public QDialog
    2. {
    3. public:
    4. datamanager() {
    5. ...
    6. _dmcenter.start();
    7. }
    8.  
    9. private:
    10. webserviceThread _dmcenter;
    11. }
    To copy to clipboard, switch view to plain text mode 
    Wysota recommended usage of main thread for event processing, but I found this to be easier in terms of encapsulation of all QNAM/webservice logic inside one class.

  11. #8
    Join Date
    Jun 2011
    Posts
    35
    Thanks
    16
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Default Re: Webservice with QT

    I tried to run example this. but it did not run.please help me

  12. #9
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Webservice with QT

    You need to help yourself first. What did not run? What happened? What did you expect? What is the problem?

  13. #10
    Join Date
    Jun 2011
    Posts
    35
    Thanks
    16
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Default Re: Webservice with QT

    sorry squidge, actually i did not read it carefully before ask question. now , i am using qtsoap to connect service. i did it well.

Similar Threads

  1. qtsoap with .net webservice
    By drbergie in forum Qt Programming
    Replies: 11
    Last Post: 12th February 2009, 09:46
  2. Calling a webservice
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 17th December 2007, 19:29

Tags for this Thread

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.