ThingWorx Edge Java SDK > Using ThingWorx Platform and the Edge Java SDK > Invoking a Service
Invoking a Service
While connected to the server, a client application can invoke a service on a thing. Again, keep in mind that the operation shown here from the Simple Thing example is done without binding.
The example here provides two different services, one that creates a file and one that retrieves information about the file:
Before creating the file, you need to declare a ValueCollection to contain the set of parameters for the service. Then, use the put method to populate the collection. Finally, you can invoke the service. Note that, after creating the file, this service returns NOTHING, and in this example, the response is ignored..
In the second part of the example, you clear the ValueCollection and then write the parameter for the second service to the collection, specifically the name of the file whose information is being requested. Note that for services that return a result, an InfoTable is used to store the results. In this example, the service returns all the information about the file.
// Invoking a service on a thing

//A ValueCollection is used to specify a service's parameters
ValueCollection params = new ValueCollection();

params.put("path", new StringPrimitive("/simple.txt"));
params.put("data", new StringPrimitive("Here is the content of the file."));
params.put("overwrite", new BooleanPrimitive(true));

// Use the SystemRepository thing to create a text file on the ThingWorx platform.
// This service's result type is NOTHING, so we can ignore the response.
client.invokeService(ThingworxEntityTypes.Things, "SystemRepository",
"CreateTextFile", params, 5000);

// If a service does have a result, it is returned within an InfoTable.
params.clear(); // Clear the params used in the previous service invocation.
params.put("path", new StringPrimitive("/simple.txt"));

// This service queries the SystemRepository for information about the file
// that was just created.
result = client.invokeService(ThingworxEntityTypes.Things, "SystemRepository",
"GetFileInfo", params, 5000);

// The rows of an InfoTable are ValueCollections.
ValueCollection row = result.getFirstRow();"The file info is: name: {}", row.getStringValue("name"));" path: {}", row.getStringValue("path"));" type: {}", row.getStringValue("fileType"));" date: {}", row.getPrimitive("lastModifiedDate").
getStringValue());" size: {}", row.getValue("size"));