1C:Enterprise 8.3. Administrator Guide. Appendix 6. Internet Services for Obtaining Common Infobase Lists and Client Application Distribution Sets

1C:Enterprise 8.3. Administrator Guide. Contents


APPENDIX 6. INTERNET SERVICES FOR OBTAINING COMMON INFOBASE LISTS AND CLIENT APPLICATION DISTRIBUTION SETS

6.1. OBTAINING THE LIST OF COMMON INFOBASES

When working remotely (e.g. through a web server), you need to obtain the list of common infobases. In this case the CommonInfoBases parameter of the 1CEStart.cfg configuration file does not allow you to get such a list. To obtain it, you can publish a common infobase list through an internet service. The list can be obtained both via HTTP queries and web services.

6.1.1. Obtaining a distribution set through a web service

To obtain the list of common infobases through a web service, you have to publish a special web service that will return the list. Let’s have a closer look at this web service operation.

6.1.1.1. Web service operation

The interactive launcher (1cv8s) can obtain a list of common infobases both from the local network and via the internet. Lists of common infobase are obtained through the internet only if the launch is interactive and the address to receive a list of common infobases is specified (the InternetService or WebCommonInfoBases parameter of the 1CEStart.cfg file).

To function properly, the mechanism used to receive a common infobase list should meet the following requirements:

„ the WebCommonInfoBases.CheckInfoBases() method should be called anonymously;

„ the WebCommonInfoBases.GetInfoBases() method should be called with an authentication;

„ the infobase that returns common infobase lists should contain a list of users eligible to call that infobase to obtain a list of infobases.

The first step involves calling the WebCommonInfoBases.CheckInfoBases() method (anonymously). If it is the first time the interactive launcher is called for that computer and that user, then the 00000000-0000-0000-0000-000000000000 value is passed as the ClientID and InfoBaseCheckCode parameters. If it is not the first time, the client code and the code identifying the current list of common infobases are passed as parameters. The web service method should define whether the common infobase list has to be updated or not. If it does, the InfoBasesChanged output parameter should be set to True, and the URL parameter should contain the address of a web service in which the WebCommonInfoBa- ses.GetInfoBases() method is implemented (authentication is required). Otherwise, the InfoBasesChanged parameter should be set to the value False and the URL parameter should include a null string.

The algorithm used to check the invariability of the common infobase list is not scheduled and can be arbitrary. It should be noted that the interactive launcher does not calculate the code value identifying the common infobase list, it merely stores the value passed when the web service was last called.

If, when calling the WebCommonInfoBases.CheckInfoBases() method, it emerges that the list needs to be updated, the interactive launcher calls the WebCommonInfoBases.GetInfoBases() method of the web service. The web service is located at the address that the WebCommonInfoBases.CheckInfoBases() function has returned in the URL parameter. The GetInfoBases() method should map the user in whose account the web service authentication is performed with any code of the client. There can be a “personal” mapping, when the user identifies him/ herself using his/her personal user name and password and gets his/her personal list of common infobases. There can also be a role-based mapping, i.e. the user identifies his/her role, e.g. Operator, Storekeeper, etc., and gets a common infobase list shared by all users in the same role. It should also be realized that in the first instance, the infobase executing the GetInfoBases() method should contain a list of all users who could start the interactive launcher (1cv8s) connected with the web service. In the latter case, the user list can only include role names.

The GetInfoBases() method should return three values:

„ the client code (if not set);

„ the common infobase list in the v8i format (see page 235);

„ the value of the code identifying the passed list of common infobases. This value will be passed to the WebCommonInfoBases.CheckInfoBases() method the next time it is checked whether the common infobase list needs updating. If it is the first time the common infobase list is obtained, the client code value (the ClientID parameter) is 00000000-0000-0000-0000-000000000000.

In addition, the following aspects must be taken into account:

„ The infobase where the WebCommonInfoBases web service is implemented must be published in two different publications, as an identical level of authentication must be guaranteed for calling the CheckInfoBases() and GetIndoBases() method.

„ Anonymous access can be provided for by explicitly specifying the user in whose account the default.vrd file is accessed.

„ The user in whose account anonymous access is being arranged must not be able to call the method of getting an infobase list, he/she must only be allowed to specify whether or not the list has changed as compared to the passed ClientID value.

None of publications serving the WebCommonInfoBases web service must permit working with web clients.

6.1.1.2. Web service description

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

Web service methods are listed below.

CheckInfoBases

Description

The interactive launcher (1cv8s) uses this method to verify whether a list of common infobases is required.

Parameters:

       ClientID                                                   in

Type: String. Includes the ID of the client for the relevance of the common infobase listis checked.

InfoBaseCheckCode                                           in

Type: String. This is a code identifying the infobase list. The code must expressly identify the current list of infobases. In the event of any changes to the list, the code must also change and be different from any of codes previously used for that client identifier.

InfoBasesChanged                                           out

Type: Boolean. This indicates that the list of common infobases should be obtained again.

URL                                                        out

Type: String. This is a URL at which a list of common infobases must be requested if that list has changed since the previous query.

Returned value:

Type: arbitrary, the value is ignored.

GetInfoBases

Description

Parameters:

ClientID                                                In/out

Type: String. Includes the ID of the client for which the list of common infobases should be obtained. If the client ID is not set (its value is 000000000000-0000-0000-000000000000), the method has to assign the client ID and return it in this parameter.

InfoBaseCheckCode                                       In/out

Type: String. The value of the code identifying the common infobase list returned by that method in the InfoBases parameter.

InfoBases                                               In/out

Type: String. List of common infobases in the v8i format (see page 235).

Returned value:

Type: arbitrary, the value is ignored.

6.1.1.3. Example of implementation

Let’s consider a web service example for getting a common infobase list.

NOTE

The example provided in this section is not a complete solution, and it only serves to demonstrate the mechanism principle.

The web service is a simple configuration comprising one catalog and one web service.

The catalog has the following characteristics:

„ Name CommonInfoBaseList.

„ Code type: String, length: 36 characters.

„ Attributes:

Name ListCode, type: UUID.

Name: IBList, type: String, open ended.

„ Other parameters are set to default.

This catalog will store a list of client identifiers (the Code standard attribute), a common infobase list (the IBList attribute) and a then-current version of the common infobase list (the ListCode attribute) calculated when the list was last obtained for that client. The list version is a unique identifier that changes each time the catalog item is saved. To this effect, the BeforeWrite handler is defined in the object module:

BeforeWrite(Cancel) Procedure
ListCode  = New UUID;
EndProcedure

The WebCommonInfoBases web service must also be created in the configuration for which the operations listed below must be defined:

CheckInfoBases, the Return value type property is set to the string value, the Value can be blank checkbox is selected. Other properties are set to default values. For method parameters and their types, see page 327.

GetInfoBases, the Return value type property is set to the string value, the Value can be blank checkbox is selected. Other properties are set to default values. For method parameters and their types, see page 322.

Web Service Operation Text:

Function  CheckInfoBases(ClientID, InfoBaseCheckCode, InfoBaseChanged)

If ClientID = "00000000-0000-0000-0000-000000000000"
And  InfoBaseCheckCode = "00000000-0000-0000-0000-000000000000" Then
// it is the client’s first call
InfoBaseChanged = True;

 

                                               URL = "/listservice2/ws/WebCommonInfoBases";

 

                               Return "";

 

                EndIf;

 

                                               Client = Catalogs.CommonInfobaseList.FindByCode(ClientID);

 

                               If Client.Empty() Then

 

                                // such client does not exist

 

                                InfoBaseChanged = False;

 

                Else

 

                                                               // check if the list on the client’s side and our list are identical

 

                                               if InfoBaseCheckCode = Client.ListCode Then

 

                                               // the list has not changed

 

                                               InfoBaseChanged = False;

 

                                URL = "";

 

                                Else

 

                                                // the list has changed

 

                                               InfoBaseChanged = True;

 

                                                               URL = "/listservice2/ws/WebCommonInfoBases";

 

                                EndIf;

 

                EndIf;

 

               Return "";

 

               EndFunction

 

 

 

