1. Create a Source code schema
- Go to the Configuration section and select a custom package to add the schema.
-
Click Add → Source code on the section list toolbar.
-
Go to the Schema Designer and fill out the schema properties:
- Set Code to "UsrAnonymousConfigurationService."
- Set Title to "AnonymousConfigurationService."
Click Apply to apply the properties.
2. Create a service class
- Go to the Schema Designer and add the namespace nested into Terrasoft.Configuration. You can use an arbitrary name. For example, UsrAnonymousConfigurationServiceNamespace.
- Add the namespaces the data types of which to utilize in the class using the using directive.
- Add the class name that matches the schema name (the Code property).
- Specify the Terrasoft.Nui.ServiceModel.WebService.BaseService class as a parent class.
- Add the [ServiceContract] and [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] attributes to the class.
- Add the SystemUserConnection system connection to enable anonymous access to the custom web service.
3. Implement the class method
Go to the Schema Designer and add the public string GetContactIdByName(string Name) class method that implements the endpoint of the custom web service. The method executes database queries using EntitySchemaQuery. Depending on the value of the Name parameter in the query string, the response body will contain:
- The ID of the contact (string type) if the contact is found.
- The ID of the first found contact (string type) if Creatio several contacts are found.
- The empty string if Creatio no contacts are found.
Specify the user on whose behalf to process the HTTP request. To do this, call the SessionHelper.SpecifyWebOperationIdentity method of the Terrasoft.Web.Common namespace after retrieving SystemUserConnection. This method enables business processes to manage the database entity (Entity) from the custom web service that uses anonymous authentication.
View the source code of the UsrAnonymousConfigurationService custom web service below.
Click Save then Publish on the Designer's toolbar.
4 Register the custom web service that uses anonymous authentication
- Go to the ..\Terrasoft.WebApp\ServiceModel directory.
-
Create a UsrAnonymousConfigurationService.svc file and add the following record to it.
The Service attribute contains the full name of the web service class and specifies the namespace.
5. Enable both HTTP and HTTPS support for the custom web service that uses anonymous authentication
-
Open the ..\Terrasoft.WebApp\ServiceModel\http\services.config file and add the following record to it.
- Add an identical record to the ..\Terrasoft.WebApp\ServiceModel\https\services.config file.
6. Enable all users to access the custom web service that uses anonymous authentication
- Open the ..\Terrasoft.WebApp\Web.config file.
-
Add the <location> element that defines the relative path and access permissions to the web service.
-
Add the relative web service path to the value attribute of the AllowedLocations key in the <appSettings> element.
7. Restart Creatio in IIS
Restart Creatio in IIS to apply the changes.
Outcome of the example
As a result, Creatio will add the custom UsrAnonymousConfigurationService REST web service that has the GetContactIdByName endpoint. You can access the web service from the browser, with or without pre-authentication.
Access the GetContactIdByName endpoint of the web service from the browser and pass the contact name in the Name parameter.
If Creatio finds the contact from the Name parameter in the database, the GetContactIdByNameResult property will return the contact ID value.
![](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CreateAnonymousWebService/7.18/scr_result_01.png)
If Creatio finds no contacts from the Name parameter in the database, the GetContactIdByNameResult property will return an empty string.
![](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CreateAnonymousWebService/7.18/scr_result_02.png)