Description

Retrieving the shared Infobase list

General information

NOTE. Available only for CORP licenses.

When working remotely (for example, via a web server) you need to retrieve the shared Infobase list. However, you cannot use the CommonInfoBases parameter of configuration file 1cestart.cfg to retrieve the list. You can get the shared Infobase list if it was published using the Internet service. To get the list, you can use either HTTP requests or web services.

If the shared Infobase list is retrieved using HTTP connection, the certificate of the server used to retrieve the list is checked using the certificates of the root certificate authority obtained from the corresponding OS system storage.

Using web services

To get the shared Infobase list through a web service, you need to publish a specific web service that will return the list. This web service is described below in more detail.

Overview

The interactive launcher (1cv8s) can get the shared Infobase list either from a local network or from the Internet. To retrieve the shared bases list from the Internet, you need to start the interactive launcher and specify the address of the list (the InternetService or WebCommonInfoBases parameter in file 1cestart.cfg).

The shared Infobase list retrieval procedure must meet the following requirements:

  • The WebCommonInfoBases.CheckInfoBases() method is called anonymously
  • The WebCommonInfoBases.GetInfoBases() method is called with authentication
  • The Infobase that returns the shared Infobase lists must contain a list of users allowed to request these lists.

First, the WebCommonInfoBases.CheckInfoBases() method is called (anonymously). If the launcher is started manually for the first time for this computer and this user, the ClientID and InfoBasesCheckCode parameters take the value 00000000-0000-0000-0000-000000000000. If the launcher is not started for the first time, the client code and the code of the current shared infobases list are passed as parameters. The web service method determines whether the shared Infobase list for the client needs to be updated. If the update is needed, ‑the  InfoBasesChanged output parameter must be set to True and the URL parameter must contain the address of the web service that implements the WebCommonInfoBases.GetInfoBases() method (requires authentication). Otherwise, InfoBasesChanged must be set to False and URL must contain an empty string.

The algorithm of checking for the changes in the shared Infobase list is not regulated and can be arbitrary. Please note that the launcher does not calculate the code value identifying the shared Infobase list but simply stores the value that was passed during the previous call of the web service.

If results of the call of WebCommonInfoBases.CheckInfoBases() method indicate that the list needs to be updated, the launcher calls the WebCommonInfoBases.GetInfoBases() method of the web service. The web service is located at the address returned by the WebCommonInfoBases.CheckInfoBases() function in its URL parameter. The GetInfoBases() method must match the user on whose behalf the web service is authenticated with a client code. The mapping can be “personal” ‑when the user identifies himself or herself with personal username and password and receives the personal shared Infobase list. In addition, the mapping can be a “role-based” ‑when the user identifies his or her belonging to a certain role, such as Operator, Storekeeper, etc., and obtains the shared Infobase list common to all users with the same role. You should note that in the first case, the Infobase implementing the GetInfoBases() method needs to contain the list of all users who can run the 1cv8s launcher connected to this web service. In the second case, the list of users can contain the role names only.

The GetInfoBases() method must return three values:

  • Client code (if not specified)
  • The list of shared infobases in v8i format
  • The code value identifying the passed Infobase list This value will be passed to the WebCommonInfoBases.CheckInfoBases() method at the next check for whether the shared Infobase list needs to be updated.

If the shared infobase list is retrieved for the first time, the client code (the ClientID parameter) is 00000000-0000-0000-0000-000000000000.

Please also consider the following:

  • The Infobase implementing the WebCommonInfoBases web service needs to be published in two different publications.‑ This is because calling the CheckInfoBases() and GetInfoBases() methods requires different levels of authentication.
  • The anonymous access is organized by explicitly specifying the user on whose behalf the access is performed in the default.vrd file.
  • The user on whose behalf the anonymous access is organized should not be able to call the method for retrieving the Infobase list. The user should only indicate whether the list has changed for the passed ClientID value.
  • All publications serving the WebCommonInfoBases web service must prohibit the web client.
  • If the shared Infobase list is used by the mobile client, this file must contain the correct values of the MobilePublicKey parameter for the infobases to be displayed in the mobile client.

Web service description

Web service name: WebCommonInfoBases. The timeout for the execution of any web service method is 3 seconds.

The web service methods are listed below.

CheckInfoBases

Description:

This method is used by the 1cv8s launcher to determine whether the shared Infobase list needs to be retrieved.

Parameters:

ClientID                                     input

Type: String. Contains the client ID used to check whether the shared Infobase list needs to be updated.

InfoBasesCheckCode                           input

Type: String. Identifies the shared Infobase list. The code must uniquely identify the current shared Infobase list. If the list is modified in any way, the code needs to be assigned a new value that was not previously used for this client ID.

InfoBasesChanged                            output

Type: Boolean. Indicates that the shared Infobase list must be retrieved again.

URL                                         output

Type: String. The URL to be requested if the shared Infobase list has changed since the last call.

Returns:

Arbitrary type, the value is ignored.

getInfoBases

Description:

Parameters:

ClientID                              input/output

Type: String. Contains the client ID for which the shared Infobase list is retrieved. If the client ID is not specified (or equal to 00000000-0000-0000-0000-000000000000), the method assigns the client ID and returns it in this parameter.

InfoBasesCheckCode                          output

