CN111143087B - Interface calling method, device, storage medium and server - Google Patents

Interface calling method, device, storage medium and server Download PDF

Info

Publication number
CN111143087B
CN111143087B CN201911307771.4A CN201911307771A CN111143087B CN 111143087 B CN111143087 B CN 111143087B CN 201911307771 A CN201911307771 A CN 201911307771A CN 111143087 B CN111143087 B CN 111143087B
Authority
CN
China
Prior art keywords
type
parameter
service
interface
request
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.)
Active
Application number
CN201911307771.4A
Other languages
Chinese (zh)
Other versions
CN111143087A (en
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN201911307771.4A priority Critical patent/CN111143087B/en
Publication of CN111143087A publication Critical patent/CN111143087A/en
Application granted granted Critical
Publication of CN111143087B publication Critical patent/CN111143087B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application is suitable for the technical field of computers and provides an interface calling method, an interface calling device, a storage medium and a server. The method comprises the following steps: acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter; analyzing the interface call request to obtain the request parameters, and converting the types of the request parameters into preset types; constructing a data acquisition command based on the request parameters of the preset type; converting the data acquisition command into a data flow instruction which can be identified by a service system through a RestTemplite; the data flow instruction is sent to a service system pointed by the interface address, and the service system is instructed to return the service parameters of the generic type; receiving the service parameters of the generic type returned by the service system; converting the type of the service parameter from a generic type to the type of the return parameter; outputting the service parameters after the type conversion. By adopting the method, the workload of calling related processing logic by the development interface can be reduced.

Description

Interface calling method, device, storage medium and server
Technical Field
The application belongs to the technical field of computers, and particularly relates to an interface calling method, an interface calling device, a storage medium and a server.
Background
Currently, when a user terminal calls an interface of each service system through server docking, a developer is usually required to develop a set of corresponding data processing logic for each different interface call request at the server side. For example, each interface call request may include information such as different interface addresses, request parameters (in parameters) and return parameters (out parameters), so that developers need to develop different data processing logic for different request parameter types, and the workload is huge.
Disclosure of Invention
In view of this, the present application proposes an interface calling method, which can greatly reduce the workload of a developer when developing the processing logic related to interface call.
In a first aspect, an embodiment of the present application provides an interface calling method, including:
acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
analyzing the interface call request to obtain the request parameters, and converting the types of the request parameters into preset types;
constructing a data acquisition command based on the request parameters of the preset type;
converting the data acquisition command into a data flow instruction which can be identified by a service system through a RestTemplite;
the data flow instruction is sent to a service system pointed by the interface address, and the service system is instructed to return the service parameters of the generic type;
receiving the service parameters of the generic type returned by the service system;
converting the type of the service parameter from a generic type to the type of the return parameter;
outputting the service parameters after the type conversion.
The above process converts the request parameters of the interface call request into the same preset type, such as the base class Object type which can be an Object, and uses the RestTemplite to set the type of the service system return parameters as the generic type, so that the developer only needs to develop a data processing logic aiming at the input parameters of the preset type and the output parameters of the generic type, and the workload of development is greatly reduced.
Further, the sending the data flow instruction to the service system pointed to by the interface address may include:
determining a service address to be accessed in a service system pointed by the interface address according to the request parameter;
and sending the data flow instruction to the service address.
Since a service system may contain a plurality of different functional modules, i.e. have a plurality of different service addresses (domain names), the service address of the service system to be accessed may be determined by the request parameters contained in the interface call request before sending the data flow instruction.
Further, before sending the data flow instruction to the service address, the method may further include:
performing validity verification on the interface call request through Base RestTemplate;
if the validity verification is passed, executing the step of sending the data flow instruction to the service address and the subsequent steps;
and if the validity verification is not passed, rejecting the interface calling request and outputting prompt information of verification failure.
The Base RestTemplate is used for executing a self-defined verification processing process, so that whether an interface call request initiated by a user terminal passes verification or not can be judged, whether the user terminal has legal authority for accessing the service address or not can be judged, and if the user terminal passes the verification, the subsequent data access operation can be executed; if the verification fails, an illegal interface call request is initiated, the interface call process is terminated, and prompt information of verification failure is output, for example, the request initiated by you fails the verification and is refused by the server. By the arrangement, the safety and standardization of the interface calling process can be improved.
Further, after converting the type of the service parameter from the generic type to the type of the return parameter, the method may further include:
if the type conversion of the service parameters is successful, executing the step of outputting the service parameters after the type conversion;
and if the type conversion of the service parameters fails, outputting prompt information of abnormal parameter types.
In actual operation, due to various reasons such as error configuration of a service address, error definition of a type of a return parameter set by an interface call request, error data returned by a service system, and the like, the type conversion process of the service parameter may be wrong, so that conversion failure is caused, and prompt information of 'abnormal type of the return parameter' can be output at the moment.
Further, if the type conversion of the service parameter fails, the method may further include:
discarding the service parameters of the generic type;
after a preset period of time, returning to the step of constructing a data acquisition command based on the request parameters of the predetermined type.
The reasons for the parameter type conversion failure may be a service address configuration error, the service system returns error data and the like, so after the parameter type conversion failure, a certain time can be waited, then a step of constructing a data acquisition command based on the predetermined type request parameter is returned, the service address is redetermined, and a new parameter is acquired by the docking service system again, so that the problem of the parameter type conversion failure caused by the reasons of the service address or the service system is solved.
Further, if the type conversion of the service parameter fails, the method may further include:
acquiring parameter values of the service parameters;
determining a target parameter type according to the parameter value, wherein the target parameter type is a parameter type compatible with the parameter value;
converting the type of the service parameter from a generic type to the target parameter type;
and outputting the business parameters of the target parameter types.
The reason for the failure of the conversion of the parameter type may be that the type of the return parameter set by the interface call request is defined incorrectly, for example, the parameter value character "text" returned by the service system is correct, and the return parameter set by the interface call request is defined incorrectly as a digital type, so that the "text" cannot be converted into the digital type. For this case, a parameter type compatible with the character "text" such as a string type may be determined, and then the type of the "text" may be converted from a generic type to a string type and the parameters after the type conversion may be output. By doing so, the problem of parameter type conversion failure can be solved.
Further, the service parameters after the output type conversion may include:
if the interface calling request is sent by a user terminal, the service parameters after type conversion are sent to the user terminal;
and if the interface calling request is sent by a timing task of a system background, displaying the service parameters after type conversion in a preset interface.
The sending main body of the interface call request can be a user terminal or a timing task set by a system background. If the interface calling request is sent by the user terminal, the service parameters after the type conversion are sent to the user terminal, and the interface calling process is completed once. If the interface call request is sent by a timing task of the system background, the service parameters after the type conversion can be displayed in a preset interface of the server so as to check the acquired service parameters.
In a second aspect, an embodiment of the present application provides an interface calling device, including:
the request acquisition module is used for acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
the parameter entering type conversion module is used for analyzing the interface call request to obtain the request parameters and converting the types of the request parameters into preset types;
a data acquisition command construction module for constructing a data acquisition command based on the predetermined type of request parameter;
the data stream command conversion module is used for converting the data acquisition command into a data stream command which can be identified by the service system through a RestTemplite;
the data stream instruction sending module is used for sending the data stream instruction to the service system pointed by the interface address and indicating the service system to return the service parameters of the generic type;
the service parameter receiving module is used for receiving the service parameters of the generic type returned by the service system;
the parameter-outputting type conversion module is used for converting the type of the service parameter from the generic type to the type of the return parameter;
and the parameter output module is used for outputting the service parameters after the type conversion.
In a third aspect, embodiments of the present application provide a computer readable storage medium storing a computer program, which when executed by a processor implements an interface calling method as set forth in the first aspect of embodiments of the present application.
In a fourth aspect, an embodiment of the present application provides a server, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements an interface calling method as set forth in the first aspect of the embodiment of the present application when the processor executes the computer program.
In a fifth aspect, embodiments of the present application provide a computer program product, which when run on a terminal device, causes the terminal device to perform the interface invoking method according to the first aspect.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required for the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a first embodiment of an interface invocation method provided by an embodiment of the present application;
FIG. 2 is a flow chart of a second embodiment of an interface invocation method provided by an embodiment of the present application;
FIG. 3 is a flow chart of a third embodiment of an interface invocation method provided by an embodiment of the present application;
FIG. 4 is a block diagram of one embodiment of an interface call device provided by an embodiment of the present application;
fig. 5 is a schematic diagram of a server according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail. In addition, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
The interface calling method can greatly reduce the workload of a developer when the developer calls related processing logic in the development of the interface.
Referring to fig. 1, a first embodiment of an interface calling method in an embodiment of the present application includes:
101. acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
in this embodiment of the present application, the execution body of each step is a server, and the server may obtain an interface call request, where the request may be sent by a user terminal, or may be sent by a timing task set by a server background system.
When the user terminal wants to access the interface for calling a certain service system and acquire corresponding data, firstly, an interface calling request is sent to the server, wherein the interface calling request comprises the interface address of the service system to be accessed, and the related information of the request parameters (i.e. the in-parameters) and the return parameters (i.e. the out-parameters) is requested. The request parameters and the return parameters contain information of fields, descriptions, types, remarks, whether to fill in or not, and the like, wherein the fields are attributes of classes, the descriptions are Chinese paraphrasing, and the types are attribute types, such as String, number, object, array, int, and the like. In addition, the developer can set a timing task in a background system of the server and send an interface call request at fixed time. The call between service systems is not limited to the call initiated by the user terminal, and the background system can also generate the call of the interface between the cross systems by self timing task trigger.
102. Analyzing the interface call request to obtain the request parameters, and converting the types of the request parameters into preset types;
after the server obtains the interface call request, the server analyzes the interface call request to obtain the request parameter, and converts the type of the request parameter into a preset type. Different interface call requests have different types of request parameters, and the server uniformly converts the different types of request parameters into the same predetermined type. Specifically, the predetermined type may be a base class Object type of an Object, an Object class is a special class, is a parent class of all classes, if a class does not explicitly indicate inheritance to a certain class by extensions, it inherits the Object class by default, and a variable of type Object may be used to point to an Object of any type. Therefore, the Object class can accommodate all types of entries, serialization of the Object class during network transmission is completely satisfied with other classes, and various interfaces can be supported by setting the entry as the Object class. In practice, the polymorphic concept may be used to translate request parameters into Object types.
103. Constructing a data acquisition command based on the request parameters of the preset type;
the server then constructs a data acquisition command based on the predetermined type of request parameters, which is sent to the service system for requesting and acquiring the corresponding service parameters.
104. Converting the data acquisition command into a data flow instruction which can be identified by a service system through a RestTemplite;
part of the service system may not be able to directly recognize the data acquisition command, so the server may convert the data acquisition command into a data stream instruction recognizable by the service system through the RestTemplate. The RestTemplate is a tool provided by Spring for accessing the Rest service, and provides a plurality of methods for conveniently accessing the remote Http service.
105. The data flow instruction is sent to a service system pointed by the interface address, and the service system is instructed to return the service parameters of the generic type;
after converting the data acquisition command into a data flow command identifiable by the service system, the server sends the data flow command to the service system pointed by the interface address, and instructs the service system to return the service parameters of the generic type. Specifically, the type of the service system return parameter can be set to be generic through the RestTemplate. The generic type is "parameterized type", and the parameters mentioned are the most familiar parameters when defining a method, and then the parameters are passed on when invoking the method. Parameterized types are those in which a type is parameterized from an original specific type, similar to the variable parameters in a method, and at this time the type is also defined as a parametric form (which may be called a type-shape parameter), and then a specific type (type-real parameter) is entered at the time of use/invocation.
106. Receiving the service parameters of the generic type returned by the service system;
after receiving the data stream command, the service system invokes the corresponding service parameter based on the data stream command and then sends the service parameter to the server. In addition, since the server has previously set the type of the service system return parameter to be generic, the type of the service parameter is generic.
107. Converting the type of the service parameter from a generic type to the type of the return parameter;
after receiving the service parameters of the generic type returned by the service system, the server converts the type of the service parameters from generic type to the type of the returned parameters. For example, the parameter required to be returned by the interface call request is a string type parameter, and the service system returns a service parameter generalized to a type A, so that the server can convert the service parameter of the type A into the string type, thereby meeting the requirement of the interface call request.
108. Outputting the service parameters after the type conversion.
And finally, the server outputs the service parameters after the type conversion to finish the process of one-time interface calling.
Further, step 108 may include:
if the interface calling request is sent by a user terminal, the service parameters after type conversion are sent to the user terminal;
and if the interface calling request is sent by a timing task of a system background, displaying the service parameters after type conversion in a preset interface.
The sending main body of the interface call request can be a user terminal or a timing task set by a system background. If the interface calling request is sent by the user terminal, the service parameters after the type conversion are sent to the user terminal, and the interface calling process is completed once. If the interface call request is sent by a timing task of the system background, the service parameters after the type conversion can be displayed in a preset interface of the server so as to check the acquired service parameters.
In the embodiment of the application, the request parameters of the interface call request are converted into the same preset type, such as the base class Object type which can be an Object, and the type of the service system return parameters is set to be generic by using the RestTemplite, so that a developer only needs to develop a data processing logic aiming at the input parameters of the preset type and the output parameters of the generic type, and the development workload is greatly reduced.
Referring to fig. 2, a second embodiment of an interface calling method in the embodiments of the present application includes:
201. acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
202. analyzing the interface call request to obtain the request parameters, and converting the types of the request parameters into preset types;
203. constructing a data acquisition command based on the request parameters of the preset type;
204. converting the data acquisition command into a data flow instruction which can be identified by a service system through a RestTemplite;
steps 201-204 are identical to steps 101-104, and reference is made specifically to the description of steps 101-104.
205. Determining a service address to be accessed in a service system pointed by the interface address according to the request parameter;
before the data flow instruction is sent to the service system, the service address to be accessed in the service system pointed by the interface address is determined according to the request parameter. Since a service system may contain a plurality of different functional modules, i.e. have a plurality of different service addresses (domain names), it is also necessary to determine the service address of the service system to be accessed by means of the request parameters contained in the interface call request before sending the data flow instruction. Specifically, a default constructor of the RestTemplate may be called, and the object may create an Http request at the bottom layer by using a java.
206. Performing validity verification on the interface call request through Base RestTemplate;
a custom authentication process is performed using Base RestTemplate to determine whether the interface call request initiated by the user terminal passes authentication and has legal rights to access the service address.
207. Judging whether the validity verification is passed or not;
if the validity verification is passed, executing steps 209-212; if the validity verification is not passed, step 208 is performed.
208. Rejecting the interface calling request and outputting prompt information of verification failure;
the validity verification fails, which indicates that an illegal interface call request is initiated, and the interface call process is refused, and a prompt message of verification failure is output, for example, "the request initiated by you fails verification and has been refused by the server". By the arrangement, the safety and standardization of the interface calling process can be improved.
209. Sending the data flow instruction to the service address and indicating the service system to return the service parameters of the generic type;
and the validity verification passes, which indicates that a legal interface call request is initiated, and the data flow instruction is sent to the service address at the moment and indicates the service system to return the service parameters of the generic type.
210. Receiving the service parameters of the generic type returned by the service system;
211. converting the type of the service parameter from a generic type to the type of the return parameter;
212. outputting the service parameters after the type conversion.
Specific details of steps 209-212 may be found in steps 105-108.
In the embodiment of the application, on one hand, the service address to be accessed in the service system pointed by the interface address is determined according to the request parameter, so that the data stream instruction is accurately sent to the corresponding service address of the service system; on the other hand, validity verification is performed on the interface call request through Base RestTemplate, so that the safety and standardization of interface call processing can be improved.
Referring to fig. 3, a third embodiment of an interface calling method in the embodiments of the present application includes:
301. acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
302. analyzing the interface call request to obtain the request parameters, and converting the types of the request parameters into preset types;
303. constructing a data acquisition command based on the request parameters of the preset type;
304. converting the data acquisition command into a data flow instruction which can be identified by a service system through a RestTemplite;
305. the data flow instruction is sent to a service system pointed by the interface address, and the service system is instructed to return the service parameters of the generic type;
306. receiving the service parameters of the generic type returned by the service system;
307. converting the type of the service parameter from a generic type to the type of the return parameter;
for a detailed description of steps 301-307, reference may be made to steps 101-107.
308. Judging whether the type conversion of the service parameters is successful or not;
if the type conversion of the service parameter is successful, step 309 is executed; if the type conversion of the service parameter fails, step 310 is performed.
309. Outputting the service parameters after the type conversion;
310. and outputting prompt information of abnormal parameter types.
In actual operation, the parameter type conversion process of step 307 may be in error due to various reasons such as service address configuration errors, type definition errors of the return parameters set by the interface call request, and data errors returned by the service system itself, which may cause conversion failure. For example, the parameter value returned by the service system is a character "text", the interface call request requires a sales amount to be returned, the type is a number, and the system can report errors and fails to convert the parameter type because the type of a character cannot be converted into the number, and at the moment, prompt information of "return parameter type abnormality" can be output.
Further, if the type conversion of the service parameter fails, the method may further include:
(1) Discarding the service parameters of the generic type;
(2) After a preset period of time, returning to the step of constructing a data acquisition command based on the request parameters of the predetermined type.
The reasons for the parameter type conversion failure may be a service address configuration error, the service system returns error data and the like, so after the parameter type conversion failure, a certain time can be waited, then a step of constructing a data acquisition command based on the predetermined type request parameter is returned, the service address is redetermined, and a new parameter is acquired by the docking service system again, so that the problem of the parameter type conversion failure caused by the reasons of the service address or the service system is solved.
Further, if the type conversion of the service parameter fails, the method may further include:
(1) Acquiring parameter values of the service parameters;
(2) Determining a target parameter type according to the parameter value, wherein the target parameter type is a parameter type compatible with the parameter value;
(3) Converting the type of the service parameter from a generic type to the target parameter type;
(4) And outputting the business parameters of the target parameter types.
The reason for the failure of the conversion of the parameter type may be that the type of the return parameter set by the interface call request is defined incorrectly, for example, the parameter value character "text" returned by the service system is correct, and the return parameter set by the interface call request is defined incorrectly as a digital type, so that the "text" cannot be converted into the digital type. For this case, a parameter type compatible with the character "text" such as a string type may be determined, and then the type of the "text" may be converted from a generic type to a string type and the parameters after the type conversion may be output. Through the operation, the problem of parameter type conversion failure can be effectively solved.
In this embodiment of the present application, after converting the type of the service parameter from generic type to the type of the return parameter, it is determined whether the type conversion process of the service parameter is successful, if so, the service parameter after type conversion is output, and if not, the prompt message of abnormal parameter type is output. Aiming at the special situation that the parameter type is likely to fail in conversion, corresponding processing measures are formulated in the embodiment of the application, so that the practicability and the stability of the interface calling method are further improved.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
Corresponding to the interface calling method described in the above embodiments, fig. 4 shows a block diagram of the structure of the interface calling device provided in the embodiment of the present application, and for convenience of explanation, only the portion relevant to the embodiment of the present application is shown.
Referring to fig. 4, the apparatus includes:
a request acquisition module 401, configured to acquire an interface call request, where the interface call request includes an interface address, a request parameter, and a return parameter;
a parameter-entering type conversion module 402, configured to parse the interface call request to obtain the request parameter, and convert the type of the request parameter into a predetermined type;
a data acquisition command construction module 403, configured to construct a data acquisition command based on the predetermined type of request parameter;
a data stream command conversion module 404, configured to convert the data acquisition command into a data stream command identifiable by the service system through a RestTemplate;
a data flow instruction sending module 405, configured to send the data flow instruction to a service system pointed by the interface address, and instruct the service system to return a service parameter of a generic type;
a service parameter receiving module 406, configured to receive a generic type of service parameter returned by the service system;
a parameter-out type conversion module 407, configured to convert the type of the service parameter from generic type to the type of the return parameter;
and the parameter output module 408 is configured to output the service parameter after the type conversion.
Further, the data flow instruction sending module may include:
the service address determining unit is used for determining a service address to be accessed in the service system pointed by the interface address according to the request parameter;
and the data stream instruction sending unit is used for sending the data stream instruction to the service address.
Further, the interface calling device may further include:
the validity verification module is used for executing validity verification on the interface call request through Base RestTemplate;
a request permission module, configured to execute a step of sending the data flow instruction to the service address and a subsequent step if the validity verification is passed;
and the request rejecting module is used for rejecting the interface calling request and outputting prompt information of verification failure if the validity verification is not passed.
Further, the interface calling device may further include:
the conversion success execution module is used for executing the step of outputting the service parameters after the type conversion if the type conversion of the service parameters is successful;
and the prompt information output module is used for outputting prompt information of abnormal parameter type if the type conversion of the service parameter fails.
Further, the interface calling device may further include:
the parameter discarding module is used for discarding the service parameters of the generic type;
and the step returning module is used for returning to the step of constructing the data acquisition command based on the request parameters of the preset type after the preset duration.
Further, the interface calling device may further include:
the parameter value acquisition module is used for acquiring the parameter value of the service parameter;
the target type determining module is used for determining a target parameter type according to the parameter value, wherein the target parameter type is a parameter type compatible with the parameter value;
the target type conversion module is used for converting the type of the service parameter from the generic type into the target parameter type;
and the target type parameter output module is used for outputting the service parameters of the target parameter types.
Further, the parameter output module may include:
the first output unit is used for sending the service parameters after type conversion to the user terminal if the interface calling request is sent by the user terminal;
and the second output unit is used for displaying the service parameters after type conversion in a preset interface if the interface calling request is sent by a timing task of a system background.
Embodiments of the present application also provide a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement steps of any one of the interface invocation methods as represented in fig. 1-3.
The present embodiments also provide a computer program product which, when run on a server, causes the server to perform the steps of implementing any one of the interface invocation methods as represented in fig. 1-3.
The embodiment of the application further provides a server, which comprises a memory, a processor and computer readable instructions stored in the memory and capable of running on the processor, wherein the steps of any one of the interface calling methods shown in fig. 1 to 3 are realized when the processor executes the computer readable instructions.
Fig. 5 is a schematic diagram of a server according to an embodiment of the present application. As shown in fig. 5, the server 5 of this embodiment includes: a processor 50, a memory 51, and computer readable instructions 52 stored in the memory 51 and executable on the processor 50. The processor 50, when executing the computer-readable instructions 52, implements the steps of the various interface invocation method embodiments described above, such as steps 101 through 108 shown in fig. 1. Alternatively, the processor 50, when executing the computer readable instructions 52, performs the functions of the modules/units of the apparatus embodiments described above, such as the functions of modules 401 through 408 shown in fig. 4.
For example, the computer readable instructions 52 may be partitioned into one or more modules/units that are stored in the memory 51 and executed by the processor 50 to complete the present application. The one or more modules/units may be a series of computer readable instruction segments capable of performing a specific function describing the execution of the computer readable instructions 52 in the server 5.
The server 5 may be a computing device such as a smart phone, a notebook, a palm computer, a cloud server, etc. The server 5 may include, but is not limited to, a processor 50, a memory 51. It will be appreciated by those skilled in the art that fig. 5 is merely an example of the server 5 and is not meant to be limiting of the server 5, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the server 5 may also include input and output devices, network access devices, buses, etc.
The processor 50 may be a central processing unit (CentraL Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DigitaL SignaL Processor, DSP), application specific integrated circuits (AppLication Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (fierld-ProgrammabLe Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 51 may be an internal storage unit of the server 5, for example, a hard disk or a memory of the server 5. The memory 51 may be an external storage device of the server 5, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure DigitaL (SD) Card, a FLash Card (FLash Card) or the like, which are provided on the server 5. Further, the memory 51 may also include both an internal storage unit and an external storage device of the server 5. The memory 51 is used to store the computer readable instructions and other programs and data required by the server. The memory 51 may also be used to temporarily store data that has been output or is to be output.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application implements all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing device/terminal apparatus, recording medium, computer Memory, read-Only Memory (ROM), random access Memory (RAM, random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (5)

1. An interface calling method, comprising:
acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
analyzing the interface call request to obtain the request parameters, and converting the types of the request parameters into preset types;
constructing a data acquisition command based on the request parameters of the preset type;
converting the data acquisition command into a data flow instruction which can be identified by a service system through a RestTemplite;
the data flow instruction is sent to a service system pointed by the interface address, and the service system is instructed to return the service parameters of the generic type;
receiving the service parameters of the generic type returned by the service system;
converting the type of the service parameter from a generic type to the type of the return parameter;
outputting the service parameters after the type conversion;
wherein the sending the data flow instruction to the service system pointed by the interface address includes:
determining a service address to be accessed in a service system pointed by the interface address according to the request parameter;
sending the data flow instruction to the service address;
before sending the data flow instruction to the service address, further comprising:
performing validity verification on the interface call request through Base RestTemplate;
if the validity verification is passed, executing the step of sending the data flow instruction to the service address and the subsequent steps;
if the validity verification is not passed, rejecting the interface calling request and outputting prompt information of verification failure;
after converting the type of the service parameter from the generic type to the type of the return parameter, the method further comprises:
if the type conversion of the service parameters is successful, executing the step of outputting the service parameters after the type conversion;
if the type conversion of the service parameters fails, outputting prompt information of abnormal parameter types;
if the type conversion of the service parameter fails, the method further comprises:
discarding the service parameters of the generic type;
after a preset time length, returning to the step of constructing a data acquisition command based on the request parameters of the preset type;
if the type conversion of the service parameter fails, the method further comprises:
acquiring parameter values of the service parameters;
determining a target parameter type according to the parameter value, wherein the target parameter type is a parameter type compatible with the parameter value;
converting the type of the service parameter from a generic type to the target parameter type;
and outputting the business parameters of the target parameter types.
2. The interface invocation method of claim 1, wherein the traffic parameter after the output type conversion comprises:
if the interface calling request is sent by a user terminal, the service parameters after type conversion are sent to the user terminal;
and if the interface calling request is sent by a timing task of a system background, displaying the service parameters after type conversion in a preset interface.
3. An interface calling device, comprising:
the request acquisition module is used for acquiring an interface call request, wherein the interface call request comprises an interface address, a request parameter and a return parameter;
the parameter entering type conversion module is used for analyzing the interface call request to obtain the request parameters and converting the types of the request parameters into preset types;
a data acquisition command construction module for constructing a data acquisition command based on the predetermined type of request parameter;
the data stream command conversion module is used for converting the data acquisition command into a data stream command which can be identified by the service system through a RestTemplite;
the data stream instruction sending module is used for sending the data stream instruction to the service system pointed by the interface address and indicating the service system to return the service parameters of the generic type;
the service parameter receiving module is used for receiving the service parameters of the generic type returned by the service system;
the parameter-outputting type conversion module is used for converting the type of the service parameter from the generic type to the type of the return parameter;
the parameter output module is used for outputting the service parameters after the type conversion;
wherein, the data flow instruction sending module comprises:
the service address determining unit is used for determining a service address to be accessed in the service system pointed by the interface address according to the request parameter;
a data stream instruction sending unit, configured to send the data stream instruction to the service address;
the interface calling device further comprises:
the validity verification module is used for executing validity verification on the interface call request through Base RestTemplate;
a request permission module, configured to execute a step of sending the data flow instruction to the service address and a subsequent step if the validity verification is passed;
the request rejecting module is used for rejecting the interface calling request and outputting prompt information of verification failure if the validity verification is not passed;
the interface calling device further comprises:
the conversion success execution module is used for executing the step of outputting the service parameters after the type conversion if the type conversion of the service parameters is successful;
the prompt information output module is used for outputting prompt information of abnormal parameter type if the type conversion of the service parameter fails;
the interface calling device further comprises:
the parameter discarding module is used for discarding the service parameters of the generic type;
the step return module is used for returning to the step of constructing a data acquisition command based on the request parameters of the preset type after the preset duration;
the interface calling device further comprises:
the parameter value acquisition module is used for acquiring the parameter value of the service parameter;
the target type determining module is used for determining a target parameter type according to the parameter value, wherein the target parameter type is a parameter type compatible with the parameter value;
the target type conversion module is used for converting the type of the service parameter from the generic type into the target parameter type;
and the target type parameter output module is used for outputting the service parameters of the target parameter types.
4. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the interface invoking method according to claim 1 or 2.
5. A server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the interface invocation method of claim 1 or 2 when executing the computer program.
CN201911307771.4A 2019-12-18 2019-12-18 Interface calling method, device, storage medium and server Active CN111143087B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911307771.4A CN111143087B (en) 2019-12-18 2019-12-18 Interface calling method, device, storage medium and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911307771.4A CN111143087B (en) 2019-12-18 2019-12-18 Interface calling method, device, storage medium and server

Publications (2)

Publication Number Publication Date
CN111143087A CN111143087A (en) 2020-05-12
CN111143087B true CN111143087B (en) 2024-04-02

Family

ID=70518724

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911307771.4A Active CN111143087B (en) 2019-12-18 2019-12-18 Interface calling method, device, storage medium and server

Country Status (1)

Country Link
CN (1) CN111143087B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858498A (en) * 2020-07-31 2020-10-30 北京金山云网络技术有限公司 Storage type conversion method, system, device and equipment
CN112015496B (en) * 2020-09-01 2022-11-15 中国平安财产保险股份有限公司 Interface calling method and device, computer equipment and storage medium
CN112153152A (en) * 2020-09-28 2020-12-29 深圳壹账通智能科技有限公司 Management method and system of algorithm service interface
CN112487218B (en) * 2020-11-27 2023-07-14 北京百度网讯科技有限公司 Content processing method, system, device, computing equipment and storage medium
CN112950393B (en) * 2021-02-09 2024-08-30 深圳手回科技集团有限公司 Insurance business docking method and device, electronic equipment and readable storage medium
CN112948723A (en) * 2021-02-26 2021-06-11 平安普惠企业管理有限公司 Interface calling method and device and related equipment
CN112905362A (en) * 2021-03-31 2021-06-04 浙江太美医疗科技股份有限公司 Method and system for transparently transmitting parameters between applications
CN113312390A (en) * 2021-06-01 2021-08-27 北京沃东天骏信息技术有限公司 Service data calling method and device, storage medium and electronic equipment
CN113641354A (en) * 2021-08-03 2021-11-12 挂号网(杭州)科技有限公司 Service data processing method and device, electronic equipment and storage medium
CN113726897B (en) * 2021-09-01 2024-04-19 马上消费金融股份有限公司 Data processing method, device and equipment
CN114860716A (en) * 2022-03-30 2022-08-05 北京贝壳时代网络科技有限公司 Method and device for acquiring service data
CN114968617B (en) * 2022-04-28 2023-09-01 杭州未名信科科技有限公司 API conversion system, access request processing method thereof, electronic equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628611A (en) * 2018-04-20 2018-10-09 无锡盈达聚力科技有限公司 A kind of data calling method and data call device
WO2019052526A1 (en) * 2017-09-14 2019-03-21 北京金山云网络技术有限公司 Api invoking system, method and apparatus, electronic device and storage medium
CN109766148A (en) * 2017-11-08 2019-05-17 北京京东尚科信息技术有限公司 Method and apparatus for Processing Interface method call

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019052526A1 (en) * 2017-09-14 2019-03-21 北京金山云网络技术有限公司 Api invoking system, method and apparatus, electronic device and storage medium
CN109766148A (en) * 2017-11-08 2019-05-17 北京京东尚科信息技术有限公司 Method and apparatus for Processing Interface method call
CN108628611A (en) * 2018-04-20 2018-10-09 无锡盈达聚力科技有限公司 A kind of data calling method and data call device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"Web服务访问代理参数传递的实现方法";武少波;;《电脑知识与技术(学术交流)》(第14期);第93-95页 *

Also Published As

Publication number Publication date
CN111143087A (en) 2020-05-12

Similar Documents

Publication Publication Date Title
CN111143087B (en) Interface calling method, device, storage medium and server
CN110310205B (en) Block chain data monitoring method, device, equipment and medium
CN111045756B (en) Method, apparatus, computing device and medium for generating interface service
WO2017041657A1 (en) Application interface management method and device
CN110601880A (en) Cloud platform, service processing method, command interface and computer equipment
CN110909355B (en) Unauthorized vulnerability detection method, system, electronic equipment and medium
CN110708335A (en) Access authentication method and device and terminal equipment
CN111597120A (en) Interface test apparatus, method, electronic device, and computer-readable storage medium
CN113076502A (en) Parameter control method and system based on request identification
CN112579461A (en) Assertion processing method, system and storage medium
CN108089972B (en) Interface test method and device
CN111309407A (en) Processing method and device for integrated third-party library
CN111259368A (en) Method and equipment for logging in system
CN108509228B (en) Page loading method, terminal equipment and computer readable storage medium
CN113535565B (en) Interface use case generation method, device, equipment and medium
CN113761503B (en) Interface call processing method and device
CN113467815B (en) Application repairing method and device for hot update, terminal equipment and storage medium
JP4563403B2 (en) Usage method and system in communication network
US8904411B2 (en) Framework for system communication for handling data
CN111049795B (en) Method and device for detecting sensitive data unencrypted vulnerability of distributed Web application
CN114338036A (en) Data communication method and device for block chain client
CN115859225A (en) Reinforcement method, registration method, operation method, electronic device, and storage medium
CN115022387B (en) Cross-domain pre-inspection request processing method, device, equipment and medium
CN111064747B (en) Information processing method and system, server, electronic device, medium, and product
CN115442071A (en) Project function authority management method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant