A service is created in the same way as you create a solution. You can define page source trees so that the service can use data from these trees. However, since a service is intended to run on the server (and so with no user interface), all controls and the addition of new pages (whether top or sub) are disabled. The services you can run on the server are server-side actions, such as sending an email from the server or updating a node in a page source. So a set of such actions can be defined as the actions of a service; other actions are disabled.
To create a new service, do the following:
1.Click File | New Service to open a design file for the service. A new service design is created, and a $MT_SERVICE page source is automatically created. The MobileTogether Designer interface will look the same as that for a solution. One difference you might quickly notice is that no client-interface design is possible since all controls are disabled. Instead, all the actions you want to define for the service must be defined in the tab of the project event OnServiceRunning.
2.If you need to use page sources, add them to the Page Sources Pane. In the screenshot below, an XML page source named $XML1 has been added.
3.Open the Actions dialog of the service (or Service Action Tree, see screenshot below) in one of the following ways: (i) Click the Service Action Tree button located in the middle of the design page; or (ii) In the Styles & Properties Pane, click the Additional Dialog button of the Service Actions property.
4.The left-hand pane of the dialog (not shown in screenshot above) displays all the available actions for services. The unavailable actions are disabled (and shown grayed out). Drag the actions you want to execute as the service into the OnServiceRunning tab. In the screenshot above, two actions have been added: (i) Load from File loads the MobileTogether Server log file to the $XML1 page source, and (ii) Send Email sends emails to three recipients, with the $XML1 tree of the MobileTogether Server logs as an attachment.
5.Click OK to finish creating the actions of the service.
6.Save the file (Ctrl+S) with a suitable name for the service and a filetype of .mtd.
|Note:||You can create only one set of actions for each service. If you select File | New Service a second time, a new empty service file is created.|
|Note:||You can localize services for other languages via the Localization dialog (Project | Localization menu command).|
The $MT_SERVICE page source is automatically created when the service design is created. The screenshot and listing below show the structure of the page source.
<File name="" filename="" reason=""/>
<URL name="" url=""/>
At run time, data about the triggers that have been set for the service will be passed from the server to the page source and will be stored in appropriate nodes of the page source. For example, the name of the file that activates a File System trigger will be stored in the //File/@filename node of the page source. If the XPath expressions of service actions access these nodes, then the run time information stored in these nodes can be used by the XPath expressions. For example, the name of the file that triggered a service action can be sent in a Send Email To action, together with the reason for the trigger being activated (new file created, file modified, or file deleted)—all of which is information that cannot be known beforehand, but only at run time.
Since the relevant nodes of the page source will be automatically filled at run time, there is nothing further that you need to do concerning the building of the $MT_SERVICE page source or the populating of its nodes. Its use to you is as a source of (additional) run time information about server-side triggers. You can access this information via XPath expressions, and use it: (i) to make service actions conditional on the value of the information, and/or (ii) as data to be passed on in a service action.
|Note:||For simulations, you can enter data in a $MT_SERVICE page source that will be used exclusively for simulations. This data simulates the data received at run time. How to create a $MT_SERVICE page source for simulations is described in the topic Service Trigger Simulations.|
In the Styles & Properties Pane (see screenshot above), you can set a data retrieval timeout for the service (in seconds).
This is the amount of time the server waits for data to be retrieved from a source external to the server (from a DB or URL, for example). The value is an integer value in seconds that can be entered or selected from the dropdown list of the combo box. The default value is 10 seconds. If the timeout period is exceeded, then an error message is displayed. An exception to this is when load actions have the setting On error set to Continue. In this case, the On Error actions of that action's Continue setting are executed.