Call a custom web service
You can call a custom web service in several 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.svc
system 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?SomeOptionalParameters
http://mycreatio.com/0/rest/UsrCustomConfigurationService/GetContactIdByName?Name=User1
The procedure to call a .NET Core or .NET 6 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 Core or .NET 6 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
ServiceHelper
module 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.AjaxProvider
request provider implemented in the client core. -
Call a custom web service from the
ServiceHelper
module.You can call a custom web service in several ways:
-
Call the
callService(serviceName, serviceMethodName, callback, serviceData, scope)
method. -
Call the
callService(config)
method, whereconfig
is a configuration object.The
config
configuration object has the following properties:serviceName
is the name of the custom web service.methodName
is the name of the custom web service method to call.callback
is the callback function that handles the web service response.data
is the object that contains the initialized incoming parameters for the web service method.scope
is 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.