Function GetInfoBases(ClientID, InfoBaseCheckCode, InfoBases)

 

 

 

                                               If ClientID = "00000000-0000-0000-0000-000000000000" Then

 

                                               CurUser = InfoBaseUsers.Currentuser();

 

                                               // new client must be created

 

                                               // the catalog item code will be a unique ID

 

                                // of the Infobase user

 

                                                               Object = Catalogs.CommomInfobaseList.CreateItem();

 

                                               Object.Code = String(CurUser.UUID);

 

                                               // the client name will be the user name

 

                                               Object.Name = CurUser.Name;

 

                                               // the IB list is empty at the first call

 

                               Object.IBList = "";

 

                               Object.Write();

 

                                               // generate returned values of the web service

 

                                               InfoBaseCheckCode = Object.ListCode;

 

                               InfoBases = Object.IBList;

 

                               ClientID = Object.Code;

 

                Else

 

                                               // get data for the existing client code here

 

                                                              Client = Catalogs.CommomInfobaseList.FindByCode(ClientID);

 

                                If Client.Empty() Then

 

                                               // such client does not exist

 

                                               InfoBaseCheckCode = "";

 

                                               InfoBases = "";

 

                                Else

 

                                                               InfoBaseCheckCode = Client.ListCode;

 

                                               InfoBases = Client.IBList;

 

                                EndIf;

 

                EndIf;

 

               Return "";

 

 

 

EndFunction

After the configuration is created, the web service has to be published twice on the web server (see page 161). The address of the published web services should be remembered. Have web services published at:

„ http://localhost/listservice – an anonymous web service;

„ http://localhost/listservice2 – a web service requiring authentication;

The infobase should contain the Anonymous user and, for example, users named Operator, Storekeeper, Accountant.

The default.vrd file that describes the publication at http://localhost/listservice looks like this:

<?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=Anonymous"
enable="false">
<ws>
<point  name="WebCommonInfoBases"
enable="true"/>
</ws>
</point>

The default.vrd file that describes the publication at http://localhost/listservice2 looks like this:

<?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>

The configuration of the web server for which the web service of getting the common infobase list has been published should not permit the HEAD HTTP-query to be processed (at least for the virtual directories through which the web service is called). Otherwise, the web service will not be used.

Add the internet service with the above address in the Startup Window Settings form (see page 90) and specify the ws suffix: http://localhost/listservice/ws/.

After the setting has been implemented, start the launcher. When the system prompts that the user name and the password be entered for accessing the 1C:Enterprise web service, enter Operator, Storekeeper, Accountant. The Com- monInfoBaseList catalog will have relevant entries. If a separate list in the v8i format is placed in the IBList attribute of each item of the catalog, then that list will be added to the launcher infobase list after authentication is performed.

6.2. OBTAINING A CLIENT APPLICATION DISTRIBUTION SET

Working remotely (through a web server), you need to obtain a client application distribution set automatically when the system version is replaced on the 1C:Enterprise server (or a web server). In this case searching for a new version by the DistributiveLocation parameter of configuration files may fail. To obtain the distribution set, you can publish a client application distribution set through an internet service. The list can be obtained both via HTTP-queries and web services.

6.2.1. Obtaining a distribution set through a web service

To get the client application distribution set through a web service, you have to publish a special web service that will return this distribution set. Let‘s have a closer look at this web service operation.

6.2.1.1. Web service operation

If the thin client (1cv8c) is started with the -AppAutoCheckVersion key, the system attempts to find a thin client version when it does not match the version of the 1C:Enterprise server or web server extension. Three mechanisms are applied for this purpose (listed in the order they are used):

„ Search for a distribution set in the local network – by using the DistributiveLocation parameters of configuration files (1CEStart.cfg and 1CEScmn.cfg).

„ Obtaining the client application distribution set by URL specified in the default. vrd configuration file (the point item attribute, see page 257) or in the conf. cfg configuration file (the PublishDistributiveLocation parameter, see page 251). The value specified in the default.vrd file has a higher priority.

