API calling method, system and equipment based on meta-model and medium

Through the meta-model-based API calling method, configuration and zero-code development of cross-system integration are achieved, solving the problems of high cost and responding to differentiated needs in the existing technology, reducing integration costs and improving efficiency.

CN118733104AActive Publication Date: 2024-10-01GUANGZHOU SIE CONSULTING CO LTD

Patent Information

Application Number
CN202410724662.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-10-01
Estimated Expiration
2044-06-05

AI Technical Summary

Technical Problem

Existing technologies cannot quickly respond to the differentiated needs of different manufacturers in cross-system integration, resulting in high costs and the inability to achieve zero-code adaptation.

Method used

Adopt a meta-model-based API calling method to obtain external requests through a unified API interface, perform internal protocol conversion and logical parameter mapping, execute specified services, and perform return protocol conversion based on preconfigured parameter output templates to achieve configuration and zero-code development .

Benefits of technology

It realizes differentiated demand response to different system interfaces, reduces integration costs, improves efficiency, and meets the differentiated needs of different request addresses, request formats, return formats, and exception handling formats for the same interface.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733104A_ABST
    Figure CN118733104A_ABST
Patent Text Reader

Abstract

The invention provides an API calling method, system and device based on a meta-model and a medium, and the method comprises the steps: obtaining an external request based on an API interface of the meta-model, and carrying out the internal protocol conversion of the external request, and obtaining an internal logic parameter; mapping a specified model based on the internal logic parameter and executing a corresponding service to obtain a return parameter; and performing return protocol conversion on the return parameter based on a pre-configured parameter output template to obtain a return value in a specified format, and returning the return value through the API interface. According to the method, different requirements of different systems on different request addresses, request formats, return formats and exception handling formats of the same interface can be met, and cost reduction and efficiency improvement of interface open scene development are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of metamodel technology, and in particular to a metamodel-based API calling method, system, device and medium. Background Art

[0002] With the rapid development of global informatization, the focus of system users has shifted from vertical system function construction to horizontal integration between systems, that is, cross-system integration. At present, the cost of providing external services to adapt to changing needs is very high. Currently, new services and new return formats can be provided through code through hard coding when integration is required, but the efficiency of this method is very low. Different codes need to be written to achieve different needs, and it is impossible to quickly respond to the differentiated needs of different manufacturers. Summary of the invention

[0003] The embodiment of the present invention provides a meta-model-based API calling method, system, device and medium to solve the problems existing in the related technologies. The technical solution is as follows:

[0004] In a first aspect, an embodiment of the present invention provides an API calling method based on a metamodel, comprising:

[0005] Obtain external requests based on the API interface of the metamodel, perform internal protocol conversion on the external requests, and obtain internal logical parameters;

[0006] Based on the internal logic parameter mapping, the specified model is executed and the corresponding service is executed to obtain the return parameters;

[0007] The return parameter is converted to the return protocol based on the preconfigured output parameter template to obtain the return value in the specified format, and the return value is returned through the API interface.

[0008] In one implementation, obtaining an external request based on the API interface of the metamodel includes:

[0009] Intercept external requests obtained from the request address of the API interface according to the preset routing strategy;

[0010] Distribute the intercepted external requests to the request protocol conversion layer for internal protocol conversion.

[0011] In one embodiment, it further includes:

[0012] Get the custom configuration parameters of the function configuration interface;

[0013] According to the custom configuration parameters, the protocol conversion layer is used to configure the mapping between API routing and metamodel services and the input parameter template.

[0014] In one implementation, the custom configuration parameters include a request address, an application name, a model name, a service name, and a template code.

[0015] In one implementation, performing internal protocol conversion on an external request includes:

[0016] Convert external requests into internal logical parameters based on the input parameter template. The internal logical parameters include applications, models, and services.

[0017] In one implementation, the input template configuration includes:

[0018] Obtaining a template code of a specified format entered through a function configuration interface, and identifying an occupancy symbol in the template code;

[0019] Eliminate the template code outside the occupied symbol to obtain the target code;

[0020] Generate an input parameter template based on the target code.

[0021] In one embodiment, it further includes:

[0022] Define the protocol template for successful return and the protocol template for error return through the function configuration interface, and generate the corresponding normal parameter output template and abnormal parameter output template.

[0023] In a second aspect, an embodiment of the present invention provides a metamodel-based API calling system that executes the metamodel-based API calling method as described above.

[0024] In a third aspect, an embodiment of the present invention provides an electronic device, the device comprising: a memory and a processor. The memory and the processor communicate with each other through an internal connection path, the memory is used to store instructions, the processor is used to execute the instructions stored in the memory, and when the processor executes the instructions stored in the memory, the processor executes the method in any one of the above-mentioned embodiments.

