CN114816798A - Interface calling method and device - Google Patents

Interface calling method and device Download PDF

Info

Publication number
CN114816798A
CN114816798A CN202210449001.9A CN202210449001A CN114816798A CN 114816798 A CN114816798 A CN 114816798A CN 202210449001 A CN202210449001 A CN 202210449001A CN 114816798 A CN114816798 A CN 114816798A
Authority
CN
China
Prior art keywords
interface
calling
called
configuration information
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210449001.9A
Other languages
Chinese (zh)
Inventor
刘煜辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202210449001.9A priority Critical patent/CN114816798A/en
Publication of CN114816798A publication Critical patent/CN114816798A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server

Abstract

The invention discloses a method and a device for calling an interface, and relates to the technical field of computers. One embodiment of the method comprises: responding to an interface calling instruction, and determining an interface to be called; determining target configuration information corresponding to the interface to be called from the pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively; and calling the interface to be called according to the target calling implementation class in the target configuration information and the first input parameter carried by the calling request. According to the implementation method, the calling implementation class corresponds to the protocol type, the same implementation class can be called when a plurality of interfaces to be called of the same protocol type exist, calling of the interfaces is further achieved according to the first input parameter carried by the calling request, codes do not need to be compiled for each interface to be called, and maintenance cost and labor cost are greatly saved.

Description

