ThingWorx WebSocket-based Edge MicroServer (WS EMS) and Lua Script Resource (LSR) > Remote Things > Configuring Services for Remote Things
Configuring Services for Remote Things
There are two types of services for remote things, as follows:
Local (JavaScript) - JavaScript business logic executing on the server.
Remote - a direct call to a remote service on a remote thing (such as a custom-defined Lua script).
Remote Services and Binding
When you define a remote service, you are defining the metadata for the service so that it can be properly consumed from the server. The definition includes the service name at the server, the description, remote service name, and the inputs and outputs of the service. This will bind the service to the remote service, and the remote service is executed when the service runs. From a Mashup or REST Web Service perspective, it will appear the same as a local service.
When the WSEMS opens a connection to a ThingWorx platform, it goes through a three step process:
1. Initiation: This establishes the physical WebSocket connection and prepares it to handle inbound and outbound messages.
2. Authentication: The WS EMS can authenticate using an application key. All communication that is passed over the connection from the WS EMS to the ThingWorx platform will run under the security context of this application key. After authentication is complete applications can use the REST interface of WS EMS to interact with the ThingWorx platform.
3. Binding: After authentication, remote things on the ThingWorx platform can bind to the connection of the WS EMS. Binding is the process that notifies the platform that a particular remote thing is associated with an established connection. After a thing is bound to a connection, the platform will indicate a change in the value of its isConnected property to true and update its lastConnection property. The platform can then send outbound requests to thing.
You can also directly browse and bind to remote services if the remote thing is running and is connected. Click Browse Remote Services to view the services that are currently defined for the remote thing. You can then add them to the local service definitions through the drag and drop interface (similar to how you bind remote data properties).
The process of registering a thing with the WS EMS also causes the thing to bind. The de-registering of a thing causes it to unbind.