PDA

View Full Version : Webservice with QT



BP
24th September 2010, 11:02
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.

wysota
24th September 2010, 11:32
It depends on the technology used for the webservice.

squidge
24th September 2010, 13:01
Assuming your web service uses the commonly available SOAP, you can use QtSoap (http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtsoap/):)

wysota
24th September 2010, 13:06
you can use QtSoap (http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtsoap/):)
I wouldn't be so sure about that. QtSoap is really broken :)

enlightened_j
24th September 2010, 14:43
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.

BP
25th September 2010, 09:35
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

TorAn
25th September 2010, 10:39
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.


class webserviceThread : public QThread.
{
...
private:
boost::scoped_ptr<QNetworkAccessManager> _http;
}
the main thing this class does is that it instantiates event processing.


void webserviceThread::run()
{
exec();
}
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.


webserviceThread::webserviceThread(const QString& host, int port) : QThread(),_timerid(-1), _http(new QNetworkAccessManager())
{
...
QObject::connect (_http.get(), SIGNAL (finished (QNetworkReply *)), this, SLOT(responseReceived(QNetworkReply*)));
...
_timerid = startTimer(_timerinterval);
}
Now you can declare the instance of webserviceThread anywhere and use it for communicating with your web server. In my case I have this:


class datamanager : public QDialog
{
public:
datamanager() {
...
_dmcenter.start();
}

private:
webserviceThread _dmcenter;
}
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.

jindoniit
14th June 2011, 10:42
I tried to run example this (http://wiki.forum.nokia.com/index.php/GSoap:_SOAP_and_XML_Web_services_for_Qt_apps). but it did not run.please help me

squidge
14th June 2011, 13:06
You need to help yourself first. What did not run? What happened? What did you expect? What is the problem?

jindoniit
16th June 2011, 05:08
sorry squidge, actually i did not read it carefully before ask question. now , i am using qtsoap to connect service. i did it well.