Type: String. Value of the code identifying the shared Infobase list returned by this method in the InfoBases parameter.

InfoBases                                   output

Type: String. The shared Infobase list in the v8i format.

Returns:

Arbitrary type, the value is ignored.

Implementation example

This section reviews an example of web service used to retrieve the shared Infobase list.

NOTE. The example given in this section is not complete. It is intended for the general functionality demonstration.

A simple configuration including one catalog and one web service is used as a web service.

The catalog is organized as follows:

  • Name SaredInfoBasesList.
  • Code type String, length is 36 characters.
  • Attributes:
    • Name ListCode, type UniqueIdentifier.
    • Name IBList, type String, unlimited length.
  • The remaining parameters have default values.

This catalog will store the list of customer IDs (standard attribute Code), the shared Infobase list (attribute IBList), and the current version of the Infobase list (attribute ListCode) determined when the list was last retrieved for this client. The version of the list is a unique identifier and it is changed each time a directory item is saved. For this purpose in the object module, the handler BeforeWrite is defined:

Procedure BeforeWrite(Cancel)
 ListCode = New UniqueIdentifier;
EndProcedure

In addition in the configuration the WebCommonInfoBases web service must be created with the following operations defined:

  • CheckInfoBases, the Return Value Type property is set to string, the Possibly Empty Value checkbox is set. The remaining properties are set to default values.
  • GetInfoBases, the Return Value Type property is set to string, the Possibly Empty Value checkbox is set. The remaining properties are set to default values.

Text of the web service operations:

Function CheckInfoBases(ClientID, InfoBasesCheckCode, InfoBaseChanged, URL)

 If ClientID = "00000000-0000-0000-0000-000000000000"
   And InfoBasesCheckCode = "00000000-0000-0000-0000-000000000000" Then
   // the first request of the client
   InfoBaseChanged = True;
   URL = "/listservice2/ws/WebCommonInfoBases";
   Return "";
 EndIf;         
 Client = Catalogs.SharedBaseList.FindByCode(ClientID);
 If Client.Empty() Then
   // no such client
   InfoBaseChanged = False;
 Else
   // check that the list on the client side and our list are the same
   If InfoBasesCheckCode = Client.ListCode Then
    // the list is not changed
    InfoBaseChanged = False;
    URL = "";
   Else
    // the list is changed
    InfoBaseChanged = True;
    URL = "/listservice2/ws/WebCommonInfoBases";
   EndIf;         
 EndIf;         
 Return "";
 EndFunction
 
Function GetInfoBases(ClientID, InfoBasesCheckCode, InfoBases)

 If ClientID = "00000000-0000-0000-0000-000000000000" Then
   CurUser = InfoBaseUser.CurrentUser();
   // need to add new client
   // as a code of the catalog element the unique identifier 
   // of the infobase user will be used
   Object = Catalogs.SharedBaseList.NewElement();
   Object.Code = String (CurUser.UniqueIdentifier);
   // the client name will be equal to the user name 
   Object.Name = CurUser.Name;
   // the IB list is empty at the first call
   Object.IBList = "";
   Object.Write();
   // to form the returned values of the web service
   InfoBasesCheckCode = Object.CodeList;
   InfoBases = Object.IBList;
   ClientID = Object.Code;
 Else
   // here we get the data for the existing client code
   Client = Catalogs.SharedBaseList.FindByCode(ClientID);
   If Client.Empty() Then
    // no such client
    InfoBasesCheckCode = "";
    InfoBases = "";
   Else
    InfoBasesCheckCode = Client.CodeList;
    InfoBases = Client.IBList;
   EndIf;         
 EndIf;         
 Return "";

EndFunction

After creating the configuration, the web service should be published to the webserver twice. Then the addresses of published web services should be stored. Suppose that web services are published at the addresses:

The Infobase should contain users: Anonymous, and, for example, users Operator, Storekeeper, Accountant.

The default.vrd file, which describes the publication at http://localhost/listservice, is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<point xmlns="http://v8.1c.ru/8.2/virtual-resource-system"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   base="/listservice"
   ib="File=X:\DB\ListBase;Usr=Anonimous"
   enable="false">
 <ws>
   <point name="WebCommonInfoBases"
     enable="true"/>
 </ws>
</point>

The default.vrd file, which describes the publication at http://localhost/listservice2, is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<point xmlns="http://v8.1c.ru/8.2/virtual-resource-system"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   base="/listservice2"
   ib="File= X:\DB\ListBase;"
  enable="false">
 <ws>
   <point name="WebCommonInfoBases"
     enable="true"/>
 </ws>
</point>

In the settings of the webserver where you published the web service for retrieving the shared Infobase list, the HTTP HEAD request should be disabled (at least for virtual catalogs to access the web service). Otherwise, the web service will not be used.

In the launch window setup form, you need to add a web service with the address shown above including the suffix wshttp://localhost/listservice/ws/.

After completing the configuration you should run the launcher. When prompted to enter a username and password to access the 1C:Enterprise web service, you should enter the names Operator, Storekeeper, Accountant. The corresponding entries are added to the SharedBaseList catalog. If you place into the IBList attribute of each catalog element your list in the v8i format, this list will be added to the list of infobases of the launcher after authentication.

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.