Movatterモバイル変換


[0]ホーム

URL:


CN116841884A - Interface calling method, device, equipment and readable storage medium - Google Patents

Interface calling method, device, equipment and readable storage medium
Download PDF

Info

Publication number
CN116841884A
CN116841884ACN202310802312.3ACN202310802312ACN116841884ACN 116841884 ACN116841884 ACN 116841884ACN 202310802312 ACN202310802312 ACN 202310802312ACN 116841884 ACN116841884 ACN 116841884A
Authority
CN
China
Prior art keywords
interface
target
state
mock
message
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
CN202310802312.3A
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China LtdfiledCriticalBank of China Ltd
Priority to CN202310802312.3ApriorityCriticalpatent/CN116841884A/en
Publication of CN116841884ApublicationCriticalpatent/CN116841884A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The application provides an interface calling method, a device, equipment and a readable storage medium, which can be applied to the financial field or other fields, and firstly acquire target interface information, wherein the target interface information comprises an address data input item of a target interface; generating a simulated mock interface corresponding to the target interface based on the data input item of the address of the target interface; sending a verification request to a target interface by using the analog mock interface; after receiving response information of the target interface to the verification request; determining the interface state of the target interface according to the response information; responding to a call request of a simulated mock interface sent by a target system, if the interface state of the target interface is a normal state, sending a prompt message to the target system, and transmitting the call request of the mock interface to the target interface so that the target system directly calls the target interface; if the interface state of the target interface is abnormal, a preset message is sent to the target system, so that the available interface is called in time, and the calling efficiency of the interface is improved.

Description