„ Obtaining the file through a web service for getting a client application distribution set. To this effect, specify the web service address in the 1CEStart.cfg configuration file (the InternetService or WebDistributiveLocation parameter; see page 241 for details) or in the Startup Window Options dialogue (see page 94 for details).

The thin client analyses results of calling the web service. If the web service returns 0 in the Size parameter, the required distribution set for the required client application is considered to be unavailable and the system returns an error message that client application and server versions do not match. Otherwise, the user will be prompted to download and install a client application with the distribution set size specified. If the user agrees, a new version is downloaded and installed, after which a required version of the client application is restarted. During the distributive file load, the timeout to execute the operation is 600 seconds. Redirect is not supported on the web server side when the distributive file is being loaded.

6.2.1.2. Web service description

Web service name: WebDistributiveLocation. The timeout for any web service execution is 3 seconds.

Web service methods are listed below.

GetDistributiveInfo

Description

This method is used by the thin client (1cv8ñ) to obtain a client application distribution set of the required version when:

„ The client application version and the server version do not match in the client/ server mode when connected via a web server.

„ The client application version and the web server extension version do not match in the file mode when connected via the web server.

Parameters:

      OS                                                         in

Type: String. The type of the operating system for which the client applica tion distribution set has to be obtained.

Available values: Windows, Linux.

Arch

-

in

Type: String. The architecture of the OS for which the client application

 

distribution set has to be obtained.

Available values: x86, x86_64.

Version

in

Type: Boolean. The version number of the client application whose distribution set is required.

Size                                                       out

Type: Number. The client application distribution size (in byte). If the distribution set requested is not available, the 0 value should be returned.

URL                                                        out

Type: String. This is URL to download the client application distribution set. When generating URL, remember that the distribution set file should be available for the web server, and the user who will receive the distribution set should have the right to download that file.

The client application distribution set is a zip file containing distribution files, without any hierarchy.

Returned value:

Type: arbitrary, the value is ignored.

6.2.1.3. Example of implementation

Let us examine an example of a web service for getting a client application distribution set.

NOTE

The example given in this section is not a complete solution. It is provided to demonstrate the mechanism principle.

The web service is a simple configuration that is comprised of the web service itself and has no other configuration objects. Client application distribution sets will be stored in a special directory that should be accessible for the web server. The WebDistributiveLocation web service should be created in the configuration, with the CheckInfoBases operation defined, the Return value type property set to string, and the Value can be blank check box selected. Other properties are set to default values. For method parameters and their types, see page 325.

Web service operation text

Function  GetDistributiveInfo(OS, Arch, Version, Size, URL)

DistributionSetDirectory = "C:\inetpub\Distribs\";
DistributionSetDirectory  = "C:\inetpub\Distribs\";
// generate the name of the file with an archive
FileName = "tc-" + Lower(OS) + "-" + Arch +  "-" + Version + ".zip";
Archive = New File(DistributionSetDirectory + FileName);
If Archive.Exist() Then
Size  = Archive.Size();
URL =  DistributionSetURL + FileName;
Else
Size  = 0;
URL  = "";
EndIf;
Return  "";

EndFunction

In the DistributionSetDirectory and DistributionSetURL variables, specify correct values that correspond to the actual name of the directory with client application distribution sets (DistributionSetDirectory when the directory is called from a web service, and DistributionSetURL when the directory is called through a web service).

The file with the distribution set should have the tc-windows-x86-8.3.3.657.zip name or an identical one (depending on the OS type and the architecture of the client application requested). The name of the file with the archive is defined by the program code of the web service specified in the example above.

After the configuration is created, the web service has to be published on the web server (see page 161). The address of the web service published should be remembered. Let us suppose that the web service is published at http://localhost/getdistr.

Add the internet service with the above address in the Startup Window Settings form (see page 94) and add the ws suffix to it: http://localhost/getdistr/ws. Now when the distribution set is needed, the query to the web service will be executed. If the DistributionSetDirectory directory (on the web service computer) has a zip file with the required distribution set, this file will be forwarded to the computer requesting for the distribution set.

Leave a Reply

Your email address will not be published.

 

1C:Enterprise Developer's Community