Altova MobileTogether Designer

Start Service via URL

Home Prev Top Next

You can start a service via its URL and pass parameter values to the service via the URL's query parameters.

 

We will explain this kind of use with an example. Let us say we want to pass the IP address of a mobile device to a MobileTogether Server service. (We might want to do this, for example, so that the service can store the IP address in a file on the MobileTogether Server and, in this way, make the IP address available to solutions that have access to the server.)

 

The steps of the mechanism are as follows:

 

1.A device connected to the Internet sends an HTTP GET request to the MobileTogether Server service. This will start the service.

2.The URL of the request contains, as one of its query parameters, the IP address that we want to store on the MobileTogether Server.

3.When the MobileTogether Server service receives the request it automatically stores all the query parameters of the URL in its $MT_InputParameters variable.

4.The IP address is obtained from the $MT_InputParameters variable and stored in a file on the MobileTogether Server, from where it will be available to a solution running on an MobileTogether Client device.

 

These steps are discussed in more detail below.

 

URL of the HTTP GET request

The pattern of the URL must be as follows:

 

https://<mt-server-hosting-the-solution>:<client-port>/run?d=<path-to-service>&<param1>=<value>

Example: https://localhost:8083/run?d=/services/MyIPAddressService&ipaddress=someAddress

 

Note the following points:

 

Ensure that the service solution is run as anonymous so that it can be called by any mobile device.

Anonymous execution is only possible on the client port of the server (not the administrator port).

Use run?d= to specify the path to the service solution on the server.

Use &key=value to supply the name and value of a parameter, for example: &ipaddress=someAddress.

You can supply multiple parameters. Add a new &key=value for each new parameter (with no space separator between parameters).

 

Save IP address from $MT_InputParameters to a file on the MT server

When the service solution is started on the server by the HTTP GET request, the query parameters in the URL of the GET request are automatically stored in the $MT_InputParameters variable (also see OnServerDeployment Input Parameters).

 

The values stored in the $MT_InputParameters variable can now be accessed by the actions of the Service Action Tree. For example, we can use a Save Text File action as shown in the screenshot below. This action generates a text string that contains the IP address it obtains from the $MT_InputParameters variable, and then saves the generated string to a file on the server.

MTDServicesSaveIPAddress

Note the following points about the screenshot example above:

 

The string that contains the IP address is constructed as the value of Source Node. It is a concatenation of (i) the current dateTime and (ii) the IP address.

The IP address is obtained from the value of the ipaddress key of the map stored in the $MT_InputParameters variable.

The string generated for Source Node is saved to the IPAddress.txt file, which is located in the ServerSide Solution's Working Directory.

 

The data in the text file can now easily be loaded into a page source node by using the Load Text File action.

 

Note:You could also generate a string in XML format and save the string to an XML file. In this case, you would use the Load File action to load data from the XML file.

 

© 2018-2024 Altova GmbH