Interface calling method and device
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for calling an interface.
Background
In the current Java application system, when a new interface needs to be called, a programmer needs to write corresponding codes for each new interface. When the access to a new interface in an application system is very frequent and the types of protocols corresponding to the interfaces are concentrated, a large amount of repeated writing work is generated, and the later maintenance cost is high.
Disclosure of Invention
In view of this, embodiments of the present invention provide an interface calling method and apparatus, which can determine target configuration information corresponding to an interface to be called according to an access protocol type of the interface to be called, so as to obtain a corresponding call implementation class. The calling implementation class corresponds to the protocol type, so that the same implementation class can be called when a plurality of interfaces to be called of the same protocol type exist, calling of the interfaces is further realized according to the first input parameter carried by the calling request, codes do not need to be compiled for each interface to be called, and maintenance cost and labor cost are greatly saved.
To achieve the above object, according to an aspect of an embodiment of the present invention, a method for interface invocation is provided.
The method for calling the interface comprises the following steps: responding to an interface calling instruction, and determining an interface to be called; determining target configuration information corresponding to the interface to be called from pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively; and calling the interface to be called according to a target calling implementation class in the target configuration information and the first input parameter carried by the calling request.
Optionally, the provisioning information further includes: one or more interface identifiers corresponding to each protocol type; the determining, from the pre-configuration information, target configuration information corresponding to the interface to be called includes: and determining the target configuration information from the pre-configuration information according to the identifier of the interface to be called.
Optionally, the invoking the interface to be invoked according to the target invocation implementation class in the target configuration information and the entry parameter carried by the invocation request includes: determining a parameter entry expression corresponding to the interface to be called from the configuration information; determining a second parameter according to the first parameter carried by the interface calling instruction and the parameter-entering expression; and generating a calling request according to the second input parameter and the target calling implementation class, and sending the calling request to the interface to be called so as to call the interface to be called.
Optionally, the method further comprises: receiving the output parameter corresponding to the call request returned by the interface to be called; and determining a calling result corresponding to the interface calling instruction according to the parameters and the parameter expression in the configuration information.
Optionally, the sending the call request to the interface to be called includes: the access protocol type is an http protocol type, and an http policy class call initialization instance in the target call implementation class is adopted; and sending the calling request to the interface to be called according to the initialization example.
Optionally, the sending the call request to the interface to be called includes: the access protocol type is a JSF protocol type, and the GenericService class in the target calling implementation class is adopted to call an initialization instance; and initiating a generalized calling request to the interface to be called according to the initialization example.
Optionally, the method further comprises: storing the calling result and the first input parameter correspondingly in a result set; responding to the interface calling instruction of the interface to be called received again, and determining whether the input parameters carried by the interface calling instruction include the target input parameters same as the first input parameters; if so, acquiring a calling result corresponding to the target entry parameter from the result set; otherwise, calling the interface to be called according to the input parameter carried by the interface calling instruction, and storing the input parameter carried by the interface calling instruction and the corresponding calling result into a result set.
Optionally, the method further comprises: and carrying out name transformation and/or type conversion on the parameters by using the parameter expression to obtain the calling result.
To achieve the above object, according to another aspect of the embodiments of the present invention, an apparatus for interface invocation is provided.
The device for calling the interface comprises the following components: the determining module is used for responding to the interface calling instruction and determining an interface to be called; the configuration module is used for determining target configuration information corresponding to the interface to be called from pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively; and the calling module is used for calling the interface to be called according to the target calling implementation class in the target configuration information and the first input parameter carried by the calling request.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided an electronic device for interface invocation.
An electronic device called by an interface according to an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method called by the interface.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention stores thereon a computer program that, when executed by a processor, implements a method of interface invocation of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the target configuration information corresponding to the interface to be called can be determined according to the access protocol type of the interface to be called, and then the corresponding calling implementation class is obtained. The calling implementation class corresponds to the protocol type, so that the same implementation class can be called when a plurality of interfaces to be called of the same protocol type exist, calling of the interfaces is further realized according to the first input parameter carried by the calling request, codes do not need to be compiled for each interface to be called, and maintenance cost and labor cost are greatly saved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of interface invocation according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main steps of a method for calling an interface to be called according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main steps for the case where the access protocol type is the http protocol type, according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main steps for the case where the access protocol type is a JSF protocol type, according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the main steps for determining the result of a call according to an embodiment of the invention;
FIG. 6 is a schematic diagram of the main steps of the processing of the results of a call according to an embodiment of the invention;
FIG. 7 is a diagram illustrating the main steps of a specific method for interface invocation according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of the main modules of an apparatus for interface invocation according to an embodiment of the present invention;
FIG. 9 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 10 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram of the main steps of a method of interface invocation according to an embodiment of the present invention.
As shown in fig. 1, the method for interface invocation of the embodiment of the present invention mainly includes the following steps:
step S101: responding to an interface calling instruction, and determining an interface to be called;
step S102: determining target configuration information corresponding to the interface to be called from the pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively;
step S103: and calling the interface to be called according to the target calling implementation class in the target configuration information and the first input parameter carried by the calling request.
The access protocol type corresponding to the interface to be called may be a common protocol type, such as an Http protocol, a JSF protocol, and the like, and each protocol type has a corresponding call implementation class in the pre-configuration information. The call implementation class refers to a call procedure for implementing an access protocol, and may specifically include a procedure for generating a call request according to an entry.
In an optional embodiment, the preconfiguration information further includes: for the process of determining the target configuration information corresponding to the interface to be called from the pre-configuration information in step S102, the one or more interface identifiers corresponding to each protocol type further includes: and determining target configuration information from the pre-configuration information according to the identifier of the interface to be called.
For example, assuming that there are multiple interfaces, the interface identifiers are interface 1, interface 2, interface 3, interface 4, and interface 5, respectively, where interface 1, interface 3, and interface 5 are all Http protocols, and interface 2 and interface 4 are JSF protocols, the correspondence between the interface identifiers and the protocol types is stored in the preconfigured information.
In addition to the interface identification and the corresponding call implementation class, the provisioning information may further include: interface address, interface name, connection timeout duration, number of failed retries, alias, registry, failed retry policy, etc.
In the actual application process, a unique interface identifier may be set for the interface to be called to determine corresponding target configuration information, and the corresponding relationship between the configuration information and the interface identifier is stored in the pre-configuration information, so that the corresponding target configuration information may be directly obtained from the pre-configuration information through the interface identifier.
In an alternative embodiment, as shown in fig. 2, step S103 may further include:
step S201: determining a parameter entry expression corresponding to an interface to be called from the configuration information;
step S202: determining a second input parameter according to the first input parameter carried by the interface calling instruction and the input parameter expression;
step S203: and generating a calling request according to the second input parameter and the target calling implementation class, and sending the calling request to the interface to be called so as to call the interface to be called.
In order to achieve the purpose of not requiring manual coding, in the embodiment of the present invention, an automatic configuration process similar to coding is implemented by setting a parameter-entering expression, and only a parameter-entering of the parameter-entering expression, that is, a first parameter-entering is needed to obtain a corresponding parameter-exiting parameter, that is, a second parameter-entering, and then the second parameter-entering is sent to the interface to be called, so as to call the interface.
In an alternative embodiment, the reference expression may select a regular expression (regular expression), which is a pattern (pattern) describing matching of character strings, and may be used to check whether a string contains a certain substring, replace the matched substring, or extract a substring meeting a certain condition from a certain string, and the like. Regular expressions are constructed in the same way as mathematical expressions are created, i.e., small expressions can be combined together with a variety of meta-characters and operators to create larger expressions. The components of the regular expression may be individual characters, a collection of characters, a range of characters, a selection between characters, or any combination of all of these components. In general, a regular expression is a text pattern composed of ordinary characters (e.g., characters a to z) and special characters (called "meta characters"). The pattern describes one or more character strings to be matched when searching for text, and the regular expression is used as a template to match a certain character pattern with the searched character strings. In further alternative embodiments, the reference expression includes parsing logic, accessing an address string format, and the like.
It should be noted that, for different protocol types, the manner of invocation is also different. In an alternative embodiment, for a case that the access protocol type is an http protocol type, the sending a call request to the interface to be called in step S203 includes, as shown in fig. 3:
step S301: the access protocol type is an http protocol type, and an http policy class call initialization instance in the target call implementation class is adopted;
step S302: and sending a calling request to the interface to be called according to the initialization example.
Among them, HTTP live is a child item under Apache Jakarta Common to provide an efficient, up-to-date, feature-rich client programming toolkit supporting the HTTP protocol, and it supports the latest versions and recommendations of the HTTP protocol. Compared with the URLConnection carried by the traditional JDK, the HttpClient increases the usability and flexibility, not only makes the client side send the Http request easy, but also is convenient for developers to test the interface (based on the Http protocol), improves the development efficiency and also is convenient for improving the robustness of codes.
In another alternative embodiment, for the case that the access protocol type is the JSF protocol type, as shown in fig. 4, the method includes:
step S401: the access protocol type is a JSF protocol type, and a GenericService class call initialization instance in a target call implementation class is adopted;
step S402: and initiating a generalized calling request to the interface to be called according to the initialization example.
The advantage of using the GenericService to call the interface is that the dubbo method can be called by knowing the full class name, the method name and the parameter list of the interface without depending on the interface given by a service provider, and the call is also called generalized call.
In an optional embodiment, the configuration information further includes a parameter expression, so that after the interface is called, the returned parameter is processed, and a processing result is returned to the caller. As shown in fig. 5, the method further includes:
step S501: receiving an output parameter corresponding to the call request returned by the interface to be called;
step S502: and determining a calling result corresponding to the interface calling instruction according to the parameters and the parameter-generating expression in the configuration information.
The parameter-out expression is similar to the parameter-in expression, and may also be a regular expression, and in an optional embodiment, the parameter-out expression may be used to perform name transformation and/or type conversion on the parameter-out expression to obtain a calling result.
For the processing of the call result, in a further alternative embodiment, as shown in fig. 6, the method includes:
step S601: storing the calling result and the first input parameter correspondingly in a result set;
step S602: when the interface calling instruction of the interface to be called is received again, whether the input parameters carried by the interface calling instruction include the target input parameters same as the first input parameters is determined;
if yes, go to step S603: obtaining a calling result corresponding to the target input parameter from the result set;
if not, in the order of step S101 to step S103, step S604 is performed: and calling the interface to be called according to the input parameters carried by the interface calling instruction, and storing the input parameters carried by the interface calling instruction and the corresponding calling result into a result set.
For example, when the first call entry is a, the corresponding call result is a, and when the second call entry is B, the corresponding call result is B, and when the interface call instruction is received again, the entry is a + B, and at this time, the entry includes the first and second call entries, then a and B may be directly obtained from the result set and returned to the new interface call instruction.
Fig. 7 is a specific step of the interface calling method of the present invention, as shown in fig. 7, including:
step S701: acquiring an interface identifier of an interface to be called;
step S702: determining target configuration information from the pre-configuration information according to the interface identifier and the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively;
step S703: determining a parameter entry expression corresponding to an interface to be called from the configuration information;
step S704: determining a second input parameter according to the first input parameter carried by the interface calling instruction and the input parameter expression;
step S705: adopting a target call to realize the httpparent class or the GenericService class in the classes to call the initialization instance;
step S706: sending a calling request to an interface to be called according to the initialization example;
step S707: receiving an output parameter corresponding to the call request returned by the interface to be called;
step S708: and determining a calling result corresponding to the interface calling instruction according to the parameter-out expression in the parameter-out and configuration information, and correspondingly storing the calling result and the first parameter in a result set.
According to the interface calling method provided by the embodiment of the invention, the target configuration information corresponding to the interface to be called can be determined according to the access protocol type of the interface to be called, so that the corresponding calling implementation class is obtained. The calling implementation class corresponds to the protocol type, so that the same implementation class can be called when a plurality of interfaces to be called of the same protocol type exist, calling of the interfaces is further realized according to the first input parameter carried by the calling request, codes do not need to be compiled for each interface to be called, and maintenance cost and labor cost are greatly saved.
Fig. 8 is a schematic diagram of main modules of an interface-invoked apparatus according to an embodiment of the present invention.
As shown in fig. 8, an apparatus 800 for interface invocation according to an embodiment of the present invention includes:
a determining module 801, configured to determine, in response to an interface call instruction, an interface to be called;
a configuration module 802, configured to determine, according to an access protocol type corresponding to the interface to be called, target configuration information corresponding to the interface to be called from preconfigured information; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively;
and the calling module 803 is configured to call the interface to be called according to the target calling implementation class in the target configuration information and the first input parameter carried in the calling request.
In an optional embodiment, the provisioning information further comprises: one or more interface identifiers corresponding to each protocol type; the configuration module 802 is further configured to determine the target configuration information from the preconfigured information according to the identifier of the interface to be called.
In an optional embodiment, the invoking module 803 is further configured to determine, from the configuration information, a parameter entry expression corresponding to the interface to be invoked; determining a second parameter according to the first parameter carried by the interface calling instruction and the parameter-entering expression; and generating a calling request according to the second input parameter by using the target calling implementation class, and sending the calling request to the interface to be called so as to call the interface to be called.
In an optional embodiment, the apparatus further includes a receiving module, configured to receive an exit parameter corresponding to the call request returned by the interface to be called; and determining a calling result corresponding to the interface calling instruction according to the parameters and the parameter expression in the configuration information.
In an optional embodiment, the invoking module 803 is further configured to, where the access protocol type is an http protocol type, invoke an initialization instance by using an httpclient class in the target invocation implementation class; and sending the calling request to the interface to be called according to the initialization example.
In an optional embodiment, the invoking module 803 is further configured to invoke the initialization instance by using a GenericService class in the target invocation implementation class, where the access protocol type is a JSF protocol type; and initiating a generalized calling request to the interface to be called according to the initialization example.
In an optional embodiment, the receiving module is further configured to store the call result and the first input parameter in a result set in a corresponding manner; when an interface calling instruction of the interface to be called is received again, whether the input parameters carried by the interface calling instruction include the target input parameters same as the first input parameters is determined; if so, acquiring a calling result corresponding to the target entry parameter from the result set; otherwise, calling the interface to be called according to the input parameter carried by the interface calling instruction, and storing the input parameter carried by the interface calling instruction and the corresponding calling result into a result set.
In an optional embodiment, the receiving module is further configured to perform name transformation and/or type conversion on the argument by using the argument expression to obtain the invocation result.
According to the interface calling device provided by the embodiment of the invention, the target configuration information corresponding to the interface to be called can be determined according to the access protocol type of the interface to be called, so that the corresponding calling implementation class is obtained. The calling implementation class corresponds to the protocol type, so that the same implementation class can be called when a plurality of interfaces to be called of the same protocol type exist, calling of the interfaces is further realized according to the first input parameter carried by the calling request, codes do not need to be compiled for each interface to be called, and maintenance cost and labor cost are greatly saved.
Fig. 9 illustrates an exemplary system architecture 900 of an apparatus to which the method of interface invocation or interface invocation of embodiments of the present invention may be applied.
As shown in fig. 9, the system architecture 900 may include end devices 901, 902, 903, a network 904, and a server 905. Network 904 is the medium used to provide communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 901, 902, 903 to interact with a server 905 over a network 904 to receive or send messages and the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 901, 902, 903.
The terminal devices 901, 902, 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 905 may be a server that provides various services, such as a background management server that provides support for a user using an interface call instruction transmitted by the terminal device 901, 902, 903. The background management server may analyze and perform other processing on the received data such as the interface call instruction, and feed back a processing result (e.g., a call result) to the terminal device.
It should be noted that the method for interface invocation provided by the embodiment of the present invention is generally executed by the server 905, and accordingly, the apparatus for interface invocation is generally disposed in the server 905.
It should be understood that the number of terminal devices, networks, and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 10, a block diagram of a computer system 1000 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 10 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU)1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM 1003, various programs and data necessary for the operation of the system 1000 are also stored. The CPU 1001, ROM 1002, and RAM 1003 are connected to each other via a bus 1004. An input/output (I/O) to-be-called interface 1005 is also connected to the bus 1004.
The following components are connected to the I/O to call interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card to be called such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O to-be-called interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 1001.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a determination module, a configuration module, and a calling module. The names of the modules do not constitute a limitation to the module itself in some cases, and for example, the determination module may also be described as a "module for determining an interface to be called in response to an interface call instruction".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
responding to an interface calling instruction, and determining an interface to be called; determining target configuration information corresponding to the interface to be called from pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively; and calling the interface to be called according to a target calling implementation class in the target configuration information and the first input parameter carried by the calling request.
According to the technical scheme of the embodiment of the invention, the target configuration information corresponding to the interface to be called can be determined according to the access protocol type of the interface to be called, and then the corresponding calling implementation class is obtained. The calling implementation class corresponds to the protocol type, so that the same implementation class can be called when a plurality of interfaces to be called of the same protocol type exist, calling of the interfaces is further realized according to the first input parameter carried by the calling request, codes do not need to be compiled for each interface to be called, and maintenance cost and labor cost are greatly saved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. A method for interface invocation, comprising:
responding to an interface calling instruction, and determining an interface to be called;
determining target configuration information corresponding to the interface to be called from pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively;
and calling the interface to be called according to a target calling implementation class in the target configuration information and the first input parameter carried by the calling request.
2. The method of claim 1, wherein the provisioning information further comprises: one or more interface identifiers corresponding to each protocol type; the determining, from the pre-configuration information, target configuration information corresponding to the interface to be called includes:
and determining the target configuration information from the pre-configuration information according to the identifier of the interface to be called.
3. The method according to claim 1, wherein the calling the interface to be called according to the target call implementation class in the target configuration information and the entry parameter carried in the call request includes:
determining a parameter entry expression corresponding to the interface to be called from the configuration information;
determining a second parameter according to the first parameter carried by the interface calling instruction and the parameter-entering expression;
and generating a calling request according to the second input parameter and the target calling implementation class, and sending the calling request to the interface to be called so as to call the interface to be called.
4. The method of claim 3, further comprising:
receiving the output parameter corresponding to the call request returned by the interface to be called;
and determining a calling result corresponding to the interface calling instruction according to the parameters and the parameter expression in the configuration information.
5. The method of claim 1, wherein sending the call request to the interface to be called comprises:
the access protocol type is an http protocol type, and an http policy class call initialization instance in the target call implementation class is adopted;
and sending the calling request to the interface to be called according to the initialization example.
6. The method of claim 1, wherein sending the call request to the interface to be called comprises:
the access protocol type is a JSF protocol type, and the GenericService class in the target calling implementation class is adopted to call an initialization instance;
and initiating a generalization call request to the interface to be called according to the initialization example.
7. The method of claim 4, further comprising:
storing the calling result and the first input parameter correspondingly in a result set;
responding to the interface calling instruction of the interface to be called received again, and determining whether the input parameters carried by the interface calling instruction include the target input parameters same as the first input parameters;
if so, acquiring a calling result corresponding to the target entry parameter from the result set;
otherwise, calling the interface to be called according to the input parameter carried by the interface calling instruction, and storing the input parameter carried by the interface calling instruction and the corresponding calling result into a result set.
8. The method of claim 4, further comprising:
and carrying out name transformation and/or type conversion on the parameters by using the parameter expression to obtain the calling result.
9. An apparatus for interface invocation, comprising:
the determining module is used for responding to the interface calling instruction and determining an interface to be called;
the configuration module is used for determining target configuration information corresponding to the interface to be called from pre-configuration information according to the access protocol type corresponding to the interface to be called; the pre-configuration information comprises calling implementation classes corresponding to different protocol types respectively;
and the calling module is used for calling the interface to be called according to the target calling implementation class in the target configuration information and the first input parameter carried by the calling request.
10. An electronic device for interface invocation, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
11. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202210449001.9A 2022-04-27 2022-04-27 Interface calling method and device Pending CN114816798A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210449001.9A CN114816798A (en) 2022-04-27 2022-04-27 Interface calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210449001.9A CN114816798A (en) 2022-04-27 2022-04-27 Interface calling method and device

