Interface simulation service calling method and device

Through the method of finding and obtaining the interface return value through the interface path and request parameters, the problem of complex and high cost of interface simulation service maintenance in the existing technology is solved, and fast and convenient interface service call and maintenance is achieved.

CN114398152BActive Publication Date: 2025-03-18工银科技有限公司 +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210065368.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-20
Publication Date
2025-03-18
Estimated Expiration
2042-01-20

AI Technical Summary

Technical Problem

When implementing interface simulation services in the prior art, manual input and return fields are complicated, and the return value of the mock service is random and cannot fully simulate the actual situation, resulting in high costs and complex maintenance.

Method used

By receiving the interface path and request parameters uploaded by the user, searching for the interface file and searching for the corresponding interface information based on the version information, thereby obtaining the interface return value.

Benefits of technology

It realizes the real call to external services while greatly reducing labor costs, simplifies the interface maintenance and definition process, and supports rapid response to interface changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398152B_ABST
    Figure CN114398152B_ABST
Patent Text Reader

Abstract

The present invention provides an interface simulation service calling method and device, which belongs to the field of simulation service technology and can be applied to the financial field or other fields. The interface simulation service calling method includes: receiving an interface path and an interface request parameter uploaded by a user, searching an interface file according to the interface path; searching for corresponding interface information from the interface file according to the version information of the interface request parameter; and obtaining an interface return value from the interface information according to the interface request parameter. The present invention can significantly reduce the labor cost while meeting the actual call of external services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial technology, and in particular to an interface simulation service calling method and device. Background Art

[0002] Traditional simulation services are generally implemented in the following ways:

[0003] The first solution uses mock services to simulate the services to be called through mock service tools such as mockServer, EasyMock, and Mockito, and returns data in a fixed interface format when the service is called. This method relies on manual input of interface input and return fields, which is cumbersome; and the return value of the mock service is a random value, which cannot fully simulate the actual situation.

[0004] The second solution is customized development, where developers customize and maintain the corresponding interface according to the required interface service, so that they can configure the preset interface to obtain the corresponding return data when calling. The second solution can also solve some problems, but it will increase costs. Developers will need to spend a lot of time to maintain each external interface, which is also difficult to implement when development time is relatively tight.

[0005] The third solution is to maintain according to the XML template or YML template, first enter the interface through the web end and then access it through the service. However, front-end entry and XML / YML template maintenance are more complicated and costly, and do not support repeated interfaces. Summary of the invention

[0006] The main purpose of the embodiments of the present invention is to provide an interface simulation service calling method and device, so as to significantly reduce the manpower cost while meeting the actual calling of external services.

[0007] In order to achieve the above object, an embodiment of the present invention provides an interface simulation service calling method, comprising:

[0008] Receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path;

[0009] Find the corresponding interface information from the interface file according to the version information of the interface request parameter;

[0010] Get the interface return value from the interface information according to the interface request parameters.

[0011] The embodiment of the present invention further provides an interface simulation service calling device, comprising:

[0012] The file search module is used to receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path;

[0013] An interface information search module is used to search for corresponding interface information from an interface file according to the version information of the interface request parameter;

[0014] The interface return value module is used to obtain the interface return value from the interface information according to the interface request parameters.

[0015] The embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of the interface simulation service calling method are implemented.

[0016] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the interface simulation service calling method are implemented.

[0017] The interface simulation service calling method and device of the embodiment of the present invention first searches for the interface file according to the interface path, and then searches for the corresponding interface information from the interface file according to the version information of the interface request parameter to obtain the interface return value, which can greatly reduce the labor cost while meeting the actual call to the external service. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 is a schematic diagram of the interaction between the simulation server and the service caller in an embodiment of the present invention;

[0020] Figure 2 is a flow chart of an interface simulation service calling method in an embodiment of the present invention;

[0021] Figure 3 is a timing diagram of the interface calling process in an embodiment of the present invention;

[0022] Figure 4 is a flow chart of S103 in an embodiment of the present invention;

[0023] Figure 5 is a flow chart of S201 in an embodiment of the present invention;

