An interface simulation method and device for automatically providing interface services

Through the interface simulation method that automatically provides interface services, and uses the unified interface service data format and MAP mapping table, it solves the complex problem of cross-manufacturer device interface docking, realizes efficient joint debugging of software systems and synchronous development of front-end and back-end, and improves development efficiency and Simplified development environment.

CN110908636BActive Publication Date: 2024-10-29BOCO INTER TELECOM CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201811086891.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-18
Publication Date
2024-10-29
Estimated Expiration
2038-09-18

AI Technical Summary

Technical Problem

In the process of software system development, the interface docking of cross-manufacturer equipment is complex and inefficient, causing developers to spend a lot of time and energy. Front-end and back-end development cannot be carried out simultaneously, and there are restrictions on interface docking.

Method used

The interface simulation method that automatically provides interface services is used to realize interface data preparation and simulated response by unifying the interface service data format and simulation interface, allowing the front-end and back-end to be developed simultaneously, and quickly responding to interface requests through the MAP mapping table.

Benefits of technology

It improves the efficiency of joint debugging and docking between software systems and equipment from various manufacturers, saves development time, simplifies the development environment, reduces development costs, and achieves simultaneous front-end and back-end development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110908636B_ABST
    Figure CN110908636B_ABST
Patent Text Reader

Abstract

The present invention provides an interface simulation method for automatically providing interface services, including: prefabricating interface data, making an interface description file and an interface data return file for each interface, the interface data return file is made according to the interface description file, the interface description file is used to describe the interface data, and is made according to the interface description file specification; the interface data return file is the interface data returned after the interface is requested for service, and is made according to the interface data return file specification; the made interface description file and interface data return file are saved in an interface data storage device; interface request processing, receiving an interface service request sent by an interface data request end, reading the interface description file and interface data return file from the interface data storage device, parsing the interface description file and interface data return file, searching and generating response data of the requested interface, and returning it to the interface data request end. Also provided is an interface simulation device for automatically providing interface services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication interface technology, and in particular to an interface simulation method and device for automatically providing interface services. Background Art

[0002] Many large software systems involve the need to access data from multiple manufacturers' equipment. When developing a software system, the software system needs to be debugged or tested with the equipment of each manufacturer to achieve intercommunication between the software system and the equipment of multiple manufacturers. The intercommunication test process often consumes a lot of time and energy of software developers, especially when it comes to interface docking across manufacturers and devices. The situation is more complicated and prone to errors. It often requires repeated communication and repeated modification of the interface intercommunication code before the interface docking can be completed. The work efficiency is very low.

[0003] How to change this situation and improve the efficiency of the integration and docking of software systems with equipment from various manufacturers is an urgent issue.

[0004] On the other hand, in the process of developing network software, the following scenario often occurs: the front-end developer completes the development of the WEB page, while the back-end developer completes the creation of the database, sets up the server-side architecture, and then writes the client-side and server-side interface codes; after the interface is written, the front-end and back-end can start the interface docking and joint debugging. Since the front-end and back-end are often assigned to different development engineers for development, there is no guarantee of synchronous completion. If the front-end page is developed but the back-end interface is not yet written, the front-end development engineer needs to wait for the back-end development engineer to complete the back-end development before starting the joint debugging of the system interface.

[0005] How can we make the front-end and back-end do their own things at the same time, or how can we make the interface caller and the interface service provider not affect each other? Summary of the invention

[0006] In view of this, the purpose of the present invention is to provide an interface simulation method and device for automatically providing interface services, so as to realize efficient docking between the software system and the equipment of various manufacturers, save the time of software developers, and realize the simultaneous development and advancement of the software front-end and back-end, and get rid of the limitation that the development environment requires actual interface docking.

[0007] The interface targeted by the present invention is an interface that meets the requirements of REST technology. REST is a framework for organizing Web services and uses a client / server model. The client and the server communicate with each other through a unified interface.

[0008] To solve the above problems, the present invention envisions formulating unified interface specification requirements based on a unified interface service data format, replacing the real external interface service with a simulation interface service, and making the data of the simulation interface reliable and replaceable by standardizing the data format. The real-time joint debugging can be transformed into simulation joint debugging. After preparing the interface data that meets the specifications, the simulation interface can provide interface services at any time and respond to the needs of the interface request end at any time.

[0009] In a first aspect, an embodiment of the present invention provides an interface simulation method for automatically providing interface services, the method comprising two stages:

[0010] Interface data preparation stage:

[0011] Prefabricate interface data, prepare interface description files and interface data return files for each interface, the interface data return files are prepared according to the interface description files, the interface description files are used to describe the attribute characteristics of the interface data, and are prepared according to the interface description file specifications; the interface data return files are the interface data returned after the interface is requested for service, and are prepared according to the interface data return file specifications; the prepared interface description files and interface data return files are saved in the interface data storage device;

[0012] Interface simulation phase:

[0013] Interface request processing, receiving the interface service request sent by the interface data request end, reading the interface description file and the interface data return file from the interface data storage device, parsing the interface description file and the interface data return file, searching and generating the response data of the requested interface, and returning it to the interface data request end.

[0014] In combination with the first aspect, an embodiment of the present invention provides a first possible implementation scheme of the first aspect, wherein the interface description file includes: an interface identifier, an interface operation type, an interface processing function name, a return data file name, and interface parameters and return data types, the interface identifier is unique, the interface operation type includes query operation, creation operation, deletion operation and modification operation, and the interface data return file includes: an error status code returned by the interface and the content of the returned data.

[0015] In combination with the first aspect, the embodiment of the present invention provides a second possible implementation of the first aspect, wherein the interface request processing stage includes the following steps:

[0016] S1) regularly generating a MAP mapping table, regularly reading an interface description file from an interface data storage device, parsing the interface description file, and generating a MAP mapping table, wherein the MAP mapping table includes a mapping relationship between an interface identifier and an interface processing function name, and a set of mapping relationships between an interface identifier and an interface data return file name;

[0017] S2) receiving an interface service request and an interface identifier sent by an interface data requesting end;

[0018] S3) matching the interface, traversing the MAP mapping table according to the interface identifier, if the match is successful, directly obtaining the interface processing function name and the interface data return file name of the interface identifier, otherwise, returning an error status code and empty data to the interface data request end;

[0019] S4) searching and processing the matched interface, calling the interface processing function according to the interface processing function name and the interface data return file name, finding the corresponding interface data return file from the interface data storage, parsing the interface data return file, and obtaining the interface return data;

[0020] S5) Return the interface return data, and return the interface return data to the interface data requesting end.

[0021] In combination with the first aspect, an embodiment of the present invention provides a third possible implementation scheme of the first aspect, wherein the interface description file specification follows the YAML file format, and the interface data return file specification follows the JSON file format.

[0022] In combination with the first aspect, an embodiment of the present invention provides a fourth possible implementation method of the first aspect, wherein the process of preparing the interface description file described in the prefabricated interface data step in the data preparation stage according to the interface description file specification includes two methods: automatic or manual; in the automatic method, the interface description information is extracted from the actual implementation code of the external device interface, and the interface description file is automatically generated and saved to the interface data storage device; in the manual method, the interface description file is written according to the data format requirements of the interface description file specification and saved to the interface data storage device.

[0023] In combination with the first aspect, an embodiment of the present invention provides a fifth possible implementation of the first aspect, wherein the process of preparing the interface data return file according to the interface data return file specification in the prefabricated interface data step in the data preparation stage includes two methods: online or offline:

[0024] In an online mode, interface data is directly obtained by connecting to the actual external device interface. After the connection is successful, interface request data is constructed according to the interface identifier, interface operation type, and interface parameters of the interface description file, an interface request is issued, and interface return data is obtained from the external device interface. A legality check is performed. If legal, an interface data return file is automatically generated according to the interface data return file specification and saved to the interface data storage device.

[0025] In the non-online mode, the interface data return file is written according to the data format requirements of the interface data return file specification and saved in the interface data storage device.

