Creatio development guide
PDF
This documentation is valid for Creatio version 7.16.0. We recommend using the newest version of Creatio documentation.

Creating anonymous web service

Glossary Item Box

Introduction

Creatio service model implements the base set of web services, which you can use for integration with third-party applications and systems.

Examples of system services:

These services are implemented using WCF technology and are managed at the IIS level.

Creatio also provides configuration web services designed for calls from the client part of the application. You can implement specific integration tasks using Creatio configuration web services. Learn more about creating user configuration services in the “Creating a user configuration service” article.

Most of WCF-services require preliminary user authentication. Some of the services, such as AuthService.svc, permit anonymous usage.

Since configuration services are designed to be managed at the application level rather than the IIS level, you cannot make them anonymous.

To create a WCF-service that will be accessible without user authentication:

  1. Create a configuration web service (optional).
  2. Register the WCF-service.
  3. Configure the WCF-service for the HTTP and HTTPS protocols.
  4. Setting up access to the WCF-service for all users.

Creating a configuration service

Learn more about creating configuration services in the “Creating a user configuration service” article.

Use SystemUserConnection instead of the system connection of a user when creating an anonymous configuration service,

To maintain the availability of business processes when working with Entity from an anonymous web service, call the SessionHelper.SpecifyWebOperationIdentity method of the Terrasoft.Web.Common namespace after retrieving SystemUserConnection:

Terrasoft.Web.Common.SessionHelper.SpecifyWebOperationIdentity(HttpContextAccessor.GetInstance(), SystemUserConnection.CurrentUser);

This method enables you to specify the user that will be running the HTTP query.

Registering the WCF-service

To register a WCF-service in the ..\Terrasoft.WebApp\ServiceModel directory, create an .svc file and add the following entry:

<% @ServiceHost
Service = "Service, ServiceNamespace"
Factory = "Factory, FactoryNamespace"
Debug = "Debug"
Language = "Language"
CodeBehind = "CodeBehind"
%>

Specify the full name of the configuration service class in the Service attribute. Read more about the @ServiceHost WCF directive in Microsoft documentation.

Configuring the WCF-service for the HTTP and HTTPS protocols.

Append the following record to the services.config files located at ..\Terrasoft.WebApp\ServiceModel\http and ..\Terrasoft.WebApp\ServiceModel\https directories:

<services>
    ...
    <service name="Terrasoft.Configuration.[Service name]">
        <endpoint name="[Service name]EndPoint"
            address=""
            binding="webHttpBinding"
            behaviorConfiguration="RestServiceBehavior"
            bindingNamespace="http://Terrasoft.WebApp.ServiceModel"
            contract="Terrasoft.Configuration.[Service name]" />
    </service>
</services>

Configure the service here. The <services> element must contain a list of configurations of all application services (nested <service> elements). The name attribute must contain the name of the type (class or interface) that implements the service contract. The <endpoint> child element requires an address, binding, and interface, which define the service contract specified in the name attribute of the <service> element.

You can find a detailed description of the service configuration elements in the Microsoft documentation.

Setting up access to the WCF-service for all users.

To set up access to the WCF-service for all users, make the following adjustments to the ..\Terrasoft.WebApp\Web.config file:

  • Add a <location> element defining the relative path and service access permissions
  • In the <appSettings> element, change the value attribute for the “AllowedLocations” key by supplying the relative path of the service.

You can find sample changes in the ..\Terrasoft.WebApp\Web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  ...
  <location path="ServiceModel/[Service name].svc">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
  ... 
  <appSettings>
    ...
    <add key="AllowedLocations" value="[Previous values];ServiceModel/[Service name].svc"  />
    ...
  </appSettings>
  ...
</configuration>

After reloading the application pool in IIS, the service will become available at:

[Application Address]/0/ServiceModel/[Custom Service Name].svc/[Custom Service Endpoint]?[Optional parameters]

You can access the service from a browser, with or without preliminary login.

You need to change the application configuration files to set up anonymous web-service. When updating the application, all the configuration files are changed by the new ones. Thus, you need to set up the web service again after the application update.

See also

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?