[0025] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a computer, the method in any one of the above-mentioned embodiments is executed.

[0026] The advantages or beneficial effects of the above technical solution include at least:

[0027] The present invention obtains external requests based on the unified API interface of the metamodel driven architecture, converts the external requests into internal logical parameters through the dynamic configuration function, and then calls and executes the required metamodel services, realizing configurable and zero-code adaptation of external interface call requirements, and returns according to the parameter template format when the response is returned, meeting the differentiated requirements of different systems for different request addresses, request formats, return formats, and exception handling formats of the same interface, thereby achieving cost reduction and efficiency improvement in the development of interface open scenarios.

[0028] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present invention will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present invention and should not be regarded as limiting the scope of the present invention.

[0030] Figure 1 This is a flow chart of the API calling method of the present invention;

[0031] Figure 2 Configure page graph for the function of the present invention;

[0032] Figure 3 The present invention implements a parameter configuration diagram for LIMS to push test results to DIM through a function configuration page;

[0033] Figure 4 A schematic diagram of configuring a parameter template through a function configuration page in the present invention;

[0034] Figure 5 The structure block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0035] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present invention. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.

[0036] Embodiment 1

[0037] With the rapid development of global information technology, system users have shifted their focus from vertical system function construction to horizontal integration between systems, that is, cross-system integration. At present, the cost of providing services to adapt to changing needs is very high. For example, N other systems have different requirements for the service of obtaining employee information provided by HR. There are currently two mainstream solutions in terms of implementation: the first is hard coding, which provides new services and new return formats through code when integration is required, and the other is to develop an integration platform (such as an enterprise service bus), register all system services to the integration platform, and forward services by the integration platform. However, the above two methods are more reflected in routing forwarding and service orchestration, and do not provide the ability to configure the differentiated request formats, return formats, and exception handling formats required by different manufacturers. Therefore, the cost of integration is very high, and it is not possible to respond quickly to customer integration needs.

[0038] In order to solve the above problems, this embodiment provides an API calling method based on a metamodel to realize configurable and zero-code development, meet the differentiated requirements of different systems for different request addresses, request formats, return formats, and exception handling formats for the same interface, and achieve cost reduction and efficiency improvement in interface open scenario development.

[0039] The API calling method of this embodiment is implemented based on the metamodel architecture, wherein the metamodel defines the methods and languages ​​of a specific type of model and describes the elements that constitute the model and the relationships between the elements; Figure 1 As shown, the API calling method specifically includes the following steps:

[0040] Step S1: Obtain an external request based on the API interface of the metamodel, perform internal protocol conversion on the external request, and obtain internal logical parameters;

[0041] Step S2: Call the specified model based on the internal logic parameters and execute the corresponding service to obtain the return parameters;

[0042] Step S3: Perform return protocol conversion on the return parameter based on the preconfigured output parameter template to obtain a return value in a specified format, and return the return value through the API interface.

[0043] The metamodel architecture will provide a unified API interface to the outside world. The entry point for all models is this unified API interface. After receiving different requests, the API interface will execute different logics and perform different metamodel services based on different request parameters.

[0044] In the traditional architecture, the original routing information is mapped one-to-one with the internal logic, and the external request is directly executed and returned according to the internal logic. In order to achieve protocol conversion, this embodiment dynamically maintains the routing information through the function configuration interface to determine the request address of the API interface, and generates the corresponding routing policy, and injects the routing policy into the filter chain. The filter chain can intercept the external request obtained from the request address of the API interface according to the routing policy, and distribute the intercepted external request to the request protocol conversion layer for internal protocol conversion. The specific routing policy can be set according to the actual situation. The request address can be a URL address.

[0045] The protocol conversion layer of this embodiment can realize request protocol conversion and return protocol conversion. In the traditional architecture, the parameters carried by the external request are directly matched with the parameters of the internal logic. When the type does not match or the number does not match, the service is unavailable. This embodiment adds a protocol conversion layer, the external parameters can be defined arbitrarily, and the platform establishes a mapping relationship with the internal service parameters, decoupling the external request from the internal implementation, and shielding the internal implementation logic from the outside.

