PDA

View Full Version : Using QHttp in a QDS service



bowser
22nd October 2007, 19:13
Hi all,

In a standalone application, I can successfully use QHttp to communicate with a backend server.
Now I'm trying to publish this communication as a QDS service. Basically, the same code (signal connecting, same slots etc) was transfered to the server.

The service uses a utility class that executes this QHttp object successfully and retrieves the information I want, though it generates two requestFinished signals.
The first is right after http->request() and returns a "" string
The second takes a bit longer (as expected) and returns the desired information.

I have tried placing the following after http->request():


while (!reponseRetrieved) {
loop.processEvents(QEventLoop::AllEvents); // with other parameter variations
}

But the signal is still executing twice. I'm trying to synchronize the http so the service returns the information correctly.

Any reason for this behavior?

wysota
22nd October 2007, 19:44
First requestFinished signal is probably the result of QHttp::setHost and in that case is perfectly normal. You need to use the request id to look for requests you're monitoring.

bowser
22nd October 2007, 20:26
Hum, that would explain only one done signal, though the actual response should really have requestID = 2 (for the first service call)?

If that's the normal behavior than ok by me. I'm just curious why wouldn't the setHost count as a request itself when running the same code in a standalone application?

wysota
22nd October 2007, 21:15
Maybe the signal was firing before you made the signal/slot connection? Hard to guess without seeing the actual code. I'm sure the behaviour is coherent on all platforms.

bowser
22nd October 2007, 21:31
Hum, probably. But since the actual purpose is to be in a service, and checking with stateChanged confirmed that only one request is actually sent to the backend server, I'm cool with that.
Will improve request ID management. Thanks for the info.