PDA

View Full Version : Execute method on server application.



porterneon
21st July 2011, 15:35
Hello.
I have been looking on Qt example: fortuneserver (http://doc.trolltech.com/4.7/network-threadedfortuneserver.html). FortuneServer is responding on incomingConnection event and returning randome QString. How to define my own public methos on server application? For example I would like to allow client application to call server method:
public QString GetCustomerLastName(const int& customerID);
public void SetCustomerLastName(const int& customerID, const QString& lastName);
Howto define those kind public methods on server and how to call them from client application?

high_flyer
21st July 2011, 15:40
This is off topic for this forum.

porterneon
21st July 2011, 15:44
Com on I'm fresh with Qt and this tipic is about Qt client-server application.

high_flyer
21st July 2011, 16:18
No, its about basic C++.

ChrisW67
22nd July 2011, 00:38
You need to:

Receive the incoming request, which may not be from a Qt client.
Interpret the request, validate provided parameters, check permissions etc.
Call the relevant method(s) in the server code to service the request.
Send the result back to the client.


You are asking about steps 2 and 3. You can do these any way you like (http://en.wikipedia.org/wiki/List_of_web_service_protocols). Step 2 might be disassembling a SOAP, XML-RPC or some other request packet. Step 3 involves some sort of mapping mechanism. There is no magic expose-this-method-on-the-net language extension in C++.

high_flyer
22nd July 2011, 09:59
There is no magic expose-this-method-on-the-net
So that's what he was after.... ah...

porterneon
26th July 2011, 14:46
I have read about gSOAP. I would like to use gSOAP in my Qt project. Base on FortuneServer example I have created server application that for any connected client is creating separated thread and keeping connection (and thread) alive until client get disconnected.
In gSOAP documentation I found how to Generate C++ Server Object Classes files.
Question: Is it enough if I will create gSOAP (*.h and *.cpp) files from header file that is containing all public server methods and attach generated files into my server and client application?