Publications (1)

Publication Number Publication Date
CN114816798A true CN114816798A (en) 2022-07-29

Family

ID=82507714

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210449001.9A Pending CN114816798A (en) 2022-04-27 2022-04-27 Interface calling method and device

Country Status (1)

Country Link
CN (1) CN114816798A (en)

Similar Documents

Publication Publication Date Title
CN111190888A (en) Method and device for managing graph database cluster
CN112433788A (en) Applet running method and device, electronic equipment and storage medium
CN111045833A (en) Interface calling method and device
CN113010405A (en) Application program testing method and device
CN113821352A (en) Remote service calling method and device
CN111881392A (en) Page display method and device
CN111382953A (en) Dynamic process generation method and device
CN113779122B (en) Method and device for exporting data
CN114816798A (en) Interface calling method and device
WO2021243665A1 (en) Compilation method, compilation apparatus, compilation system, storage medium, and electronic device
CN114896244A (en) Method, device and equipment for configuring database table and computer readable medium
CN112835609B (en) Method and device for modifying download address of dependent packet
CN113312900A (en) Data verification method and device
CN112306984A (en) Data source routing method and device
CN113760487A (en) Service processing method and device
CN113535221A (en) Method and device for managing application version
CN111984616A (en) Method, device and system for updating shared file
CN113779018A (en) Data processing method and device
CN113536748A (en) Method and device for generating chart data
CN112860447A (en) Interaction method and system between different applications
CN112559001A (en) Method and device for updating application
CN113765868B (en) Service processing method and device
CN108984189B (en) Module parsing method and device
CN114253520B (en) Interface code generation method and device
CN113495747B (en) Gray scale release method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination