What web services are there. What is a web service? Technical implementation of web services

A web service (service) is a program that organizes interaction between sites. Information from one portal is transferred to another.

For example, there is an airline. She has many flights, respectively, a lot of tickets. It transmits information through a web service to the tour travel aggregator site. A user who enters the aggregator will be able to buy tickets for this airline right there.

Another example of web services is a weather tracking site that provides information about weather conditions in a particular city or country as a whole. This information is also often used by third parties.

Information on the Internet is diverse. Sites are managed different systems. different transmission and encryption protocols are used. Web services simplify the exchange of information between different sites.

Web services architecture and protocols

You can define 3 instances that interact with each other: catalog, contractor and customer. After creating the service, the performer registers it in the catalog, and the customer finds the service there.

The data exchange mechanism is formed in the Web Services Description. It is a specification covering the forwarding formats, content types, transport protocols that are used in the exchange of information between the customer and the service transporter.

Today, several technologies are most often used to implement various web services:

  1. TCP/IP is a protocol that is understood by almost everyone network equipment, from mainframes to portable devices and PDA.
  2. HTML is a universal markup language used to display content to consumer devices.
  3. XML is a universal tool for handling all kinds of data. Other information exchange protocols can also work on its basis: SOAP and WSDL.
  4. UDDI is a universal source of recognition, integration and description. It works, as a rule, in private networks and has not yet found sufficient distribution.

The versatility of the presented technologies is the basis for understanding web services. They work on standard technologies that are independent of application vendors and other network resources. Can be used in any operating systems, application servers, programming languages, etc.

Advantages

  • Creation of the necessary conditions for the interaction of software components, regardless of the platform.
  • Web services are based on open standard protocols. Through the introduction of XML, it is easy to create and configure web services.
  • The use of HTTP guarantees the interaction of systems through inter-network access.

disadvantages

  • Low performance and a large amount of traffic, in comparison with RMI, CORBA, DCOM systems, due to the use of XML-messages in the context of text.
  • Security level. All modern web services must implement coding, and require user authorization. Whether HTTPS is enough here or more reliable protocols are needed, such as XML Encryption, SAML, etc., are decided during development.

Web service tasks

Web services can be used in many areas.

B2B transactions

Integration of processes goes at once, without participation of people. For example, updating the catalog of an online store with new products. They are brought to the warehouse, and the storekeeper marks the arrival in the database. Information is automatically transferred to the online store. And the buyer, instead of marking “Out of stock” on the product card, sees its quantity.

Enterprise service integration

If the company uses corporate programs, then the web service will help set up their joint work.

Creation of a client-server system

Services are used to customize client and server operation. This gives you the following benefits:

  • can not sell alone software, but make paid access to the web service;
  • easier to solve problems using third-party software;
  • it is easier to organize access to the content and materials of the server.

A web service is an application that simplifies the technical configuration of resource interactions.

The 1C:Enterprise Web services mechanism is based on the use of metadata objects of the same name, i.e. configuration objects from the "Web services" branch.

1. GENERAL DEFINITIONS

Let's try to give a generalized definition of the term "Web service".

web-service is a network technology that provides interprogram interaction(between different applications) based on web standards. Web services make it possible to access from one application to another and at the same time perform certain functions.

A web service is identified by a URI (Uniform Resource Identifier) ​​string - a uniform resource identifier (this is a character string that allows you to identify a resource).

The web service has a programming interface presented in the format WSDL(Web Services Description Language) - a language for describing web services and accessing them, based on the XML language (http://www.w3.org/TR/wsdl specification). Designed for a unified view external interfaces web services and is used to let another program know that this program has such a "service" (i.e. the first program on the website lays out information about its services in the WSDL file format).

Other systems interact with the web service by exchanging SOAP (Simple Object Access Protocol) messages - a protocol for exchanging structured messages in a distributed computing environment (http://www.w3.org/TR/soap specification). Like any text-based protocol, SOAP can be used with any application layer protocol: SMTP, FTP, HTTPS, and more, but most often SOAP is used over HTTP.

Figure 1. Web service concept.

SOAP is used for arbitrary XML messaging and remote procedure call (RPC).

Thus, between the web service and the application, XML documents are exchanged in the form of messages. Web services standards define:

Message format, interface to which the message is sent;

Rules for binding the content of the message to the application implementing the service and vice versa;

Mechanisms for publishing and searching for interfaces.

The simplest and most obvious use of web services is to obtain reference data from public services available on the Internet. For example, Aeroflot provides information about its flights through a Web service, the Bank of Russia - information about exchange rates, securities, credit organizations - there can be many options.

2. WEB-SERVICES IN THE SYSTEM "1C: ENTERPRISE"

1C:Enterprise 8 application solution can be:

Web Service Provider;

In the 1C:Enterprise 8 system, Web services are one of the platform mechanisms used for integration with other information systems and 1C:Enterprise 8 applications among themselves.

In other words, 1C:Enterprise can export its functionality via Web services. Their definitions are set in the configuration tree and become available to arbitrary information systems by publishing them on a web server.

The Web services mechanism in 1C:Enterprise is a means of supporting Service-Oriented Architecture (SOA), meaning that programs use "services" to exchange data with each other.

In order for the functionality of 1C:Enterprise to be available to external consumers of Web services, you need to do the following:

Create the required number of Web services in the configuration;

Creating a Web service is:

In addition to the metadata tree of the Web service configuration object;

Description of the operations that this Web service can perform;

Description of operation parameters.

The Web service configuration object contains a module that creates procedures in the built-in language that are executed when certain Web service operations are called. Web service operation parameter types are described using XDTO types and can be either XDTO values ​​or XDTO objects.

The call to the Web service goes like this:

A suitable connection to the infobase is selected from the connection pool; in the absence of a required connection, a connection is created;

A new session is created;

The requested Web service method is called.

The Web services mechanism implemented in 1C:Enterprise supports the following standards:

WS-I Basic Profile 1.1;

SSL 3.0/TLS 1.0.

3. STUDYINGWEB-SERVICES IN THE SYSTEM "1C: ENTERPRISE"

A web service is a program that can be accessed by other programs over the Internet (http). For example, suppose you have a function that provides HTML text. The purpose of the application is a web browser that displays the results and a person can easily read this text on the page.

On the other hand, the target audience of a web service is other programs or other web services that consume the data served by the web service. Typically, the output is in a standard language that other programs can understand. Take the example above, if a web service outputs text in XML format, then other web services that can read or understand XML can use that output.

The main benefit of a web service is that applications can be written in any language, but they can communicate and communicate with each other via a web service. Software applications written in different programming languages ​​and running on different platforms can use web services for data exchange over the Internet (HTTP). This interaction (for example, between Java and Python, or Windows applications and Linux) is associated with the use of open standards (XML, SOAP, HTTP).

  • SOAP (Simple Object Access Protocol)
  • UDDI (Universal Description, Discovery and Integration)
  • WSDL (Web Services Description Language)

How many different kinds of web services are there?

Primarily, there are two types of web services, Simple Object Access Protocol (SOAP) and Representational State Transfer (REST).

  • The SOAP web service accepts an XML request and generates XML output.
  • REST web service is more generic and can accept XML as well as JSON as a request and generate output in XML as well as JSON or even HTML

This issue can be studied in more detail on ours.

We have reviewed general concepts mechanism « web-services". Let's refresh some knowledge.

Web services are used to exchange data between a server and a client; the XML format is used to “package” data for mutual understanding between both participants in the communication.

CHAPTERI

IMPLEMENTATION EXAMPLEWEB-SERVICE IN THE SYSTEM "1C: ENTERPRISE"

A TASK: It is necessary to create a web service, referring to which clients can determine all the necessary information for their applications.

The task is a demonstration one and serves only as an example for understanding and learning the mechanismweb-services.

DECISION:

Step 1. Let's create a new information base without configuration to develop a new configuration.

Step 2 Let's add some new objects to the configuration

Directory "Clients";

Document "Application";

Enumeration "Statuses of Applications".

Step 3 Let's create a new XDTO package.

Why and why are we creating an XDTO package? You can read more about using the XDTO mechanism in "Chapter 16. Developer's Guide" and.

Let us briefly note only that the XDTO mechanism is universal way data representations for interaction with various external data sources and software systems.

In our case, an XDTO package is created to describe the return value of the web service.

Expand the branch “General” → “XDTO packages” → Add…

Specify the name of the XDTO package " DocumentsData' and its namespace http://localhost/request or http://192.168.1.76/request (for ease of understanding and learning, we specify local IP address the computer where the web server is installed (supported web servers: IIS or Apache)). Each Web service can be uniquely identified by its name and the URI of the namespace to which it belongs.

Our package contains two types of XDTO objects:

1) Customer- to transfer the data of the "Clients" directory element.

- Name ;

2) document- to transfer the data of the document "Application"

This type of XDTO object will contain the following properties:

- Customer- Customer type from the http://192.168.1.76/request namespace; is a reference to the XDTO object we defined above;

- Status- string type from http://www.w3.org/2001/XMLSchema namespace;

- Numder- string type from http://www.w3.org/2001/XMLSchema namespace.

Step 4 Add a new Web service to the configuration

Expand the branch "General" → "Web services" → Add ...

For the Web service, specify the following property values:

Name - DocumentsData

URI Namespaces - http://192.168.1.76/request

XDTO Packages - DocumentsDataorhttp://192.168.1.76/request

Publication File Name - request.1cws

Step 5 For the created Web service, we define the operation " getdata»

Operation property values:

Return type - Document (http://192.168.1.76/request)

Possibly empty value - True

Procedure name - getdata.

Step 6 Operation getdata define the Customer parameter with the following property values:

Value type - type string from the http://www.w3.org/2001/XMLSchema namespace;

Transfer direction - input.

Step 7 Let's open the module of the created Web service and place the Get() function in it, which will be executed when this Web service is called.

Function GetData(Customer) // Get the types of XDTO objects ClientType = FactoryXDTO.Type("http://192.168.1.76/request", "Customer"); RequestType = FactoryXDTO.Type("http://192.168.1.76/request", "Document"); // Get the client ClientReference = Directories.Clients.FindByName(Customer); If Not ValueFilled(ClientReference) Then Return Undefined; EndIf; Request = New Request; Request.Text = "SELECT FIRST 1 | Ticket.Reference, | REPRESENTATION(Ticket.Status) AS Status, | Ticket.Number |FROM | Document.Ticket AS Ticket |WHERE | Ticket.Client = &Client"; Request.SetParameter("Client", ClientReference); QueryResult = Query.Execute(); If QueryResult.Empty() Then Return Undefined; EndIf; Selection = QueryResult.Select(); Selection.Next(); Document = Selection.Reference.GetObject(); // Create an XDTO ticket object Ticket = FactoryXDTO.Create(TicketType); Application.Numder = Sample.Number; Client = FactoryXDTO.Create(ClientType); Client.Name = ClientReference.Name; Application.Customer = Client; Application.Status = Selection.Status; // Return request Return Request; EndFunctions

Step 8 Let's publish the created Web service on the web server.

Configurator menu item: "Administration" → "Publishing on a Web server".

On the "Web services" tab, set the "Publish Web services" flag and also check the box next to our new Web service.

CHAPTERII

EXAMPLE OF REFERENCE TOWEB- 1C:ENTERPRISE SERVICE FROM A THIRD-PARTY APPLICATION

The main purpose of the Web services mechanism in 1C:Enterprise is to transfer the necessary data to third-party applications.

Let's consider an example of developing an application in Delphi calling our web service from the first section of this article.

Step 1. Let's create a new project and place several controls on the form

Text field - used to display information received from the web service;

Two buttons - clearing the text field and accessing the web service;

The input field is a parameter passed to the web service.

Step 2 Importing the WSDL file

As a result, we get a new module request(we defined such a name directly in 1C). This module contains all the necessary information on the web service.

Step 3 Write a web service call handler

The DocumentDataPortType variable is already defined in the module request

Step 4 Launch the application and check.

CHAPTERIII

EXAMPLE OF REFERENCE TOWEB-SERVICE IN THE SYSTEM "1C: ENTERPRISE"

Step 1. Let's create a new external processing named "WEB_Service"

Step 2 For processing, we define new form

Step 3 Specify several details for the form

Client - type "String"

ClientReturn - type "String"

NumberReturn - type "String"

StatusReturn - "String" type.

We will display the details on the form.

Step 4 Let's add the form command " To get data»

Specify a command handler

&OnClient Procedure GetData(Command) GetDataOnServer(Client); End of Procedure Procedure GetDataOnServer(Client) // Create a WS proxy based on the link and execute the Get() operation Definition = New WSDefinitions("http://192.168.1.76/WEB_Service/ws/request.1cws?wsdl"); Proxy = New WSProxy(Definition, "http://192.168.1.76/request", "DocumentsData", "DocumentsDataSoap"); RequestData = Proxy.GetData(Client); If OrderData = Undefined Then ClientReturn = "Undefined"; StatusReturn = "Undefined"; ReturnNumber = "Undefined"; Return; EndIf; CustomerReturn = RequestData.Customer.Name; StatusReturn = RequestData.Status; ReturnNumber = RequestData.Numder; EndProcedure

1C:Enterprise can use web services provided by other providers in two ways:

By using static links created in the configuration tree;

"a plus": high speed of work;

"minus": re-importing the WSDL description using the configurator and saving the changed configuration.

By using dynamic links created by means of the built-in language

(respectively, the "cons" of static for dynamic ones are "pluses")

CHAPTERIV

DEBUGING WEB SERVICES IN THE 1C:ENTERPRISE SYSTEM

For a local web service, you need:

Step 1. Put on the client where the 1C system is launched file webservicecfg.xml with the following content

Step 2 To file default. vrd publish config add line

Step 3 In the configurator, select the menu item

"Debug" → "Connection" → "Automatic connection" → "Web services on the server"

Step 4 Click on the "OK" button

For the server version, you also need to run the 1c server in debug mode with the key /debug