ThingWorx WebSocket-based Edge MicroServer (WS EMS) and Lua Script Resource (LSR) > Configuring a Template for the Lua Script Resource > Defining Services
  
Defining Services
The serviceDefinition group is used to provide metadata for a service that is used when browsing services from the ThingWorx platform.
A service definition is a separate entry in the template file from the actual implementation of the service. The name of the service definition must match the name of the service it is defining in order for the service to work as expected.
serviceDefinitions.Add(
input { name="p1", baseType="NUMBER", description="The first addend of the operation" },
input { name="p2", baseType="NUMBER", description="The second addend of the operation" },
output { baseType="NUMBER", description="The sum of the two parameters" },
description { "Add two numbers" }
)

serviceDefinitions.Subtract(
input { name="p1", baseType="NUMBER", description="The number to subtract from" },
input { name="p2", baseType="NUMBER", description="The number to subtract from p1" },
output { baseType="NUMBER", description="The difference of the two parameters" },
description { "Subtract one number from another" }
Parameters
The following table lists and describes the parameters that you can use to define services:
Use
To
serviceDefinition.nameOfService
Declare a Service Definition.
input
Describe an input parameter to the service that is referenced within the data table that is passed to the service at runtime. Valid values include:
name — The name of the input parameter.
baseType — The type of input parameter used by the service.
description — A description of the input parameter.
output
Describes the output produced by the service. Valid values include:
baseType — The type of output that the service produces.
description — A description of the output that the service produces.
description
Provide information about the purpose and operation of the service.