Call a custom web service
You can call a custom web service in multiple ways:
- from the browser.
- from the front-end.
Call a custom web service from the browser
Call a custom web service that uses cookie-based authentication from the browser
To call a .NET Framework custom web service that uses cookie-based authentication from the browser:
-
Retrieve the authentication cookies using the
AuthService.svcsystem web service. -
Call a custom web service using the following request string:
- Template URL of a custom web service that uses cookie-based authentication
- Example URL of a custom web service that uses cookie-based authentication
SomeCreatioApppURL/0/rest/SomeCustomWebServiceName/SomeCustomWebServiceEndpoint?SomeOptionalParametershttp://mycreatio.com/0/rest/UsrCustomConfigurationService/GetContactIdByName?Name=User1
The procedure to call a .NET custom web service that uses cookie-based authentication is identical. That said, the /0 prefix is not required.
Call a custom web service that uses anonymous authentication from the browser
To call a .NET Framework custom web service that uses anonymous authentication from the browser, use the request string below.
- Template URL of a custom web service that uses anonymous authentication
- Example URL of a custom web service that uses anonymous authentication
SomeCreatioAppURL/0/ServiceModel/SomeCustomWebServiceName.svc/SomeCustomWebServiceEndpoint?SomeOptionalParameters
http://mycreatio.com/0/ServiceModel/UsrCustomConfigurationService.svc/GetContactIdByName?Name=User1
The procedure to call a .NET custom web service that uses anonymous authentication is identical. That said, the /0 prefix is not required.
Call a custom web service from the front-end
-
Add the
ServiceHelpermodule as a dependency to the module of the page from which to call the service. This module provides a convenient interface for executing server requests via theTerrasoft.AjaxProviderrequest provider implemented in the client core. -
Call a custom web service from the
ServiceHelpermodule.You can call a custom web service in multiple ways:
-
Call the
callService(serviceName, serviceMethodName, callback, serviceData, scope)method. -
Call the
callService(config)method, whereconfigis a configuration object.The
configconfiguration object has the following properties:serviceNameis the name of the custom web service.methodNameis the name of the custom web service method to call.callbackis the callback function that handles the web service response.datais the object that contains the initialized incoming parameters for the web service method.scopeis the scope of the request execution.
-
The ServiceHelper module supports only POST requests. As such, add the [WebInvoke] attribute that contains the Method = "POST" parameter to the custom web service methods.