[0024] Figure 6 is a timing diagram of the interface creation process in an embodiment of the present invention;

[0025] Figure 7It is a call flow chart of the interface service in the prior art;

[0026] Figure 8 is a call flow chart of the interface simulation service in an embodiment of the present invention;

[0027] Fig. 9 is a schematic diagram of an interface simulation service calling device in an embodiment of the present invention;

[0028] Fig.10 It is a structural block diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0031] It should be noted that the interface simulation service calling method and device of the present invention can be used in simulation service scenarios in the financial field, and can also be used in any field other than the financial field. The embodiment of the present invention does not limit the application field of the interface simulation service calling method and device.

[0032] The key terms mentioned in this invention are defined as follows:

[0033] Interface simulation service: simulates the real interface to provide services.

[0034] FreeMarker: A general-purpose tool for generating output text based on templates and data to be changed.

[0035] URI: Universal Resource Identifier, is a string used to identify the name of an Internet resource.

[0036] SpringBoot: A Java open source development framework that simplifies the construction and development process of Spring applications.

[0037] Server: A centralized control service used to publish front-end websites and back-end data, providing users with visual website resource files and user data storage functions.

[0038] In view of the fact that the prior art cannot fully simulate the actual situation, the maintenance is complicated and the cost is high, the embodiment of the present invention provides an interface simulation service calling method, which can well solve the problem of external service call dependency by combining FreeMarker, MybatisPlus, Vue, SpringBoot and data storage technologies: using the intelligent recognition function, the characteristics of SpringBoot and the function of FreeMarker, the external dependency interface can be quickly defined and the definition return information can be conveniently defined, and it is no longer dependent on the resource limitations of mock services and manually written interfaces. Developers no longer have to worry about frequent modifications or redefinitions caused by interface changes. By intelligently identifying and modifying the interface, the changes of external dependency services can be quickly completed. Therefore, the present invention can not only quickly and intelligently maintain the required interface services, but also flexibly change them, and realize interface simulation service calls without changing the interface address, which can meet the actual call of external services while greatly reducing labor costs.

[0039] Figure 1 Schematic diagram of the interaction between the simulation server and the service caller in the embodiment of the present invention. Figure 1 As shown, the user imports the interface file of the external interface that the user relies on according to the FreeMarker requirements through the simulation server front end. The simulation server back end intelligently identifies and parses the interface file and solidifies the interface and return information template into the database. When the user needs to call the interface, the expected return value can be obtained by accessing the external service provided by the back-end server through the path of the called interface. The simulation service integrates the service as an intermediate layer, so the external interface service can be registered on the simulation service. When it needs to be called, the simulation service can be directly called. In the end, the external interface return data can be truly simulated instead of using mocks, while reducing the investment of R&D personnel, and completing the definition and maintenance of external dependent interfaces conveniently and quickly.

[0040] Figure 2 It is a flow chart of the interface simulation service calling method in an embodiment of the present invention. Figure 3 is a timing diagram of the interface calling process in an embodiment of the present invention. Figure 2-Figure 3 As shown, the interface simulation service calling method includes:

[0041] S101: receiving an interface path and interface request parameters uploaded by a user, and searching for an interface file according to the interface path.

[0042] Figure 6 FIG. 1 is a timing diagram of the interface creation process in an embodiment of the present invention. Figure 6 As shown, before executing S101, the process further includes:

[0043] Obtain the interface document uploaded by the user, which includes the interface path and interface request parameters; generate an interface simulation service according to the interface document.

[0044] During the specific implementation, the user opens the simulation service website front end to import the interface document. The interface document should conform to the standard format: including interface request parameters, interface path URI, request sample message and return sample message (the return message needs to be in freemarker format, i.e. anchor point). The simulation server front end (Vue front end) verifies the interface document to determine whether the document is in word format, and then passes the interface document processing to the simulation server back end (SpringBoot back end). The simulation server back end performs logical verification and processing on the received interface document, stores the data in the Mysql storage server, and generates an external interface simulation service based on the freemarker template and interface document, and returns the Mysql storage server processing results to the simulation server front end.

[0045] The data processing of the simulation server backend specifically includes:

[0046] 1. Format verification: Verify whether the interface elements are complete, whether the request sample message and the return sample message conform to the JSON standard, etc.

[0047] 2. Business logic processing: identifying interface parameters and adding, deleting, modifying and checking interfaces.

[0048] 3. Data solidification: store the identified interface parameters into the database.

[0049] 4. External interface service: Generate a simulation interface for external services through a unified calling interface.

[0050] 5. Exception handling, including: a. Format verification exception, when it does not conform to the interface format, the front-end processing information is returned; b. Business processing exception: when there are exceptions in the addition, deletion, modification and query of the interface, the front-end processing failure information is returned; c. Database processing exception: database link exception and database verification exception (sql and primary key conflict exception), etc.

[0051] When executing S101, when the user needs to call the entered interface, the IP, port, interface path (URI) and interface request parameters of the simulation server backend can be called. The simulation server backend will use the interface path (URI) as an identifier to retrieve the interface file from the Mysql storage server.

[0052] S102: Searching for corresponding interface information from an interface file according to the version information of the interface request parameter.

[0053] In specific implementation, the Mysql storage server searches for the corresponding interface information from the interface file according to the version information of the interface request parameter; if the interface information exists, it is passed to the simulation server backend, otherwise it is fed back to the simulation server backend that the interface does not exist. The simulation server backend passes the interface information to the FreeMarker template engine.

[0054] S103: Obtaining an interface return value from the interface information according to the interface request parameters.

[0055] Figure 4 is a flow chart of S103 in an embodiment of the present invention. Figure 4 As shown, S103 includes:

[0056] S201: Parse the interface request parameters to obtain key values.

[0057] Figure 5 is a flow chart of S201 in an embodiment of the present invention. Figure 5 As shown, S201 includes:

[0058] S301: Perform map conversion on the interface request parameters, and obtain the map level from the converted interface request parameters.

[0059] In specific implementation, FreeMarker converts the interface request parameters into jsonMap through map conversion and obtains the map level from jsonMap.

[0060] S302: Obtain key values ​​by parsing the converted interface request parameters according to the map level.

[0061] In the specific implementation, FreeMarker parses jsonMap according to the map level to get the key value key.

[0062] S202: Obtain a corresponding interface return value from the interface information according to the key value.

[0063] In one embodiment, S202 includes:

[0064] Locate the anchor point in the return value template of the interface information according to the key value; obtain the corresponding interface return value from the anchor point according to the key value.

[0065] In the specific implementation, FreeMarker locates the anchor point from the return value template defined in the interface information according to the key value key, obtains the corresponding value from the anchor point according to the key value key and puts it into the interface return value resparams, and returns the interface return value resparams to the caller through the simulation server backend.

[0066] Figure 2The execution subject of the interface simulation service calling method shown can be a simulation server. Figure 2 As can be seen from the process shown, the interface simulation service calling method of the embodiment of the present invention first searches for the interface file according to the interface path, and then searches for the corresponding interface information from the interface file according to the version information of the interface request parameters to obtain the interface return value, which can greatly reduce the labor cost while meeting the actual call to the external service.

[0067] Figure 7 It is a call flow chart of the interface service in the prior art; Figure 8 FIG. 1 is a flow chart of calling the interface simulation service in an embodiment of the present invention. Figure 7 As shown, when a user calls the same login interface, two sets of services will be customized, and reuse cannot be achieved; as shown in the figure, users a and b define interface login respectively. Therefore, the existing technology needs to match parameters in sequence when defining the interface, and the workload is large when there are many parameters.

[0068] like Figure 8 As shown, the present invention enables different users to achieve unified definition through simulation services when calling the same login interface:

[0069] 1. In the case of multiple projects, when different projects use the same login interface, the system will distinguish the interfaces based on the project ID and return different results.

[0070] 2. In the same project dimension, when multiple user information is not synchronized or the old and new versions of the interface are used at the same time, conflicts may arise in maintaining multiple interfaces. Figure 8 User e calls the login interface version 1.1 under the same project. The existing technical solution does not allow duplicate interface URL definitions to be generated during creation to solve the problem, but it cannot meet actual needs. This application supports multiple interface duplicate definitions, such as Figure 8 login-version1 and login-version1.1 in. When processing version1 and login-version1.1 calls, the login interface address called by the user remains unchanged, but the incoming request parameters are different. When the background receives the login request, it will match the parameters of all login interfaces under this project in the database according to the request parameters, and return the version that matches it. And when defining the interface, the parameters passed by the present invention are changed from single parsing to json parsing, realizing the direct import and identification method from the interface document, which can more conveniently maintain the request and response parameters.

[0071] The specific process of the embodiment of the present invention is as follows:

[0072] 1. Get the interface document uploaded by the user. The interface document includes the interface path and interface request parameters.

[0073] 2. Generate interface simulation service according to the interface document.

[0074] 3. Receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path.

[0075] 4. Search the corresponding interface information from the interface file according to the version information of the interface request parameter.

[0076] 5. Perform map conversion on the interface request parameters and obtain the map level from the converted interface request parameters.

[0077] 6. Obtain the key value by parsing the converted interface request parameters according to the map level.

[0078] 7. Locate the anchor point in the return value template of the interface information according to the key value, and obtain the corresponding interface return value from the anchor point according to the key value.

[0079] In summary, the interface simulation service calling method of the embodiment of the present invention is applied to various interface calling scenarios, and can reduce the ability to rely on external services in the case of development, joint debugging and testing, thereby reducing costs and ensuring time progress by reducing the investment of developers and testers. The present invention can also maintain the external dependency set and realize the reuse of interfaces through multiple projects; at the same time, it supports the calling of various languages ​​based on Java development to reduce the compatibility threshold, and has a large market promotion space.

[0080] Based on the same inventive concept, an embodiment of the present invention also provides an interface simulation service calling device. Since the principle of solving the problem by the device is similar to that of the interface simulation service calling method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0081] Fig. 9 Schematic diagram of an interface simulation service calling device in an embodiment of the present invention. Fig. 9 As shown, the interface simulation service calling device includes:

[0082] The file search module is used to receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path;

[0083] An interface information search module is used to search for corresponding interface information from an interface file according to the version information of the interface request parameter;

[0084] The interface return value module is used to obtain the interface return value from the interface information according to the interface request parameters.

[0085] In one embodiment, the interface return value module includes:

[0086] A parsing unit, used to parse interface request parameters to obtain key values;

[0087] The interface return value unit is used to obtain the corresponding interface return value from the interface information according to the key value.

[0088] In one embodiment, the parsing unit includes:

[0089] The level acquisition subunit is used to perform map conversion on the interface request parameters and obtain the map level from the converted interface request parameters;

[0090] The key-value subunit is used to obtain the key value by parsing the converted interface request parameters according to the map level.

[0091] In summary, the interface simulation service calling device of the embodiment of the present invention first searches for the interface file according to the interface path, and then searches for the corresponding interface information from the interface file according to the version information of the interface request parameter to obtain the interface return value, which can greatly reduce the labor cost while meeting the actual call to the external service.

[0092] The embodiment of the present invention also provides a specific implementation of a computer device capable of implementing all the steps in the interface simulation service calling method in the above embodiment. Fig.10 is a block diagram of a computer device in an embodiment of the present invention, see Fig.10 , the computer equipment specifically includes the following contents:

[0093] Processor (processor) 1001 and memory (memory) 1002.

[0094] The processor 1001 is used to call the computer program in the memory 1002. When the processor executes the computer program, all the steps in the interface simulation service calling method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0095] Receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path;

[0096] Find the corresponding interface information from the interface file according to the version information of the interface request parameter;

[0097] Get the interface return value from the interface information according to the interface request parameters.

[0098] In summary, the computer device of the embodiment of the present invention first searches for the interface file according to the interface path, and then searches for the corresponding interface information from the interface file according to the version information of the interface request parameter to obtain the interface return value, which can meet the actual call to external services while greatly reducing labor costs.

[0099] The embodiment of the present invention also provides a computer-readable storage medium capable of implementing all the steps in the interface simulation service calling method in the above embodiment. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps in the interface simulation service calling method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0100] Receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path;

[0101] Find the corresponding interface information from the interface file according to the version information of the interface request parameter;

[0102] Get the interface return value from the interface information according to the interface request parameters.

[0103] In summary, the computer-readable storage medium of an embodiment of the present invention first searches for the interface file according to the interface path, and then searches for the corresponding interface information from the interface file according to the version information of the interface request parameters to obtain the interface return value, which can significantly reduce labor costs while meeting the actual call to external services.

[0104] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

[0105] Those skilled in the art may also understand that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention may be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly demonstrate the interchangeability of hardware and software, the various illustrative components, units, and steps described above have generally described their functions. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functions for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present invention.

[0106] The various illustrative logic blocks, or units, or devices described in the embodiments of the present invention can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of the above. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any conventional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.

[0107] The steps of the method or algorithm described in the embodiments of the present invention can be directly embedded in hardware, a software module executed by a processor, or a combination of the two. The software module can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC, and the ASIC can be arranged in a user terminal. Optionally, the processor and the storage medium can also be arranged in different components in the user terminal.

[0108] In one or more exemplary designs, the above functions described in the embodiments of the present invention can be implemented in hardware, software, firmware or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium, or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by any general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program codes in the form of instructions or data structures and other forms that can be read by general or special computers, or general or special processors. In addition, any connection can be appropriately defined as a computer-readable medium, for example, if the software is transmitted from a website site, server or other remote resource through a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disk and disc include compact disk, laser disk, optical disk, DVD, floppy disk and blue-ray disk. Disks usually copy data magnetically, while discs usually copy data optically with lasers. The above combination can also be included in computer readable media.

Claims

1. An interface simulation service calling method, characterized in that: include: Receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path; Searching for corresponding interface information from the interface file according to the version information of the interface request parameter; Obtaining an interface return value from the interface information according to the interface request parameter; The acquiring the interface return value from the interface information according to the interface request parameter comprises: Parsing the interface request parameters to obtain key values; Obtain a corresponding interface return value from the interface information according to the key value.

2. The interface simulation service calling method according to claim 1, characterized in that: Parsing the interface request parameters to obtain key values ​​includes: Performing map conversion on the interface request parameters, and obtaining a map level from the converted interface request parameters; The converted interface request parameters are parsed according to the map level to obtain key values.

3. The interface simulation service calling method according to claim 2, characterized in that: Acquiring a corresponding interface return value from the interface information according to the key value includes: Locate an anchor point from a return value template of the interface information according to the key value; Obtain a corresponding interface return value from the anchor point according to the key value.

4. The interface simulation service calling method according to claim 1, characterized in that: Also includes: Obtaining the interface document uploaded by the user, wherein the interface document includes an interface path and interface request parameters; An interface simulation service is generated according to the interface document.

5. An interface simulation service calling device, characterized in that: include: A file search module, used to receive the interface path and interface request parameters uploaded by the user, and search for the interface file according to the interface path; An interface information search module, used to search for corresponding interface information from the interface file according to the version information of the interface request parameter; An interface return value module, used to obtain an interface return value from the interface information according to the interface request parameters; The interface return value module includes: A parsing unit, used for parsing the interface request parameters to obtain key values; The interface return value unit is used to obtain the corresponding interface return value from the interface information according to the key value.

6. The interface simulation service calling device according to claim 5, characterized in that: The parsing unit comprises: A level acquisition subunit, used to perform map conversion on the interface request parameters and obtain a map level from the converted interface request parameters; The key-value subunit is used to parse the converted interface request parameters according to the map level to obtain the key value.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the interface simulation service calling method according to any one of claims 1 to 4 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the interface simulation service calling method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Simulator system and method based on simulation data model

    CN106250308A

  • Back-end interface response method and device, electronic equipment and storage medium

    CN109871498A

  • Interface control method and device, computer readable storage medium and computer device

    CN110008039A