Calling configuration services with ServiceHelper
Glossary Item Box
Introduction
To call a configuration web service from the client JavaScript-code:
- Add the ServiceHelper module as a dependency to the module of the page that was used for calling the service. This module is an interface for executing server queries via the Terrasoft.AjaxProvider query provider implemented in the client core.
- Call the callService(serviceName, serviceMethodName, callback, serviceData, scope) method from the ServiceHelper module by passing the parameters as listed in table 1.
Table 1. The callService() method parameters
Parameter | Details |
---|---|
serviceName | Configuration service name. Corresponds to the name of the C# class that implements the service. |
servcieMethodName | Name of the configuration service method being called. The method can accept incoming parameters and return resulting values. |
callback(response) |
The callback function that processes the service response. The function accepts the response object as a parameter. If the called service method returns any value, you can receive it on a client via the response object property. The name of the property that returns the method output-value is generated according to the following rule: [Service method name] + [Result] For example, if you call the GetSomeValue() method, the returned value will be contained in the response.GetSomeValueResult property. |
serviceData | The object with the initialized incoming parameters for the service method. |
scope | Execution context. |
There is an alternative way of calling the callService(config)method, where config is a configuration object with the following properties:
- serviceName – configuration service name
- methodName – name of the configuration service method being called
- callback – the callback function processing the service response
- data – the object with the initialized incoming parameters for the service method
- scope – execution context
The ServiceHelper module only works with the POST requests. Therefore, the configuration service methods must be marked by the [WebInvoke] method with the Method = "POST” parameter.
See also: