3
libmaia is a easy-to-use XML-RCP library for Qt!
15
Allowed types for Argument and Return Values:
17
C++/Qt-Types XMLRPC-Types
18
----------------------------------------
21
* double <double></double>
22
* QString <string></string>
23
* QDateTime <datetime.iso8601></datetime.iso8601>
24
* ByteArray <base64></base64>
25
* QVariantMap <struct></struct>
26
* QVariantList <array></array>
32
1. qmake: your Project file (.pro) should contain
34
INCLUDEPATH += /path/to/libmaia
35
LIBS += /path/to/libmaia/libmaia.a
38
2. in your header file include
40
#include "maiaXmlRpcClient.h"
44
#include "maiaXmlRpcServer.h"
51
MaiaXmlRpcServer *server = new MaiaXmlRpcServer(8080, this);
55
MaiaXmlRpcClient *client = new MaiaXmlRpcClient(QUrl("http://localhost:8080/RPC2"), this);
60
your method has to be a Qt Slot.
64
QString MyClass::myMethod(int param1, QString param2) {
68
return "not bigger than 5";
72
// "example.methodName" <- used to identify the method over xml-rpc
73
// this <- pointer to the class which contains the method you would export
74
// "myMethod" the name of the method
75
server->addMethod("example.methodName", this, "myMethod");
80
when calling a method you need three things:
82
1. a Slot for the MethodResponse
83
2. a Slot for the FaultResponse
84
3. a QVariantList containig the arguments for the RPC-Method
88
void MyClientClass::myResponseMethod(QVariant &arg) {
89
// do something with the arg
92
void MyClientClass::myFaultResponse(int error, const QString &message) {
93
qDebug() << "An Error occoured, Code: " << error << " Message: " << message;
98
args << "second argument";
100
rpcClient->call("example.methodName", args,
101
this, SLOT(myResponseMethod(QVariant&)),
102
this, SLOT(myFaultResponse(int, const QString &)));