[0026] In a second aspect, an embodiment of the present invention provides an interface simulation device for automatically providing an interface service, the device comprising:

[0027] The interface data prefabrication module is used to prepare an interface description file and an interface data return file for each interface. The interface data return file is prepared according to the interface description file. The interface description file is used to describe the interface data and is prepared according to the interface description file specification. The interface data return file is the interface data returned after the interface is requested for service and is prepared according to the interface data return file specification. The prepared interface description file and interface data return file are saved in the interface data storage device.

[0028] Interface data storage device, used for storing interface description files and interface data return files;

[0029] The interface request processing module is used to receive the interface service request sent by the interface data request end, read the interface description file and the interface data return file from the interface data storage device, parse the interface description file and the interface data return file, search and generate the response data of the requested interface, and return it to the interface data request end.

[0030] In combination with the second aspect, an embodiment of the present invention provides a first possible implementation method of the second aspect, wherein the interface description file includes: an interface identifier, an interface operation type, an interface processing function name, a return data file name, and interface parameters and return data types, the interface identifier is unique, the interface operation type includes query operation, creation operation, deletion operation and modification operation, and the interface data return file includes: an error status code returned by the interface and the content of the returned data.

[0031] In combination with the second aspect, the embodiment of the present invention provides a second possible implementation of the second aspect, wherein the interface request processing module includes: a polling unit, a communication unit, a matching unit and a processing unit, wherein:

[0032] A polling unit, used for periodically reading an interface description file from an interface data storage device, parsing the interface description file, and generating a MAP mapping table, wherein the MAP mapping table includes a mapping relationship between an interface identifier and an interface processing function name, and a set of mapping relationships between an interface identifier and an interface data return file name;

[0033] The communication unit is used to receive the interface identifier sent by the interface data request end and transfer it to the matching unit; and return the response data of the requested interface to the interface data request end;

[0034] A matching unit, used to traverse the MAP mapping table according to the interface identifier, and if the match is successful, directly obtain the interface processing function name and the interface data return file name of the interface identifier and send them to the processor module; otherwise, return an error status code and empty data to the communication unit;

[0035] The processing unit calls the interface processing function according to the received interface processing function name and interface data return file name. The interface processing function finds the corresponding data return file from the interface data storage device, parses the data return file, obtains the interface return data, and returns it to the communication unit.

[0036] In combination with the second aspect, an embodiment of the present invention provides a third possible implementation of the second aspect, wherein the interface description file specification complies with the YAML file format, and the interface data return file specification complies with the JSON file format.

[0037] In combination with the second aspect, the embodiment of the present invention provides a fourth possible implementation of the second aspect, wherein the interface data prefabrication module includes an interface description file preparation module, an interface description file parsing module, an interface request module, and an interface data return file preparation module, wherein:

[0038] The interface description file making module is used to extract interface description information from the actual implementation code of the external device interface, automatically generate an interface description file, and save it to the interface data storage; or, according to the data format requirements of the interface description file specification, write the interface description file and save it to the interface data storage;

[0039] The interface description file parsing module is used to read the interface description file from the interface data storage device, parse the interface identifier, interface operation type, and interface parameters therefrom to construct interface request data, and send the data to the interface request module;

[0040] The interface request module is used to establish a communication connection with the actual external device interface. After the connection is successful, an interface request is sent to the actual external device interface, interface return data is obtained from the external device interface, and sent to the interface data return file production module;

[0041] The interface data return file production module generates a data return file based on the data returned from the interface request module and saves it to the interface data storage device; or, according to the data format requirements of the interface data return file specification, writes the interface data return file and saves it to the interface data storage device.

[0042] The interface simulation method for automatically providing interface services in the embodiment of the present invention can speed up the front-end and back-end development process of the software system through the implementation of the interface data preparation stage and the interface simulation stage, and facilitate the developers to adjust the external interface needs at any time. The interface simulation device for automatically providing interface services in the embodiment of the present invention has the ability to provide the software system with convenient and automatic acquisition of external interface return data; when adding a new interface service, it only needs to add an interface description file and an interface return data file to the interface data storage device, that is, it can provide the ability to simulate the newly added interface service, without the need to develop additional program code, which greatly simplifies the development environment of the software system, reduces development costs, and saves development time.

[0043] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 A schematic flow chart of an interface simulation method for automatically providing interface services provided by a first embodiment of the present invention is shown.

[0046] Figure 2 A schematic diagram of an interface request processing flow of an interface simulation method for automatically providing interface services provided by a first embodiment of the present invention is shown.

[0047] Figure 3 A schematic diagram showing the module composition of an interface simulation device for automatically providing interface services provided by a second embodiment of the present invention is shown.

[0048] Figure 4 A schematic diagram showing the composition of an interface data prefabrication module in an interface simulation device for automatically providing interface services provided by a second embodiment of the present invention.

[0049] Figure 5 A schematic diagram showing the composition of an interface request processing module in an interface simulation device for automatically providing interface services provided by a second embodiment of the present invention. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present invention.

[0051] Embodiment 1

[0052] Figure 1 1 is a flow chart of an interface simulation method for automatically providing interface services provided by a first embodiment of the present invention, the method comprising the following steps:

[0053] Step S1, prefabricate interface data step: create an interface description file and an interface data return file for each interface, the interface data return file is created based on the interface description file, the interface description file is used to describe the interface data attribute characteristics, and is created based on the interface description file specification; the interface data return file is the interface data returned after the interface is requested for service, and is created based on the interface data return file specification; the created interface description file and interface data return file are saved in the interface data storage device.

[0054] This step will collect various commonly used interface data required, and use two files, interface description file and interface data return file, to express the interface data and load the return data of the response interface request. The file specifications should be able to express the data structure, and the data should be easy to read, analyze, interact and transmit. It can be customized, or it can adopt the industry-common file formats such as XML (Extensible Markup Language), YAML (YAML An't a Markup Lanague), JSON (JavaScript Object Notation), etc. The interface data storage is the storage carrier of all interface description files and interface data return files.

[0055] Step S2, interface request processing step: receive the interface service request sent by the interface data request end, read the interface description file and the interface data return file from the interface data storage device, parse the interface description file and the interface data return file, search and generate the response data of the requested interface, and return it to the interface data request end.

[0056] After the interface data collection is completed in step S1, the interface data is prepared for step S2. Step S2 specifically implements the request and response of the simulated interface.

[0057] Preferably, the interface description file may include: interface identifier, interface operation type, interface processing function name, return data file name, and interface parameters and return data type. The interface identifier is unique, and the interface data return file includes: the error status code returned by the interface and the content of the returned data.

[0058] Preferably, the interface description file may also include: interface identifier, interface name, interface address, interface operation type, interface description, interface processing function name, as well as interface parameters, the number of interface parameters and the type of returned data. The interface identifier is unique, and the interface data return file includes: interface identifier, error status code returned by the interface and the content of the returned data.

[0059] The interface operation types may include query operation, create operation, delete operation and modify operation.

[0060] Figure 2 This is a schematic diagram of an interface request processing flow of the interface simulation method for automatically providing interface services provided by the first embodiment of the present invention. This step also includes the following five sub-steps:

[0061] Step S21, regularly generating a MAP mapping table, regularly reading an interface description file from an interface data storage device, parsing the interface description file, and generating a MAP mapping table, wherein the MAP mapping table includes a mapping relationship between an interface identifier and an interface processing function name, and a set of mapping relationships between an interface identifier and an interface data return file name;

[0062] In order to quickly respond to interface requests, the MAP mapping table is a quick search tool. According to the interface identifier, the interface processing function name and the interface data return file name can be quickly found, thus improving the interface response efficiency. Generally, the MAP mapping table is generated when the system starts. In order to facilitate users to add new interfaces at any time, to cope with the newly added interface description files and interface data return files in the interface data storage, a timing polling mechanism is set to regularly generate new MAP mapping tables. In this way, the ability to simulate the newly added interface service can be provided without restarting the system or adding additional program coding.

[0063] Step S22, receiving an interface service request, and receiving an interface identifier sent by an interface data request end.

[0064] Step S23, matching the interface, traversing the MAP mapping table according to the interface identifier, if the match is successful, directly obtaining the interface processing function name and the interface data return file name of the interface identifier, otherwise, returning an error status code and empty data to the interface data request end.

[0065] If the interface processing function name and interface data return file name of the interface identifier are not found in the MAP mapping table, it means that there is no corresponding interface data. At this time, the user knows based on the returned error status code and is ready to pre-prepare the interface data and put it into the interface data storage device.

[0066] Step S24, search and process the matched interface, call the interface processing function according to the interface processing function name and the interface data return file name, the interface processing function finds the corresponding interface data return file from the interface data storage, parses the interface data return file, and obtains the interface return data.

[0067] Step S25, returning the interface return data, and returning the interface return data to the interface data requesting end.

[0068] Through the above method, the goal of quickly responding to interface requests can be achieved.

[0069] Preferably, the interface description file specification complies with the YAML file format, and the interface data return file specification complies with the JSON file format.

[0070] The YAML file format is an intuitive data serialization format that can be recognized by computers. It is a programming language that is highly readable and easy for humans to read, easy to interact with scripting languages, and used to express data sequences. It is a data description language similar to XML, a subset of the Standard Generalized Markup Language. Its syntax is much simpler than XML and has become the current mainstream data description method.

[0071] JSON file format is a lightweight data exchange format that uses a text format that is completely independent of the language. It is an ideal data exchange language. It is easy for people to read and write, and it is also easy for machines to parse and generate.

[0072] For example, the following interface description file definition is described in YAML file format:

[0073]

[0074] The above example defines an interface for creating a virtual network element, including the interface identifier, interface operation type, interface processing function name, return data file name, two interface parameters, return data type, error code and other interface description information.

[0075] The interface returns data, and an example of the JSON file format description is as follows:

[0076]

[0077] Furthermore, the process of making the interface description file described in the prefabricated interface data step of the data preparation stage according to the interface description file specification includes two methods: automatic or manual; in the automatic method, the interface description information is extracted from the actual implementation code of the external device interface, and the interface description file is automatically generated and saved to the interface data storage device; in the manual method, the interface description file is written according to the data format requirements of the interface description file specification and saved to the interface data storage device.

[0078] It should be noted that the automatic method is based on the code segment of the external device interface. A program is written to directly analyze the code segment, automatically extract the interface identifier, interface operation type, interface processing function name, return data file name, and interface parameters and return data type in the interface description information, automatically generate an interface description file, and save it to the interface data storage device.

[0079] The manual method can be completed by a text editor of other software, or by making a text editing module in this system.

[0080] Regarding the work in the interface data preparation stage, the process of preparing the interface data return file in the prefabricated interface data step in the data preparation stage according to the interface data return file specification includes two methods: online or offline:

[0081] In an online mode, interface data is directly obtained by connecting to the actual external device interface. After the connection is successful, interface request data is constructed according to the interface identifier, interface operation type, and interface parameters of the interface description file, an interface request is issued, and interface return data is obtained from the external device interface. A legality check is performed. If legal, an interface data return file is automatically generated according to the interface data return file specification and saved to the interface data storage device.

[0082] In the non-online mode, the interface data return file is written according to the data format requirements of the interface data return file specification and saved in the interface data storage device.

[0083] The online method is to collect data when the external device interface is actually available, and is a method for directly obtaining interface data. For example, system A and system B can be connected to test interface 1. System A is the caller of interface 1 and initiates a request to system B. System B responds to the request and returns the data of interface 1 to system A. In this case, the device applying the method of the present invention can replace the role of system A. The device of the method of the present invention sends a request for interface 1 to system B, and system B returns data to the device of the method of the present invention, and the data is saved as an interface data return file and saved in the interface data storage device.

[0084] The non-online method can be completed by a text editor of other software, or by a text editing module in this system.

[0085] Embodiment 2

[0086] Corresponding to the method in the above-mentioned embodiment 1, the embodiment of the present invention further provides an interface simulation device for automatically providing interface services, which is used to execute the method in the above-mentioned embodiment 1.

[0087] Figure 3 A schematic diagram showing the module composition of an interface simulation device for automatically providing interface services provided by a second embodiment of the present invention is shown.

[0088] like Figure 3 As shown, the interface simulation device for automatically providing interface services in this embodiment includes two modules and a data storage device:

[0089] The interface data prefabrication module M1 is used to prepare an interface description file and an interface data return file for each interface. The interface data return file is prepared according to the interface description file. The interface description file is used to describe the interface data and is prepared according to the interface description file specification; the interface data return file is the interface data returned after the interface is requested for service and is prepared according to the interface data return file specification; the prepared interface description file and interface data return file are saved in the interface data storage device.

[0090] The interface data storage DB is used to store interface description files and interface data return files.

[0091] The interface request processing module M2 is used to receive the interface service request sent by the interface data request end, read the interface description file and the interface data return file from the interface data storage device, parse the interface description file and the interface data return file, search and generate the response data of the requested interface, and return it to the interface data request end.

[0092] After completing the interface data collection, module M1 saves the data to DB for later use. Module M2 can accept user interface requests at any time. Module M2 specifically implements the request and response of the simulated interface.

[0093] Moreover, the data in the DB is not static and can be continuously added through M1 at any time according to the business needs of the interface request.

[0094] Preferably, the interface description file may include: interface identifier, interface operation type, interface processing function name, return data file name, and interface parameters and return data type. The interface identifier is unique, and the interface data return file includes: the error status code returned by the interface and the content of the returned data.

[0095] Preferably, the interface description file may also include: interface identifier, interface name, interface address, interface operation type, interface description, interface processing function name, as well as interface parameters, the number of interface parameters and the type of returned data. The interface identifier is unique, and the interface data return file includes: interface identifier, error status code returned by the interface and the content of the returned data.

[0096] Figure 4 The schematic diagram of the composition of an interface request processing module M2 in the interface simulation device for automatically providing interface services provided by the second embodiment of the present invention is shown. The interface request processing module further includes: a polling unit M21, a communication unit M22, a matching unit M23 and a processing unit M24, wherein:

[0097] The polling unit M21 is used to periodically read the interface description file from the interface data storage, parse the interface description file, and generate a MAP mapping table, which includes a mapping relationship between the interface identifier and the interface processing function name, and a set of mapping relationships between the interface identifier and the interface data return file name.

[0098] In order to quickly respond to interface requests, the interface processing function name and the interface data return file name can be quickly found according to the interface identifier. A quick search tool MAP mapping table is designed to improve the interface response efficiency. Generally, the MAP mapping table is generated when the system starts. In order to facilitate users to add new interfaces at any time and deal with the newly added interface description files and interface data return files in the interface data storage, consider setting up a timed polling mechanism to regularly generate the latest MAP mapping table, including the latest interface data mapping relationship. In this way, users can be provided with the ability to simulate new interface services without restarting the system or adding additional program coding.

[0099] The communication unit M22 is used to receive the interface identifier sent by the interface data request end and transfer it to the matching unit; and return the response data of the requested interface to the interface data request end.

[0100] The communication unit will establish a connection channel between the development software system that is ready for interface joint debugging and the device of the present invention, receive the interface data request, and return the result of the request to the development software system.

[0101] The matching unit M23 is used to traverse the MAP mapping table according to the interface identifier. If the match is successful, the interface processing function name and the interface data return file name of the interface identifier are directly obtained and sent to the processor module. Otherwise, the error status code and empty data are returned to the communication unit.

[0102] Processing unit M24 calls the interface processing function according to the received interface processing function name and interface data return file name. The interface processing function finds the corresponding data return file from the interface data storage device, parses the data return file, obtains the interface return data, and returns it to the communication unit.

[0103] like Figure 5 , shows the composition structure of an interface data prefabrication module M1 in the interface simulation device for automatically providing interface services provided by the second embodiment of the present invention and its interactive relationship with the external device interface IF; the interface data prefabrication module M1 includes: an interface description file preparation module M11, an interface description file parsing module M12, an interface request module M13, and an interface data return file preparation module M14, wherein,

[0104] The interface description file making module M11 is used to extract the interface description information from the actual implementation code of the external device interface, automatically generate the interface description file, and save it to the interface data storage; or, according to the data format requirements of the interface description file specification, write the interface description file and save it to the interface data storage;

[0105] The interface description file parsing module M12 is used to read the interface description file from the interface data storage, parse the interface identifier, interface operation type, and interface parameters therefrom to construct interface request data, and send the data to the interface request module;

[0106] The interface request module M13 is used to establish a communication connection with the actual external device interface. After the connection is successful, it sends an interface request to the actual external device interface, obtains interface return data from the external device interface, and sends it to the interface data return file making module;

[0107] The interface data return file creation module M14 generates a data return file based on the data returned from the interface request module and saves it to the interface data storage device; or, writes an interface data return file based on the data format requirements of the interface data return file specification and saves it to the interface data storage device.

[0108] A step of prefabricating interface data in the above embodiment device is:

[0109] (1) The description file making module M11 extracts the interface description information from the actual implementation code of the external device interface, automatically generates the interface description file, and saves it to the interface data storage DB;

[0110] (2) The interface description file parsing module M12 is used to read the interface description file from the interface data storage, parse the interface identifier, interface operation type, and interface parameters to construct interface request data, and send it to the interface request module M13;

[0111] (3) The interface request module M13 establishes a communication connection with the actual external device interface IF. After the connection is successful, it sends an interface request to the actual external device interface IF, obtains interface return data from the external device interface IF, and sends it to the interface data return file creation module M14;

[0112] (4) Generate a data return file based on the data returned from the interface request module M14 and save it to the interface data storage DB.

[0113] Preferably, the interface description file specification complies with the YAML file format, and the interface data return file specification complies with the JSON file format.

[0114] In the embodiments provided by the present invention, it should be understood that the disclosed methods and devices can be implemented in other ways. The system embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.

[0115] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0116] In addition, each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0117] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0118] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0119] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or perform equivalent replacements on some of the technical features thereof; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. They should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. An interface simulation method for automatically providing interface services, characterized in that: The method comprises an interface data preparation phase and an interface simulation phase, and the method comprises the steps of: S1) prefabricate interface data, prepare interface description files and interface data return files for each interface, the interface data return files are prepared according to the interface description files, the interface description files are used to describe interface data, and are prepared according to the interface description file specifications; the interface data return files are interface data returned after the interface is requested for service, and are prepared according to the interface data return file specifications; the prepared interface description files and interface data return files are saved in the interface data storage device; The interface description file includes: interface identifier, interface operation type, interface processing function name, return data file name, and interface parameters and return data type. The interface identifier is unique. The interface data return file includes: error status code returned by the interface and content of return data. S2) interface request processing, receiving an interface service request from an interface data request end, reading an interface description file and an interface data return file from an interface data storage device, parsing the interface description file and the interface data return file, searching and generating response data for the requested interface, and returning the response data to the interface data request end; The interface request processing comprises the following steps: S21) regularly generating a MAP mapping table, regularly reading an interface description file from an interface data storage device, parsing the interface description file, and generating a MAP mapping table, wherein the MAP mapping table includes a mapping relationship between an interface identifier and an interface processing function name, and a set of mapping relationships between an interface identifier and an interface data return file name; S22) receiving an interface service request and receiving an interface identifier sent by an interface data requesting end; S23) matching the interface, traversing the MAP mapping table according to the interface identifier, if the match is successful, directly obtaining the interface processing function name and the interface data return file name of the interface identifier, otherwise, returning an error status code and empty data to the interface data request end; S24) searching and processing the matched interface, calling the interface processing function according to the interface processing function name and the interface data return file name, finding the corresponding interface data return file from the interface data storage, parsing the interface data return file, and obtaining the interface return data; S25) returns the interface return data, and returns the interface return data to the interface data requesting end, The process of preparing the interface data return file in the prefabricated interface data step of the data preparation stage according to the interface data return file specification includes two methods: online or offline: In an online mode, the interface data is directly obtained by connecting to the actual external device interface. After the connection is successful, the request data is constructed according to the interface identifier, interface operation type, and interface parameters of the corresponding interface description file, and an interface request is issued to obtain the interface return data from the external device interface and perform a legality check. If it is legal, the interface data return file is automatically generated according to the interface data return file specification and saved to the interface data storage device; In the non-online mode, the interface data return file is written according to the data format requirements of the interface data return file specification and saved in the interface data storage device.

2. The method according to claim 1, characterized in that The interface description file specification follows the YAML file format, and the interface data return file specification follows the JSON file format.

3. The method according to claim 1, characterized in that The process of making the interface description file described in the prefabricated interface data step of the data preparation stage according to the interface description file specification includes two methods: automatic and manual. In the automatic method, the interface description information is extracted from the actual implementation code of the external device interface, and the interface description file is automatically generated and saved to the interface data storage device. In the manual method, the interface description file is written according to the data format requirements of the interface description file specification and saved to the interface data storage device.

4. An interface simulation device for automatically providing interface services, characterized in that: The device comprises: The interface data prefabrication module is used to prepare an interface description file and an interface data return file for each interface. The interface data return file is prepared according to the interface description file. The interface description file is used to describe the interface data and is prepared according to the interface description file specification. The interface data return file is the interface data returned after the interface is requested for service and is prepared according to the interface data return file specification. The prepared interface description file and interface data return file are saved in the interface data storage device. The interface description file includes: an interface identifier, an interface operation type, an interface processing function name, a return data file name, and interface parameters and the type of return data. The interface identifier is unique. The interface data return file includes: an error status code returned by the interface and the content of the return data. Interface data storage device, used for storing interface description files and interface data return files; The interface request processing module is used to receive the interface service request sent by the interface data request end, read the interface description file and the interface data return file from the interface data storage device, parse the interface description file and the interface data return file, search for the response data of the requested interface, and return it to the interface data request end; The interface request processing module includes: a polling unit, a communication unit, a matching unit and a processing unit, wherein: A polling unit, used for periodically reading an interface description file from an interface data storage device, parsing the interface description file, and generating a MAP mapping table, wherein the MAP mapping table includes a mapping relationship between an interface identifier and an interface processing function name, and a set of mapping relationships between an interface identifier and an interface data return file name; The communication unit is used to receive the interface identifier sent by the interface data request end and transfer it to the matching unit; and return the response data of the requested interface to the interface data request end; A matching unit, used to traverse the MAP mapping table according to the interface identifier, and if the match is successful, directly obtain the interface processing function name and the interface data return file name of the interface identifier and send them to the processor module; otherwise, return the error status code and empty data to the communication unit; The processing unit calls the interface processing function according to the received interface processing function name and interface data return file name, wherein the interface processing function finds the corresponding data return file from the interface data storage device, parses the data return file, obtains the interface return data, and returns it to the communication unit. The interface data prefabrication module includes an interface description file preparation module, an interface description file parsing module, an interface request module, and an interface data return file preparation module. The interface description file making module is used to extract the interface description information from the actual implementation code of the external device interface, automatically generate the interface description file, and save it to the interface data storage; or, according to the data format requirements of the interface description file specification, write the interface description file and save it to the interface data storage; The interface description file parsing module is used to read the interface description file from the interface data storage device, parse the interface identifier, interface operation type, and interface parameters therefrom to construct interface request data, and send the data to the interface request module; The interface request module is used to establish a communication connection with the actual external device interface. After the connection is successful, an interface request is sent to the actual external device interface, interface return data is obtained from the external device interface, and sent to the interface data return file production module; The interface data return file production module generates a data return file based on the data returned from the interface request module and saves it to the interface data storage device; or, according to the data format requirements of the interface data return file specification, writes the interface data return file and saves it to the interface data storage device.

Citation Information

Patent Citations

  • Method and device for testing based on RMI protocol

    CN103685354A

  • Client software testing method and apparatus

    CN106802859A