Interface calling method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to an interface calling method, apparatus, device, and readable storage medium.
Background
With the rapid development of digitization of various industries, the number of various business systems is increasing, the application of a mobile terminal is gradually highlighted, the technology of front-end and rear-end separation development is gradually mature, and most of services are called by other applications in a data interface mode.
At present, a third party platform for providing online data interface service is mainly used for providing definition and test of interfaces, and a great deal of time is required for technicians to participate in development of the interfaces, so that the interfaces are difficult to be effectively called, and the calling quality of the interfaces is difficult to be ensured. Therefore, there is a need for an interface calling method to improve the interface calling efficiency.
Disclosure of Invention
In view of the above, the present application provides an interface calling method, apparatus, device, and readable storage medium, which can improve the calling efficiency of an interface.
In order to solve the problems, the technical scheme provided by the application is as follows:
in a first aspect, the present application provides an interface calling method, the method comprising:
acquiring target interface information, wherein the target interface information comprises an address of a target interface and a data input item of the target interface;
generating a simulated mock interface corresponding to the target interface based on the address of the target interface and the data input item of the target interface;
transmitting a verification request to the target interface by using the analog mock interface;
receiving response information of the target interface to the verification request;
determining the interface state of the target interface according to the response information;
responding to a call request of the simulated mock interface sent by a target system, if the interface state of the target interface is a normal state, sending a prompt message to the target system, and transmitting the call request of the simulated mock interface to the target interface so that the target system directly calls the target interface, wherein the prompt message indicates that the interface state of the target interface is the normal state;
and responding to a call request of the simulated mock interface sent by a target system, and if the interface state of the target interface is an abnormal state, sending a target interface abnormal message to the target system.
In one possible implementation manner, the sending, by using the analog mock interface, a verification request to the target interface includes:
judging whether the analog mock interface is called in a preset interface calling period;
and if the simulated mock interface is called, sending a verification request to the target interface by using the simulated mock interface.
In one possible implementation manner, the response information is a target message, and the determining, according to the response information, an interface state of the target interface includes:
judging whether the target message is identical to a preset verification message or not;
if the target message is the same as the preset verification message, determining that the interface state of the target interface is a normal state;
and if the target message is different from the preset verification message, determining that the interface state of the target interface is an abnormal state.
In one possible implementation manner, the response information is interface abnormality information, and the determining, according to the response information, the interface state of the target interface includes:
and determining the interface state of the target interface as an abnormal state based on the interface abnormal message.
In one possible implementation, the method includes:
and if the interface state of the target interface is an abnormal state, storing the response information, the verification request and the interface state in a target database.
In a second aspect, the present application also provides an interface calling device, where the device includes:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring target interface information, and the target interface information comprises an address of a target interface and a data input item of the target interface;
the generation module is used for generating a simulated mock interface corresponding to the target interface based on the address of the target interface and the data input item of the target interface;
the first sending module is used for sending a verification request to the target interface by utilizing the analog mock interface;
the receiving module is used for receiving response information of the target interface to the verification request;
the determining module is used for determining the interface state of the target interface according to the response information;
the call module is used for responding to a call request of the simulated mock interface sent by a target system, sending a prompt message to the target system if the interface state of the target interface is a normal state, and transmitting the call request of the simulated mock interface to the target interface so that the target system directly calls the target interface, wherein the prompt message indicates that the interface state of the target interface is the normal state;
and the second sending module is used for responding to the call request of the simulated mock interface sent by the target system, and sending a target interface exception message to the target system if the interface state of the target interface is an exception state.
In one possible implementation manner, the first sending module is specifically configured to:
judging whether the analog mock interface is called in a preset interface calling period;
and if the simulated mock interface is called, sending a verification request to the target interface by using the simulated mock interface.
In one possible implementation manner, the response information is a target message, and the determining module is specifically configured to:
judging whether the target message is identical to a preset verification message or not;
if the target message is the same as the preset verification message, determining that the interface state of the target interface is a normal state;
and if the target message is different from the preset verification message, determining that the interface state of the target interface is an abnormal state.
In one possible implementation manner, the response information is interface abnormality information, and the determining module is specifically configured to:
and determining the interface state of the target interface as an abnormal state based on the interface abnormal message.
In one possible implementation, the apparatus further includes: a storage module;
and the storage module is used for storing the response information, the verification request and the interface state in a target database if the interface state of the target interface is an abnormal state.
In a third aspect, the present application provides an interface calling device, including: a processor and a memory;
the memory is used for storing one or more programs;
the processor is configured to implement an interface calling method as described in the first aspect above when the one or more programs are executed by the processor.
Fourth aspect the present application provides a computer readable storage medium storing instructions which, when run on a device, cause the device to perform an interface invocation method as described in the first aspect above.
From this, the application has the following beneficial effects:
the application provides an interface calling method, a device, equipment and a readable storage medium, wherein target interface information is firstly obtained, and the target interface information comprises an address of a target interface and a data input item of the target interface; generating a simulation mock interface corresponding to the target interface based on the address of the target interface and the data input item of the target interface; then, the analog mock interface can be utilized to send a verification request to the target interface; receiving response information of the target interface to the verification request; determining the interface state of the target interface according to the response information; responding to a call request of the simulated mock interface sent by a target system, if the interface state of the target interface is a normal state, sending a prompt message to the target system, and transmitting the call request of the simulated mock interface to the target interface so that the target system directly calls the target interface, wherein the prompt message indicates that the interface state of the target interface is the normal state; and if the interface state of the target interface is an abnormal state, sending a preset message to the target system. Therefore, the embodiment of the application can generate the simulated mock interface, send the verification request to the target interface through the simulated mock interface, determine the state of the target interface through the response information of the target interface, send the prompt message to the target system if the target interface is in a normal state when the target system calls the target interface, and transmit the call request of the simulated mock interface to the target interface, so that the target system directly calls the target interface, and send the abnormal information of the target interface to the target system if the target interface is in an abnormal state, thereby realizing timely calling of the available interface and improving the call efficiency of the interface.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for calling an interface according to an embodiment of the present application;
fig. 2 is a schematic device structure diagram of an interface calling device according to an embodiment of the present application.
Detailed Description
In order to facilitate understanding and explanation of the technical solutions provided by the embodiments of the present application, the following description will first describe terms and background techniques that may be related to the embodiments of the present application:
mock: mock is a method for creating a virtual object to simulate some objects which are not easy to construct or easy to acquire in the software development test process so as to carry out software development test.
Baffle system: and providing a mock functional platform for software development testers.
mock takes effect: and starting the mock as a service, and providing an interface return function for the outside.
In the software development test process, the mock tool or platform used by us generally has only the functions of creating, deleting, modifying, inquiring, scheduling and managing mock objects and the like. When the mock object is an api interface, the mock tool or platform typically does not have the functionality to be detected by simulating the actual availability of the mock interface. The analog mock interface of the api interface in the development test process can temporarily replace the function of the api interface under the condition that the initial test interface is not provided, thereby helping to perform primary verification on basic functions and flow. But the interface can not be directly replaced to carry out development test of the product, and when the actual api interface is available, the actual interface needs to be adjusted back to carry out functional verification.
In view of the functions and features of the existing mock tool or mock platform, the development tester typically knows the availability of the interface in a passive notification manner, and meanwhile, the development tester needs to manually switch the mock to the real-world object. Therefore, the existing interface mock tool or mock platform does not have an interface availability monitoring function, a development tester cannot know the availability of a mock interface in time, and after the mock interface is available, the development tester cannot automatically switch to an actual interface to continue the development test of software at the first time.
In order to solve the problems, the application provides the interface monitoring added in the mock process, which is beneficial to the software development and test personnel to know the availability condition of the mock interface in real time, informs the development and test personnel at the first time after the api interface is available, and automatically switches the analog mock interface to the actual api interface, so that the api interface can be called in time when the api interface is available, and the analog mock interface cannot be called all the time.
The technical scheme of the application is as follows:
the application provides an interface calling method, which comprises the steps of firstly obtaining target interface information, wherein the target interface information comprises an address of a target interface and a data input item of the target interface; generating a simulation mock interface corresponding to the target interface based on the address of the target interface and the data input item of the target interface; then, the analog mock interface can be utilized to send a verification request to the target interface; receiving response information of the target interface to the verification request; determining the interface state of the target interface according to the response information; responding to a call request of the simulated mock interface sent by a target system, if the interface state of the target interface is a normal state, sending a prompt message to the target system, and transmitting the call request of the simulated mock interface to the target interface so that the target system directly calls the target interface, wherein the prompt message indicates that the interface state of the target interface is the normal state; and if the interface state of the target interface is an abnormal state, sending a preset message to the target system. Therefore, the embodiment of the application can generate the simulated mock interface, send the verification request to the target interface through the simulated mock interface, determine the state of the target interface through the response information of the target interface, send the prompt message to the target system if the target interface is in a normal state when the target system calls the target interface, and transmit the call request of the simulated mock interface to the target interface, so that the target system directly calls the target interface, and send the abnormal information of the target interface to the target system if the target interface is in an abnormal state, thereby realizing timely calling of the available interface and improving the call efficiency of the interface.
In order to facilitate understanding of the technical solution provided by the embodiments of the present application, an interface calling method and apparatus provided by the embodiments of the present application are described below with reference to the accompanying drawings.
First, referring to fig. 1, a flowchart of a method for calling an interface according to an embodiment of the present application is shown, where the method specifically includes S101-S107.
S101: and acquiring target interface information, wherein the target interface information comprises an address of a target interface and a data input item of the target interface.
In this step, the information of the mock interface may be obtained first, where the obtained information includes at least an address of the mock interface and a data entry of the mock interface, where the mock interface is a called interface in the system B.
It can be understood that the information of the to-be-mock interface is pre-stored in the platform, or the platform can acquire the information of the to-be-mock interface from the to-be-mock interface information base, and the acquiring mode of the to-be-mock interface information is not specifically limited.
S102: and generating a simulated mock interface corresponding to the target interface based on the address of the target interface and the data input item of the target interface.
After the interface address of the mock interface and the data input item of the interface are acquired, an analog mock interface corresponding to the interface can be generated. It can be understood that when the analog mock interface is created, the address and the port of the mock interface are used as the attributes of the analog mock interface, namely, the address and the interface data input items of the mock interface are provided, so that the analog mock interface corresponding to the mock interface can be created.
S103: and sending a verification request to the target interface by using the analog mock interface.
After the analog mock interface is created, a verification request may be sent to the mock interface through the analog mock interface.
In this embodiment, it is required to determine whether the analog mock interface is called in a preset interface call period, and if the analog mock interface is called, send a verification request to the mock interface by using the analog mock interface. For example, the preset interface calling period is once a week, the system a calls the analog mock interface for a plurality of times in a week, at this time, the platform will send a verification request to the mock interface in the system B by using the analog mock interface, and if the analog mock interface is not called in the preset interface calling period, the analog mock interface is marked as an unusual interface.
S104: and receiving response information of the target interface to the verification request.
The mock interface feeds back a response message to the platform after receiving the verification request.
S105: and determining the interface state of the target interface according to the response information.
The platform can determine whether the interface state of the mock interface is a normal state or an abnormal state according to the received corresponding information.
In this embodiment, a preset rule may be used to verify the availability of an actual interface, that is, a mock interface, send preset interface request information to the actual interface and obtain interface return information, compare the return information with return information when the interface input when the interface definition of the mock interface is normal, and consider that the mock interface is available if the comparison is consistent. The scanned object, namely the object sending the request information, is a baffle (a mock interface) which is in effect in the system, and the scanning mode is that a message is sent to an actual interface through a normal process.
That is, when the response information fed back to the platform by the mock interface is a message, the platform judges whether the message fed back by the mock interface is the same as a preset and stored verification message in the platform, if the message is the same as the preset verification message, the interface state of the mock interface can be determined to be a normal state, and if the message is different from the preset verification message, the interface state of the mock interface can be determined to be an abnormal state. It should be noted that, the authentication message stored in advance in the platform may be a message fed back when the mock interface is in a normal state and receives the message.
In an alternative embodiment, when the response information fed back to the platform by the mock interface is interface exception information, the platform may directly determine that the interface state of the mock interface is an exception state based on the interface exception information.
Further, when the interface state of the mock interface is an abnormal state, the platform may store the response information of the mock interface, the verification request sent by the analog mock interface, and the interface state of the mock interface in the target database or in the log file.
S106: responding to a call request of the simulated mock interface sent by a target system, if the interface state of the target interface is a normal state, sending a prompt message to the target system, and transmitting the call request of the simulated mock interface to the target interface so that the target system directly calls the target interface, wherein the prompt message indicates that the interface state of the target interface is the normal state.
In an alternative embodiment, if the received analog mock interface call request sent by the system a is a normal state, the platform sends a prompt message to the system a, and sends the call request for the analog mock interface to the mock interface in a transparent manner, after the system a receives the prompt message, the system a can directly call the mock interface because the mock interface is in the normal state.
That is, during the system development test, when some external interfaces or internal interfaces of the system have not completed development or are abnormal (such as that after the request is released from the interfaces, the information returned by the interfaces is inconsistent with the pre-agreed information, etc.), we will generally create a simulated mock interface and start the simulated mock interface to replace the abnormal interface. When the platform verifies that the mock interface is in an available state, namely, the interface state is in a normal state, the analog mock interface corresponding to the mock interface is accessed by other systems or services again, and at the moment, related data is not returned through the analog mock interface as usual, the platform can send a request message to an actual interface, and the sending mode is transparent transmission, namely, the request message and the format are not changed, and the request message is directly sent to the actual interface (the mock interface).
S107: and responding to a call request of the simulated mock interface sent by a target system, and if the interface state of the target interface is an abnormal state, sending a target interface abnormal message to the target system.
If the simulation mock interface call request sent by the system A is received, at this time, if the interface state of the mock is abnormal, the platform will send an interface abnormal message to the system A.
As can be seen from the relevant content of S101-S107, the embodiment of the present application may generate a mock interface, send a verification request to a target interface through the mock interface, determine the state of the target interface through response information of the target interface, send a prompt message to the target system if the target interface is in a normal state when the target system calls the target interface, and transparently transmit a call request of the mock interface to the target interface, so that the target system directly calls the target interface, and send a target interface exception message to the target system if the target interface is in an abnormal state, thereby realizing timely call to an available interface and improving call efficiency of the interface.
It should be noted that the method, the device, the apparatus and the readable storage medium for calling an interface provided by the present application may be used in the financial field or other fields, and the above is merely an example, and the application field of the method, the device, the apparatus and the readable storage medium for calling an interface provided by the present application is not limited.
Corresponding to the method shown in fig. 1, the embodiment of the present application further provides an interface calling device, which is used for implementing the method shown in fig. 1, where the interface calling device provided in the embodiment of the present application may be applied to a computer terminal or various mobile devices, and the structural schematic diagram of the interface calling device is shown in fig. 2, and the interface calling device specifically includes:
an obtaining module 201, configured to obtain target interface information, where the target interface information includes an address of a target interface and a data entry of the target interface;
a generating module 202, configured to generate an analog mock interface corresponding to the target interface based on an address of the target interface and a data entry of the target interface;
a first sending module 203, configured to send a verification request to the target interface by using the analog mock interface;
a receiving module 204, configured to receive response information of the target interface to the verification request;
a determining module 205, configured to determine an interface state of the target interface according to the response information;
a calling module 206, configured to respond to a call request of the mock interface sent by a target system, if an interface state of the target interface is a normal state, send a prompt message to the target system, and transparently transmit the call request of the mock interface to the target interface, so that the target system directly calls the target interface, where the prompt message indicates that the interface state of the target interface is the normal state;
the second sending module 207 is configured to send a target interface exception message to the target system if the interface state of the target interface is an exception state in response to receiving a call request of the mock interface sent by the target system.
In one possible implementation manner, the first sending module 203 is specifically configured to:
judging whether the analog mock interface is called in a preset interface calling period;
and if the simulated mock interface is called, sending a verification request to the target interface by using the simulated mock interface.
In one possible implementation manner, the response information is a target message, and the determining module 205 is specifically configured to:
judging whether the target message is identical to a preset verification message or not;
if the target message is the same as the preset verification message, determining that the interface state of the target interface is a normal state;
and if the target message is different from the preset verification message, determining that the interface state of the target interface is an abnormal state.
In one possible implementation manner, the response information is interface abnormality information, and the determining module 205 is specifically configured to:
and determining the interface state of the target interface as an abnormal state based on the interface abnormal message.
In one possible implementation, the apparatus further includes: a storage module;
and the storage module is used for storing the response information, the verification request and the interface state in a target database if the interface state of the target interface is an abnormal state.
Based on the interface calling method provided by the embodiment of the method, the application provides interface calling equipment, which comprises the following steps: a processor and a memory;
the memory is used for storing one or more programs;
the processor is configured to implement an interface calling method according to any of the above embodiments when the one or more programs are executed by the processor.
Based on the interface calling method provided by the embodiment of the method, the application provides a computer readable storage medium, wherein the computer readable storage medium stores instructions, and when the instructions run on a device, the instructions cause the device to execute the interface calling method according to any one of the embodiments.
It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
It is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