[0046] Before performing protocol conversion, this embodiment needs to configure the mapping relationship between API routing and metamodel service and configure the API input parameter template in the function configuration interface. The mapping between API routing and metamodel service is set in the function configuration interface. The system generates the function configuration interface according to the preset IU interface code, such as Figure 2 As shown, the function configuration interface displays filling items such as "app name", "app version", "model name", "service name", and "internal protocol conversion template". Users can fill in the corresponding custom configuration parameters in the function configuration interface according to actual needs. The custom configuration parameters include request address, application name, model name, service name, and template code. The system can determine the input parameter template, protocol conversion rules, etc. according to the custom configuration parameters entered in the function configuration interface, so as to perform protocol conversion on the external request proposed by the front end and transmit it to the back end, and execute the corresponding model and the corresponding service according to the mapping relationship between the external request and the platform's internal APP, model, and service to obtain the return parameters.

[0047] Assume that the route / mes / getMeteral is added, and the mapping with the metamodel unified service is as follows:

[0048] Serial number parameter type Configuration Values Required describe 1 app String Mes √ App Name 2 tag String v1.1 √ App Version 3 model String Meteral √ Model Name 4 service String getMeteral √ Service Name 5 version String V2 X Service Version

[0049] The input parameter template can directly generate default values ​​for non-mandatory parameters in the protocol conversion process, which can improve the efficiency of internal protocol conversion. The custom configuration of the input parameter template can define the template according to the parameter format of the unified API, that is, obtain the template code of the specified format entered through the function configuration interface. The code format of the internal protocol conversion template in this embodiment can be json format, identify the occupancy symbol in the template code of the specified format, remove the code outside the occupancy symbol, obtain the target code, and generate the input parameter template according to the target code. The target code is as follows:

[0050]

[0051]

[0052] After the user makes a series of configurations in the function configuration interface, the internal request protocol is encapsulated according to the custom configuration parameters, the specified parameters of the external request are converted into default values ​​based on the input parameter template, and the external request is quickly converted into the internal protocol and transmitted to the backend; the backend determines the mapping relationship between the external request and the internal logical parameters based on the custom configuration parameters obtained through the function configuration interface, so as to call the corresponding applications, models and services according to the internal logical parameters to perform corresponding operations.

[0053] like Figure 3 As shown, assuming that the external request obtained through the request address is LIMS pushing the test results to DIM, the user enters the app name as "dim-qms", the model name as "LIMSToDIM", and the service name as "limsReturnResult" in the function configuration interface. At this time, the system will determine the mapping relationship between the external request and the application, model, and service according to the above configuration content, thereby executing the "limsReturnResult" service and obtaining the return parameters of the test results pushed by LIMS to DIM.

[0054] In this embodiment, while customizing the configuration request protocol conversion, the return protocol conversion can also be configured, such as Figure 4 As shown, the protocol template for successful return and the protocol template for error return are defined through the function configuration interface, and the corresponding normal parameter output template and abnormal parameter output template are generated.

[0055] The return format based on the metamodel architecture is fixed. The normal format includes List <map>Or Map, the exception format is Map and the main information is put into the object with key error.

[0056] (1) Under normal circumstances, configure the API output parameters to unify the API output parameter mapping and configure the normal API output parameter template; mainly configure the mapping of the key value in the Map. If the key is consistent, no configuration is required. The key normally returned by the platform API is mainly data. The data may be a (k, v) pair or a List of (k, v) pairs. The template uniformly uses {} placeholders:

[0057]

[0058]

[0059] (2) Configure the abnormal situation API to participate in the unified API abnormal output parameter mapping and configure the API abnormal output parameter template; mainly configure the mapping of the key value in the Map. If the key is consistent, no configuration is required. Build the abnormal return format template such as:

[0060]

[0061] This embodiment will combine the metamodel driven architecture, take advantage of the architecture's unified API, unified input parameters and return format, dynamically add APIs through the routing management function, dynamically establish request message templates, and mappings with the unified entry of the metamodel architecture, dynamically establish return message templates, exception message templates, and mappings with the unified return format of the metamodel architecture, decouple the actual API from the provided API format, and replace the traditional process of writing code, compiling, packaging, and publishing when adding an API. This will achieve configurable, zero-code development, meet the differentiated requirements of different systems for different request addresses, request formats, return formats, and exception handling formats for the same interface, and achieve cost reduction and efficiency improvement in interface open scenario development.

[0062] Embodiment 2

[0063] This embodiment provides a metamodel-based API calling system, which executes the metamodel-based API calling method of the first embodiment. The system includes:

[0064] Configuration UI interface module, used to provide and display the function configuration interface, in which custom configuration parameters can be entered, and the internal protocol conversion mode is determined according to the custom configuration parameters;

[0065] The internal protocol conversion module is used to obtain external requests through the API interface of the metamodel, perform internal protocol conversion on the external requests, obtain internal logical parameters, call the specified model based on the internal logical parameters and execute the corresponding service to obtain the return parameters;

[0066] The return protocol conversion module is used to perform return protocol conversion on the return parameters according to the preconfigured output parameter template, obtain the return value in the specified format, and return the return value through the API interface.

[0067] The purpose of this embodiment is to achieve configurable, zero-code adaptation of external interface call requirements based on a unified API of a metamodel-driven architecture through dynamic configuration functions, to achieve automatic routing to a unified API when requesting an API, and to achieve dynamic return according to the parameter template format when returning a response, thereby reducing costs and increasing efficiency in providing interfaces to the outside world.

[0068] The functions of each module in the system of the embodiment of the present invention can be found in the corresponding description of the above method, which will not be repeated here.

[0069] Embodiment 3

[0070] Figure 5 FIG. 2 shows a structural block diagram of an electronic device according to an embodiment of the present invention. Figure 5 As shown, the electronic device includes: a memory 100 and a processor 200, wherein the memory 100 stores a computer program that can be run on the processor 200. When the processor 200 executes the computer program, the metamodel-based API calling method in the above embodiment is implemented. The number of the memory 100 and the processor 200 can be one or more.

[0071] The electronic device also includes:

[0072] The communication interface 300 is used to communicate with external devices and perform data exchange transmission.

[0073] If the memory 100, the processor 200 and the communication interface 300 are implemented independently, the memory 100, the processor 200 and the communication interface 300 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0074] Optionally, in a specific implementation, if the memory 100, the processor 200 and the communication interface 300 are integrated on a chip, the memory 100, the processor 200 and the communication interface 300 can communicate with each other through an internal interface.

[0075] An embodiment of the present invention provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present invention when executed by a processor.

[0076] An embodiment of the present invention further provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present invention.

[0077] An embodiment of the present invention also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided by the embodiment of the invention.

[0078] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the advanced RISC machines (ARM) architecture.

[0079] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).

[0080] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.

[0081] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.

[0082] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0083] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.< / map>

Claims

1. A meta-model-based API calling method, It is characterized in that include: Obtain external requests based on the API interface of the metamodel, perform internal protocol conversion on the external requests, and obtain internal logical parameters; Mapping a specified model based on the internal logic parameters and executing a corresponding service to obtain a return parameter; The return parameter is converted into a return protocol based on a preconfigured output parameter template to obtain a return value in a specified format, and the return value is returned through the API interface.

2. The API calling method based on the metamodel according to claim 1, It is characterized in that The API interface based on the metamodel obtains the external request, including: Intercepting the external request obtained from the request address of the API interface according to a preset routing strategy; The intercepted external request is distributed to the request protocol conversion layer for internal protocol conversion.

3. The API calling method based on the metamodel according to claim 2, It is characterized in that Also includes: Get the custom configuration parameters of the function configuration interface; According to the custom configuration parameters, the protocol conversion layer performs mapping configuration between API routing and metamodel service and input parameter template configuration.

4. The API calling method based on the metamodel according to claim 3, It is characterized in that The custom configuration parameters include the request address, application name, model name, service name and template code.

5. The API calling method based on metamodel according to claim 3, It is characterized in that The performing internal protocol conversion on the external request includes: The external request is converted into the internal logic parameters based on the input parameter template, and the internal logic parameters include application, model and service.

6. The API calling method based on metamodel according to claim 3, It is characterized in that The input template configuration includes: Acquire a template code of a specified format entered through the function configuration interface, and identify an occupancy symbol in the template code; Eliminate the template code outside the occupant to obtain the target code; Generate the input parameter template according to the target code.

7. The metamodel-based API calling method according to claim 1, It is characterized in that Also includes: Define the protocol template for successful return and the protocol template for error return through the function configuration interface, and generate the corresponding normal parameter output template and abnormal parameter output template.

8. An API calling system based on metamodel, It is characterized in that Execute the metamodel-based API calling method as described in any one of claims 1 to 7.

9. An electronic device, It is characterized in that include: A processor and a memory, wherein the memory stores instructions, and the instructions are loaded and executed by the processor to implement the metamodel-based API calling method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the metamodel-based API calling method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Remote procedure calling method, device and equipment and readable storage medium

    CN115408169A

  • Model-based interface design method and system, medium and equipment

    CN115794717A

  • Micro-service calling method, platform and device, terminal equipment and readable storage medium

    CN117472477A

  • URL (Uniform Resource Locator) interface generation method and device, equipment and storage medium

    CN117932172A

  • Unified metamodel for web services description

    US20080155557A1

Cited By

  • E-commerce online operation data analysis method and device and computer equipment

    CN119784413A