messagesResult element

Type: messagesResult
Namespace: http://eurotech.com/edc/2.0
XML Schema: edc.xsd

MessagesResult is a container for a list of Messages returned by a list or search messages call. It contains the list of requested Messages and a flag signaling whether the limit for the maximum number of returned entities has been reached.
If limitedExceeded is set,the client is requested to paginate through the result by moving the offset forward and issue a new request to get more data.

Example to get all messages:

// First get the total count of messages
String apiPath = "messages/count.xml";
WebResource apisWeb = client.resource(API_URL).path(apiPath);
CountResult countResult = apisWeb.get(CountResult.class);

// Then paginate to get all messages
long MSG_COUNT = countResult.getCount();
apiPath = "messages.xml";
apisWeb = client.resource(API_URL).path(apiPath);

for (int offset = 0; offset < MSG_COUNT; offset += limit) {
// set limit and offset as queryParam
// if the "limit" queryParam is not initialized, limit default value = 50
// if the "offset" queryParam is not initialized, offset default value = 0
apisWeb = apisWeb.queryParam("limit", "" + limit);
if (offset > 0)
apisWeb = apisWeb.queryParam("offset", "" + offset);

MessagesResult result = apisWeb.get(MessagesResult.class);
}

// To get all messages of a given topic
apiPath = "messages/searchByTopic.xml";
apisWeb = client.resource(API_URL).path(apiPath);
apisWeb = apisWeb.queryParam("topic", topic);

MessagesResult result;
int offset = 0;
do {
apisWeb = apisWeb.queryParam("limit", "" + limit);
if (offset > 0)
apisWeb = apisWeb.queryParam("offset", "" + offset);
result = apisWeb.get(MessagesResult.class);
offset += limit;
} while (result.isLimitExceeded()):

Example XML

<?xml version="1.0" encoding="UTF-8"?> <messagesResult xmlns="http://eurotech.com/edc/2.0"> <limitExceeded>...</limitExceeded> <message> <topic>...</topic> <receivedOn>...</receivedOn> <payload> <sentOn>...</sentOn> <position> <longitude>...</longitude> <latitude>...</latitude> <altitude>...</altitude> <precision>...</precision> <heading>...</heading> <speed>...</speed> <timestamp>...</timestamp> <satellites>...</satellites> <status>...</status> </position> <metrics> <metric> <name>...</name> <type>...</type> <value>...</value> </metric> <metric> <!--...--> </metric> <!--...more "metric" elements...--> </metrics> <body>...</body> </payload> <uuid>...</uuid> </message> <message> <!--...--> </message> <!--...more "message" elements...--> </messagesResult>

Example JSON

{ "limitExceeded" : false, "message" : [ { "topic" : "...", "receivedOn" : "...", "payload" : { "sentOn" : "...", "position" : { "longitude" : ..., "latitude" : ..., "altitude" : ..., "precision" : ..., "heading" : ..., "speed" : ..., "timestamp" : "...", "satellites" : ..., "status" : ... }, "metrics" : { "metric" : [ { "name" : "...", "type" : "...", "value" : "..." }, ... ] }, "body" : "..." }, "uuid" : "..." }, ... ] }