CN113722115A - Method, device, equipment and computer readable medium for calling interface - Google Patents

Method, device, equipment and computer readable medium for calling interface Download PDF

Info

Publication number
CN113722115A
CN113722115A CN202010453682.7A CN202010453682A CN113722115A CN 113722115 A CN113722115 A CN 113722115A CN 202010453682 A CN202010453682 A CN 202010453682A CN 113722115 A CN113722115 A CN 113722115A
Authority
CN
China
Prior art keywords
interface
request
calling
parameters
call
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
CN202010453682.7A
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 CN202010453682.7A priority Critical patent/CN113722115A/en
Publication of CN113722115A publication Critical patent/CN113722115A/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a method, a device, equipment and a computer readable medium for calling an interface, and relates to the technical field of computers. One embodiment of the method comprises: receiving a call interface request; acquiring input parameters of a calling interface based on the parameters in the calling interface request; packaging the input parameters in a Remote Procedure Call (RPC) request, and sending the RPC request to a preset interface calling program to call an interface; and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface. The embodiment can improve the efficiency of interface development.

Description

Method, device, equipment and computer readable medium for calling interface
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a computer-readable medium for invoking an interface.
Background
With the increase of the traffic, the traffic codes are also continuously increased, and the system becomes bloated by simply increasing the codes without limitation.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: each time the Remote interface is called, the code of a Remote Procedure Call (RPC) layer needs to be written separately, resulting in inefficient interface development.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a device, and a computer-readable medium for invoking an interface, which can improve the efficiency of interface development.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method for calling an interface, including:
receiving a call interface request;
acquiring input parameters of a calling interface based on the parameters in the calling interface request;
packaging the input parameters in a Remote Procedure Call (RPC) request, and sending the RPC request to a preset interface calling program to call an interface;
and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface.
The call interface request comprises a hypertext transfer protocol (HTTP) call interface request;
the obtaining input parameters of the calling interface based on the parameters in the calling interface request includes:
and taking parameters in the call interface request as the input parameters, wherein the input parameters comprise a participation request link, an HTTP request body and timeout time.
The interface calling request comprises an RPC framework calling request;
the obtaining input parameters of the calling interface based on the parameters in the calling interface request includes:
the parameters in the RPC frame interface calling request comprise interface names, implementation methods corresponding to the interface names are loaded through the interface names by using a reflection technology, and parameters related to the implementation methods are loaded by using the reflection technology;
and taking the interface name, the implementation method corresponding to the interface name and the parameters related to the implementation method as the input parameters.
The RPC framework interface calling request comprises one of a JSF service calling request, a dubbo service calling request and a springCloud service calling request.
The RPC request comprises an rpcRequest object;
the outputting the parameters of the interface feedback comprises:
and outputting the parameters fed back by the interface in the rpcResponse object.
The call interface request comprises a call HTTP interface request;
the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface, and the method comprises the following steps:
packaging the input parameters into an HTTP client request, and calling and sending an HTTP client t to send the RPC request to the interface by adopting an HTTP client request management end;
and after the interface is successfully called, packaging and outputting parameters fed back by the interface in a rpcResponse object in a JSON data format.
The interface calling request comprises an RPC framework calling request;
the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface, and the method comprises the following steps:
acquiring an implementation method set of the interface according to the interface name in the input parameter;
traversing the implementation method set, and comparing the implementation methods corresponding to the interface names of the input parameters to obtain the implementation methods needing to be requested;
calling the interface according to the implementation method of the request and the parameters related to the implementation method corresponding to the interface name of the input parameter;
and after the interface is successfully called, packaging and outputting parameters fed back by the interface in a rpcResponse object in a JSON data format.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for calling an interface, including:
the receiving module is used for receiving a calling interface request;
the obtaining module is used for obtaining the input parameters of the calling interface based on the parameters in the calling interface request;
the calling module is used for packaging the input parameters in a Remote Procedure Call (RPC) request and sending the RPC request to a preset interface calling program to call an interface;
and the output module is used for successfully calling the interface by the preset interface calling program and outputting the parameters fed back by the interface.
According to a third aspect of the embodiments of the present invention, there is provided an electronic device for calling an interface, including:
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 as described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method as described above.
One embodiment of the above invention has the following advantages or benefits: receiving a call interface request; acquiring input parameters of a calling interface based on parameters in the calling interface request; encapsulating the input parameters in the RPC request, and sending the RPC request to a preset interface calling program to call an interface; and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface. Because the preset interface calling program can be executed to send the RPC request according to the input parameters of the calling interface, the parameters fed back by the interface are output. The code of the RPC layer does not need to be written separately, so that the efficiency of interface development can be improved.
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 flow diagram of an APP data request;
FIG. 2 is a schematic diagram of the main flow of a method of calling an interface according to an embodiment of the invention;
FIG. 3 is a flow chart illustrating a process for obtaining input parameters of a calling interface according to an embodiment of the present invention;
FIG. 4 is a diagram of parameters involved in an HTTP interface request according to an embodiment of the present invention;
FIG. 5 is a parameter-related diagram of a JSF service invocation request according to an embodiment of the present invention;
FIG. 6 is a flow diagram illustrating a request to invoke an interface for an HTTP interface according to an embodiment of the present invention;
FIG. 7 is a schematic flow diagram of a call interface for a JSF service call request according to an embodiment of the present invention;
FIG. 8 is a flow diagram of an APP data request in accordance with an embodiment of the present invention;
FIG. 9 is a schematic diagram of the main structure of a device for invoking an interface according to an embodiment of the present invention;
FIG. 10 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 11 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a 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.
Referring to fig. 1, fig. 1 is a schematic flow diagram of an APP data request, which specifically includes:
the user sends a request to a client, which may be an Application (APP) installed on the mobile terminal. The client sends the request to a Service Oriented Architecture (SOA) system of the service side through the gateway.
The SOA is a component model that splits the different functional units of an application and ties them together through well-defined interfaces and protocols between these services. The interface is defined in a neutral manner and should be independent of the hardware platform, operating system and programming language in which the service is implemented. This allows the services of the components in a wide variety of systems to interact in a uniform and versatile manner.
And the service-side SOA system concurrently processes the request through the view layer and the service layer. Specifically, a thread pool (threadpoolexcuctor) is created. Rpc1.executor, rpc2.executor and rpc3.executor are processed in parallel in ThreadPoolExcutor. The parallel processing relates to an RPC layer, and the RPC layer mainly relates to interface calling and does not perform service logic processing. And finally, feeding back the processing result to the service terminal SOA system.
And the service terminal SOA system feeds back parameters corresponding to the request to the user through the gateway and the client.
Currently, a separate RPC layer needs to be created for each remote service call, and RPCs also need to be configured in the xml file of Spring. Spring is a lightweight open source framework in the field of Java EE programming.
When Spring starts to initialize, all RPC layer code needs to be loaded into the Control Inversion (IOC) container. It is time consuming to load a large amount of RPC layer code that can impact the initialization of the container. Wherein IOC is the core of spring. The IOC is a framework for Spring, in which Spring is responsible for controlling the life cycle of an object and the relationship between objects.
In terms of development efficiency, since each remote service call must add the code of the corresponding RPC layer, the interface development efficiency is reduced. In addition, the large increase of the repeated codes can lead to the increase of the system code volume, the increase of the maintenance difficulty and the reduction of the code value.
It becomes increasingly important to promote code reusability among ever increasing traffic codes. For reusable programs and field sorting modification; the remotely invoked data layer may be optimized based on the participating projects. It can be seen that the efficiency of interface development is low due to the repetition of codes in the PRC layer and the large number of codes.
In order to solve the technical problem of low efficiency of interface development, the following technical scheme in the embodiment of the present invention may be adopted.
Referring to fig. 2, fig. 2 is a schematic diagram of a main flow of a method for calling an interface according to an embodiment of the present invention, in which an input parameter of the calling interface is encapsulated in an RPC request, a preset interface calling program is executed, and a parameter fed back by the interface is output. As shown in fig. 1, the method specifically comprises the following steps:
s201, receiving a calling interface request.
After a service side SOA system receives an interface calling request sent by a user, firstly, the interface type needs to be determined.
In an embodiment of the invention, the interface types include a hypertext transfer protocol (HTTP) interface and an RPC framework interface. Wherein, the RPC frame interface is an interface adopting a PRC frame.
As an example, the RPC framework interface call request comprises one of the following: a JSF service invocation request, a dubbo service invocation request and a springCloud service invocation request. Jsf (javaserver faces) is a standard framework for building Java Web applications.
According to the call interface request sent by the user, the type of the call interface can be directly known. It will be appreciated that the interface type is determined by a call interface request sent by the user.
S202, acquiring input parameters of the calling interface based on the parameters in the calling interface request.
And the calling interface request comprises one or more parameters, and the input parameters of the calling interface are further acquired based on the parameters. The input parameter of the call interface is a parameter for the call interface. The RPC request can be sent using the input parameters of the call interface.
Considering that the calling interface is different in type, the input parameters of the calling interface can be obtained according to the interface type.
For the calling interface request including the HTTP interface request, the input parameters of the calling interface may be obtained in a first manner. And for the calling interface request comprising the RPC frame interface request, acquiring the input parameters of the calling interface by adopting a second mode.
In a first mode
The entry request link URL, HTTP Body, and TimeOut time TimeOut are included in the HTTP interface request. In order to call the interface, the parameters in the HTTP interface request may be used as input parameters for calling the interface. That is, the input parameters of the call interface include an entry request link URL, HTTP Body, and TimeOut.
Mode two
Referring to fig. 3, fig. 3 is a schematic flowchart of a process of acquiring an input parameter of a call interface according to an embodiment of the present invention, which specifically includes:
s301, calling parameters in the RPC frame interface request to include interface names, loading implementation methods corresponding to the interface names by the interface names through reflection technology, and parameters related to the implementation methods.
The parameters in the call RPC framework interface request include the interface name. The input parameters of the calling interface need to include an interface name, an implementation method corresponding to the interface name, and parameters related to the implementation method corresponding to the interface name.
The implementation method corresponding to the interface name can be loaded by the interface name by using a reflection technology, and parameters related to the implementation method corresponding to the interface name can be loaded by using the reflection technology.
The RPC framework interface call request comprises one of the following requests: a JSF service invocation request, a dubbo service invocation request and a springCloud service invocation request. The following is an exemplary description taking the example that the call RPC framework interface request is a JSF service call request.
Such as: and inquiring the order information, wherein the interface type provided by the station in the order is the JSF type, and the interface name in the call request for calling the JS F service is com. An implementation method getOrderInfo (pin, orderId) corresponding to an interface name is acquired from an IOC container through the interface name by utilizing a reflection technology, and a parameter Ord ercenter JsfExport related to the implementation method. Finally, getOrderInfo is called with OrderCenterJsfExport to call the JSF interface.
S302, the interface name, the implementation method corresponding to the interface name and the parameters related to the implementation method are used as input parameters.
The interface name, the implementation method corresponding to the interface name, and the parameters related to the implementation method may be used as input parameters of the calling interface to call the upstream interface.
In the embodiment of fig. 3, for the request of calling the RPC framework interface, the reflection technique may be used to load the relevant parameters, thereby obtaining the input parameters of the calling interface.
S203, encapsulating the input parameters in the RPC request, and sending the RPC request to a preset interface calling program to call an interface.
According to the existing development program, if an upstream interface needs to be called when a new service is accessed every time, a separate RPC layer code needs to be added for the newly accessed interface, so that repeated code writing is caused.
In the embodiment of the invention, for the interface calling request, no matter what interface type, a preset interface can be adopted to call the program calling interface. That is, according to the input parameters of the calling interface, the RPC request can be sent to call the interface by calling the program through the preset interface.
In particular, code need not be repeatedly written. The input parameters of the calling interface can be uniformly packaged in the rpcRequest object. And analyzing the input parameters in the rpcRequest object in a preset interface calling program, and then calling the interface. And after the interface is successfully called, uniformly packaging the returned parameters into the rpcResponse object by the preset interface calling program.
Interface calling programs are preset according to the commonality of various RPC codes, so that the maximum reduction of the service code quantity can be realized, and the interfaces can be called normally. It is understood that the default interface caller is set according to the commonality of the various RPC codes.
And S204, the preset interface calling program successfully calls the interface and outputs parameters fed back by the interface.
And after the preset interface calling program receives the input parameters of the calling interface, successfully calling the interface and outputting the parameters fed back by the interface. Specifically, the feedback parameters may be output to the SOA system of the server.
In one embodiment of the invention, the PRC request includes an rpcrrequest object. Then the parameters fed back by the interface can be output in the rpcsesponse object.
Referring to fig. 4, fig. 4 is a diagram illustrating parameters involved in an HTTP interface request according to an embodiment of the present invention.
In the case where the calling interface request is an HTTP interface request, the call involves rpsRequest and rpcsespons. rpsRequest needs to encapsulate the reference request link URL, the reference Body, and the TimeOut TimeOut. That is, the input parameters of the call interface include an enter request link URL, an enter Body, and a TimeOut.
Referring to fig. 5, fig. 5 is a schematic diagram of parameters involved in a JSF service invocation request according to an embodiment of the present invention.
Wherein, in case the call interface request is a JSF service call request, the call involves rp sRequest and rpcsespons. The rpsRequest needs to encapsulate an interface name, an implementation method corresponding to the interface name, and a parameter requestPara m related to the implementation method. That is, the input parameters of the calling interface include the interfaceName, the methodName, and the requestParam.
In the embodiment of the present invention, the program is called to call the interface through the preset interface, and an exemplary description is given below according to the interface type.
Fig. 6 illustrates an example in which the call interface request is a call HTTP interface request. Fig. 7 illustrates an example in which the call interface request is a JSF service call request.
Referring to fig. 6, fig. 6 is a schematic flowchart of a procedure for invoking an interface for an HTTP interface request according to an embodiment of the present invention, which specifically includes:
s601, packaging the input parameters into an HTTP client request, and calling the HTTP client to send an RPC request to an interface by adopting an HTTP client request management end.
The HTTP interface request is sent to an HTTP request handler, and the access request link URL, the access Body and the TimeOut are analyzed. And (3) linking the entry-reference request with the URL, the entry-reference Body and the timeout Tim eOut to an rpsRequest, wherein the rpsRequest is an HTTP client request (HttpClie ntRequest).
Then, an HTTP request tool type HTTP client request management end (HTTP client request manager) is used to call a corresponding implementation method to send an HTTP client (sendhttp client) to send an RPC request to an interface.
And S602, after the interface is called successfully, packaging and outputting parameters fed back by the interface in the rpcResponse object in a JSON data format.
After the interface is successfully called, the parameters fed back by the interface can be received, the parameters fed back by the interface are output in the rpcResponse object in the JSON data format, and the fed back parameters can be returned to the SOA system of the service terminal.
JSON is a lightweight data exchange format. It is based on a subset of ECMAScript, and uses a text format that is completely independent of the programming language to store and represent data. The compact and clear hierarchy makes JSON an ideal data exchange language. The method is easy to read and write, and is easy to analyze and generate by a machine, and the network transmission efficiency is effectively improved.
In the embodiment of fig. 6, for each HTTP interface request, without repeatedly writing code, the interface may be called by using the steps in fig. 6, and the fed back parameters may be returned to the service-side SOA system.
Referring to fig. 7, fig. 7 is a schematic flowchart of a call interface for a JSF service call request according to an embodiment of the present invention, where an RPC framework interface request may include: a JSF service invocation request, a dubbo service invocation request or a springCloud service invocation request. The following is an exemplary description of an RPC framework interface request, specifically a JSF service call request. The method specifically comprises the following steps:
s701, acquiring an interface implementation method set according to the interface name in the input parameter.
The HPPT interface request is sent to JsfRequestHandler, and is resolved into the parameters InterfaceName, methodName and requestParam.
And loading the class of the interface in the IOC container according to the interface name by adopting @ automatic. And simultaneously acquiring an interface implementation method set according to the reflected class.
S702, traversing the implementation method set, and comparing the implementation methods corresponding to the interface names of the input parameters to obtain the implementation method required to be requested.
And traversing the interface method set, and comparing the access parameter with the method name to obtain the implementation method required to be requested.
And S703, calling the interface according to the requested implementation method and the parameters related to the implementation method corresponding to the interface name of the input parameter.
And calling a JSF interface according to the implementation method of the request and the requestParam.
S704, after the interface is called successfully, parameters fed back by the interface are packaged and output in the rpcResponse object in the data format of JSON.
And feeding back parameters by the JSF interface, namely successfully calling the JSF interface. And packaging the parameters fed back by the JSF interface into the rpcResponse object in a JSON data format to output the parameters fed back by the interface to the service-side SOA system.
In the embodiment of fig. 7, for each RPC framework interface call request, the interface may be called by using the steps in fig. 7 without repeatedly writing code, and the fed back parameters may be returned to the service-side SOA system.
Referring to fig. 8, fig. 8 is a schematic flowchart of an APP data request according to an embodiment of the present invention, which specifically includes:
the user sends a request to the client, and the client sends the request to the service-oriented Service Oriented Architecture (SOA) system of the service through the gateway.
And the service-side SOA system concurrently processes the request through the view layer and the service layer. The concurrent processing of requests differs from that in fig. 1, but instead receives a call interface request at threadpoolexcuitor. Then, the input parameters of the calling interface are obtained based on the interface type, the output parameters can be packaged in rpsRequest, the parameters returned by the preset interface calling program are received in rpcRespons, and the returned parameters can be fed back to the SOA system of the service terminal.
And the service terminal SOA system feeds back a result corresponding to the request to the user through the gateway and the client.
As can be seen from the above process, compared with fig. 1, the technical scheme in fig. 8 adopts rpsRequest and rpcsespons to execute the preset interface calling program, and code writing does not need to be repeated, thereby reducing the amount of service code.
In addition, the parameters fed back to the service-side SOA system are consistent with the parameters fed back by adopting the prior art, so that the service-side SOA system can be ensured to normally return relevant data to the user.
In the above embodiment, a call interface request is received; acquiring input parameters of a calling interface based on parameters in the calling interface request; encapsulating the input parameters in the RPC request, and sending the RPC request to a preset interface calling program to call an interface; and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface.
The RPC information is loaded in the IOC container, and the RPC code of each interface is not required to be loaded because only the preset interface calling program is required to be loaded, so that a large amount of loading time is reduced. The performance of the system is improved, and meanwhile, the access time is reduced; in addition, the reduction of RPC layer codes causes the system to become lighter, the maintenance is simple, and the readability is increased; finally, the service volume is increased instantly, and redundant RPC repeated codes are not required to be added, so that the development efficiency is greatly improved, the development period is shortened, the service can quickly respond to the market requirement, and the interface development efficiency can be improved. The experience of the user is integrally improved.
Referring to fig. 9, fig. 9 is a schematic diagram of a main structure of a device for calling an interface according to an embodiment of the present invention, where the device for calling an interface may implement a method for calling an interface, as shown in fig. 9, the device for calling an interface specifically includes:
a receiving module 901, configured to receive an interface invocation request.
An obtaining module 902, configured to obtain an input parameter of the calling interface based on a parameter in the calling interface request.
And the calling module 903 is used for packaging the input parameter in the RPC request and sending the RPC request to a preset interface calling program to call an interface.
And the output module 904 is configured to preset parameters fed back by the interface calling program, which successfully calls the interface and outputs the parameters.
In one embodiment of the invention, invoking the interface request comprises invoking an HTTP interface request;
the obtaining module 902 is specifically configured to use parameters in the call interface request as input parameters, where the input parameters include an entry request link URL, an entry Body, and a TimeOut.
In one embodiment of the invention, invoking the interface request comprises invoking an RPC framework interface request;
an obtaining module 902, configured to specifically call parameters in an interface request of an RPC framework, where the parameters include an interface name, and load, by using a reflection technology, an implementation method corresponding to the interface name and parameters related to the implementation method through the interface name;
the interface name, the implementation method corresponding to the interface name and the parameters related to the implementation method are used as input parameters.
In one embodiment of the invention, the RPC framework interface call request comprises one of a JSF service call request, a dubbo service call request and a springCloud service call request.
In one embodiment of the invention, the RPC request includes an rpcRequest object;
the output module 904 is specifically configured to output the parameters fed back by the interface in the rpcsesponse object.
In one embodiment of the invention, invoking the interface request comprises invoking an HTTP interface request;
the output module 904 is specifically configured to encapsulate the input parameter into an http challenge request, and call sendhttp challenge by using an http challenge manager to send the RPC request to an interface;
and after the interface is successfully called, packaging and outputting parameters fed back by the interface in the rpcResponse object in a JSON data format.
In one embodiment of the invention, invoking the interface request comprises invoking an RPC framework interface request;
an output module 904, configured to specifically obtain an implementation method set of an interface according to an interface name in the input parameter;
traversing the implementation method set, and comparing the implementation methods corresponding to the interface names of the input parameters to obtain the implementation method required to be requested;
calling the interface according to the implementation method of the request and the parameters related to the implementation method corresponding to the interface name of the input parameter;
and after the interface is successfully called, packaging and outputting parameters fed back by the interface in the rpcResponse object in a JSON data format.
Fig. 10 illustrates an exemplary system architecture 1000 to which a method of calling an interface or an apparatus for calling an interface of an embodiment of the present invention may be applied.
As shown in fig. 10, the system architecture 1000 may include terminal devices 1001, 1002, 1003, a network 1004, and a server 1005. The network 1004 is used to provide a medium for communication links between the terminal devices 1001, 1002, 1003 and the server 1005. Network 1004 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 1001, 1002, 1003 to interact with a server 1005 via a network 1004 to receive or transmit messages or the like. The terminal devices 1001, 1002, 1003 may have installed thereon various messenger client applications such as shopping applications, web browser applications, search applications, instant messenger, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 1001, 1002, 1003 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 1005 may be a server that provides various services, such as a backend management server (for example only) that supports shopping websites browsed by users using the terminal devices 1001, 1002, 1003. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for invoking the interface provided by the embodiment of the present invention is generally executed by the server 1005, and accordingly, the apparatus for invoking the interface is generally disposed in the server 1005.
It should be understood that the number of terminal devices, networks, and servers in fig. 10 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 11, shown is a block diagram of a computer system 1100 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 11 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. 11, the computer system 1100 includes a Central Processing Unit (CPU)1101, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)1102 or a program loaded from a storage section 1108 into a Random Access Memory (RAM) 1103. In the RAM 1103, various programs and data necessary for the operation of the system 1100 are also stored. The CPU 1101, ROM 1102, and RAM 1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
The following components are connected to the I/O interface 1105: an input portion 1106 including a keyboard, mouse, and the like; an output portion 1107 including a signal output unit such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 1108 including a hard disk and the like; and a communication section 1109 including a network interface card such as a LAN card, a modem, or the like. The communication section 1109 performs communication processing via a network such as the internet. A driver 1110 is also connected to the I/O interface 1105 as necessary. A removable medium 1111 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1110 as necessary, so that a computer program read out therefrom is mounted into the storage section 1108 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 portion 1109 and/or installed from the removable medium 1111. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 1101.
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 transmitting unit, an obtaining unit, a determining unit, and a first processing unit. The names of these units do not in some cases constitute a limitation to the unit itself, and for example, the sending unit may also be described as a "unit sending a picture acquisition request to a connected server".
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:
receiving a call interface request;
acquiring input parameters of a calling interface based on the parameters in the calling interface request;
packaging the input parameters in a Remote Procedure Call (RPC) request, and sending the RPC request to a preset interface calling program to call an interface;
and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface.
According to the technical scheme of the embodiment of the invention, an interface calling request is received; acquiring input parameters of a calling interface based on parameters in the calling interface request; encapsulating the input parameters in the RPC request, and sending the RPC request to a preset interface calling program to call an interface; and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface. Because the preset interface calling program can be executed to send the RPC request according to the input parameters of the calling interface, the parameters fed back by the interface are output. The code of the RPC layer does not need to be written separately, so that the efficiency of interface development can be improved.
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 (10)

1. A method of invoking an interface, comprising:
receiving a call interface request;
acquiring input parameters of a calling interface based on the parameters in the calling interface request;
packaging the input parameters in a Remote Procedure Call (RPC) request, and sending the RPC request to a preset interface calling program to call an interface;
and the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface.
2. The method of invoking an interface of claim 1 wherein said invoking an interface request comprises invoking a hypertext transfer protocol (HTTP) interface request;
the obtaining input parameters of the calling interface based on the parameters in the calling interface request includes:
and taking parameters in the call interface request as the input parameters, wherein the input parameters comprise a participation request link, an HTTP request body and timeout time.
3. The method of claim 1, wherein the call interface request comprises a call RPC framework interface request;
the obtaining input parameters of the calling interface based on the parameters in the calling interface request includes:
the parameters in the RPC frame interface calling request comprise interface names, implementation methods corresponding to the interface names are loaded through the interface names by using a reflection technology, and parameters related to the implementation methods are loaded by using the reflection technology;
and taking the interface name, the implementation method corresponding to the interface name and the parameters related to the implementation method as the input parameters.
4. The method of claim 3, wherein the RPC framework interface call request comprises one of a JSF service call request, a dubbo service call request, and a springCloud service call request.
5. The method of calling an interface of claim 1, wherein the RPC request comprises an rpcRequest object;
the outputting the parameters of the interface feedback comprises:
and outputting the parameters fed back by the interface in the rpcResponse object.
6. The method of invoking an interface of claim 1 wherein said invoking an interface request comprises invoking an HTTP interface request;
the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface, and the method comprises the following steps:
packaging the input parameters into an HTTP client request, and calling a transmission HTTP client by adopting an HTTP client request management end to transmit the RPC request to the interface;
and after the interface is successfully called, packaging and outputting parameters fed back by the interface in a rpcResponse object in a JSON data format.
7. The method of claim 1, wherein the call interface request comprises a call RPC framework interface request;
the preset interface calling program successfully calls the interface and outputs the parameters fed back by the interface, and the method comprises the following steps:
acquiring an implementation method set of the interface according to the interface name in the input parameter;
traversing the implementation method set, and comparing the implementation methods corresponding to the interface names of the input parameters to obtain the implementation methods needing to be requested;
calling the interface according to the implementation method of the request and the parameters related to the implementation method corresponding to the interface name of the input parameter;
and after the interface is successfully called, packaging and outputting parameters fed back by the interface in a rpcResponse object in a JSON data format.
8. An apparatus for invoking an interface, comprising:
the receiving module is used for receiving a calling interface request;
the obtaining module is used for obtaining the input parameters of the calling interface based on the parameters in the calling interface request;
the calling module is used for packaging the input parameters in a Remote Procedure Call (RPC) request and sending the RPC request to a preset interface calling program to call an interface;
and the output module is used for successfully calling the interface by the preset interface calling program and outputting the parameters fed back by the interface.
9. An electronic device for invoking an interface, 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.
10. 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.
CN202010453682.7A 2020-05-26 2020-05-26 Method, device, equipment and computer readable medium for calling interface Pending CN113722115A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010453682.7A CN113722115A (en) 2020-05-26 2020-05-26 Method, device, equipment and computer readable medium for calling interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010453682.7A CN113722115A (en) 2020-05-26 2020-05-26 Method, device, equipment and computer readable medium for calling interface

Publications (1)

Publication Number Publication Date
CN113722115A true CN113722115A (en) 2021-11-30

Family

ID=78671832

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010453682.7A Pending CN113722115A (en) 2020-05-26 2020-05-26 Method, device, equipment and computer readable medium for calling interface

Country Status (1)

Country Link
CN (1) CN113722115A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115529303A (en) * 2022-11-07 2022-12-27 北京智象信息技术有限公司 Method, system and medium for adapting Cobalt interface request

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102780613A (en) * 2012-06-19 2012-11-14 瑞斯康达科技发展股份有限公司 Method and device for communication of boards of distributed device
CN103164200A (en) * 2011-12-15 2013-06-19 华迪计算机集团有限公司 Application system development control method
CN106598851A (en) * 2016-12-05 2017-04-26 广州唯品会信息科技有限公司 Software interface test method and system
CN107360261A (en) * 2017-09-07 2017-11-17 北京奇艺世纪科技有限公司 A kind of HTTP request processing method, device and electronic equipment
CN107733922A (en) * 2017-11-20 2018-02-23 百度在线网络技术(北京)有限公司 Method and apparatus for calling service
CN109377348A (en) * 2018-09-27 2019-02-22 深圳市佰仟金融服务有限公司 Applied to the business interface call method for helping loan operation system and help loan operation system
CN109981546A (en) * 2017-12-28 2019-07-05 北京京东尚科信息技术有限公司 The method and apparatus for obtaining the far call relationship between application module
CN110191164A (en) * 2019-05-20 2019-08-30 中国工商银行股份有限公司 Distributed Services access system and method
CN110851210A (en) * 2019-11-12 2020-02-28 北京字节跳动网络技术有限公司 Interface program calling method, device, equipment and storage medium
CN111193716A (en) * 2019-12-11 2020-05-22 未鲲(上海)科技服务有限公司 Service data calling method and device, computer equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103164200A (en) * 2011-12-15 2013-06-19 华迪计算机集团有限公司 Application system development control method
CN102780613A (en) * 2012-06-19 2012-11-14 瑞斯康达科技发展股份有限公司 Method and device for communication of boards of distributed device
CN106598851A (en) * 2016-12-05 2017-04-26 广州唯品会信息科技有限公司 Software interface test method and system
CN107360261A (en) * 2017-09-07 2017-11-17 北京奇艺世纪科技有限公司 A kind of HTTP request processing method, device and electronic equipment
CN107733922A (en) * 2017-11-20 2018-02-23 百度在线网络技术(北京)有限公司 Method and apparatus for calling service
CN109981546A (en) * 2017-12-28 2019-07-05 北京京东尚科信息技术有限公司 The method and apparatus for obtaining the far call relationship between application module
CN109377348A (en) * 2018-09-27 2019-02-22 深圳市佰仟金融服务有限公司 Applied to the business interface call method for helping loan operation system and help loan operation system
CN110191164A (en) * 2019-05-20 2019-08-30 中国工商银行股份有限公司 Distributed Services access system and method
CN110851210A (en) * 2019-11-12 2020-02-28 北京字节跳动网络技术有限公司 Interface program calling method, device, equipment and storage medium
CN111193716A (en) * 2019-12-11 2020-05-22 未鲲(上海)科技服务有限公司 Service data calling method and device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115529303A (en) * 2022-11-07 2022-12-27 北京智象信息技术有限公司 Method, system and medium for adapting Cobalt interface request
CN115529303B (en) * 2022-11-07 2023-03-07 北京智象信息技术有限公司 Method, system and medium for adapting Cobalt interface request

Similar Documents

Publication Publication Date Title
US11144711B2 (en) Webpage rendering method, device, electronic apparatus and storage medium
CN105718540B (en) Data loading method and device
CN109815107B (en) Method and device for automatic testing
CN111338623B (en) Method, device, medium and electronic equipment for developing user interface
CN111786939B (en) Method, device and system for testing management platform of Internet of things
CN111831461A (en) Method and device for processing business process
CN114979295B (en) Gateway management method and device
CN112653614A (en) Request processing method and device based on message middleware
CN110704200A (en) Method and device for converting call interface
CN112084042A (en) Message processing method and device
CN112015383A (en) Login method and device
CN116561013B (en) Testing method and device based on target service framework, electronic equipment and medium
CN113722115A (en) Method, device, equipment and computer readable medium for calling interface
CN113965628A (en) Message scheduling method, server and storage medium
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN113535419A (en) Service arranging method and device
CN112764746A (en) Data processing method and device, electronic equipment and storage medium
CN113779122B (en) Method and device for exporting data
US7908397B1 (en) Application server gateway technology
CN112187916B (en) Cross-system data synchronization method and device
CN111937366B (en) Web request processing method and device
CN112131095B (en) Pressure testing method and device
CN110909269B (en) Log reporting method and device
CN112929453A (en) Method and device for sharing session data
CN113760693A (en) Method and apparatus for local debugging of microservice systems

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