CN202310802312.3A2023-06-302023-06-30Interface calling method, device, equipment and readable storage mediumPendingCN116841884A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202310802312.3ACN116841884A (en)2023-06-302023-06-30Interface calling method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202310802312.3ACN116841884A (en)2023-06-302023-06-30Interface calling method, device, equipment and readable storage medium

Publications (1)

Publication NumberPublication Date
CN116841884Atrue CN116841884A (en)2023-10-03

Family

ID=88166446

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202310802312.3APendingCN116841884A (en)2023-06-302023-06-30Interface calling method, device, equipment and readable storage medium

Country Status (1)

CountryLink
CN (1)CN116841884A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN118860895A (en)*2024-08-122024-10-29广州三七极耀网络科技有限公司 A testing method, device, storage medium and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN118860895A (en)*2024-08-122024-10-29广州三七极耀网络科技有限公司 A testing method, device, storage medium and electronic equipment
CN118860895B (en)*2024-08-122025-04-22广州三七极耀网络科技有限公司Test method and device, storage medium and electronic equipment

Similar Documents

PublicationPublication DateTitle
US6891929B2 (en)Automated and integrated call control server
CN113268336B (en)Service acquisition method, device, equipment and readable medium
CN108134708B (en)Method and device for monitoring third-party interface
CN112491654B (en)Performance test method and device, electronic equipment and storage medium
CN110908708B (en) A code publishing method, device and system
CN111010527A (en)Method and related device for establishing video call through short message link
CN111158661A (en)System interface docking method, device, medium and electronic equipment
CN116841884A (en)Interface calling method, device, equipment and readable storage medium
CN114390457B (en)Short message verification method, device, equipment and storage medium
CN113342595B (en)Gray scale verification method, device, equipment and storage medium
CN103312554A (en)Testing method and system of multi-server interactive services
CN111382062A (en)Joint debugging test method and device for house property transaction system and external mechanism business system
CN112561690B (en)Method, system, equipment and storage medium for testing credit card staged service interface
CN112073462A (en)Positioning method and device
CN119201669A (en) Business service status detection method and device, electronic device, and storage medium
CN108377357B (en)Visual platform call method and device
CN103152216A (en)System test method and device in internet
CN114666116B (en)Authentication processing method, device, equipment and storage medium based on applet
CN115729793A (en)Kafka performance test system and method for vehicle OTA
CN119211332A (en)Service microinstruction issuing method, device, equipment and medium
CN112612700B (en)Interface testing method and device and electronic equipment
CN116204439A (en)Method and device for testing coverage of full-link service scene
CN110990275B (en)Page display test method and device for mobile banking
CN115276844A (en)Communication module testing method and device and electronic equipment
CN114897573A (en)Commodity information processing method and device, readable medium and electronic equipment

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp