CN111562953A - Interface calling method and device, computer device and readable storage medium - Google Patents

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

Info

Publication number
CN111562953A
CN111562953A CN202010177379.9A CN202010177379A CN111562953A CN 111562953 A CN111562953 A CN 111562953A CN 202010177379 A CN202010177379 A CN 202010177379A CN 111562953 A CN111562953 A CN 111562953A
Authority
CN
China
Prior art keywords
request
interface
template file
interface template
calling
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
CN202010177379.9A
Other languages
Chinese (zh)
Inventor
王佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Smart Technology Co Ltd
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
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 OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN202010177379.9A priority Critical patent/CN111562953A/en
Publication of CN111562953A publication Critical patent/CN111562953A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides an interface calling method, an interface calling device, a computer device and a readable storage medium. The method comprises the steps of obtaining a modification request of a request end to an interface template file; modifying the interface template file according to the modification request to obtain a modified interface template file; receiving an interface calling request of the request terminal to a target interface of a given type of a server terminal; matching the modified interface template file of a given type from the modified interface template file according to the interface calling request, wherein the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server; executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file; and calling a target interface of the server according to the attribute field in the interface calling request and the target interface template file. The invention improves the efficiency of interface calling.

Description

Interface calling method and device, computer device and readable storage medium
Technical Field
The invention relates to the technical field of interfaces, in particular to an interface calling method, an interface calling device, a computer device and a computer readable storage medium.
Background
The service end providing multiple services needs to provide corresponding interfaces for different request ends in order to meet the docking requirements of multiple request ends. Each request end has own service requirement, each service requirement corresponds to an interface calling request, and the protocols of the interface calling requests are different. The non-uniformity of the interfaces causes the frequent adjustment of the interface and the interface calling request for the interface by both the request terminal and the service terminal, and causes the low efficiency of the interface calling.
Disclosure of Invention
In view of the foregoing, there is a need for an interface calling method, an interface calling apparatus, a computer apparatus, and a computer-readable storage medium, which can call an interface of a server according to an interface call request of a request end, improve efficiency of interface call, and increase scene adaptability of interface call.
A first aspect of the present application provides an interface calling method, including:
acquiring a modification request of a request end to an interface template file;
modifying the interface template file according to the modification request to obtain a modified interface template file;
receiving an interface calling request of the request terminal to a target interface of a given type of a server terminal;
matching a modified interface template file of a given type from the modified interface template file according to the identifier of the request terminal and the request type in the interface calling request, wherein the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server terminal;
executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file;
and calling a target interface of the server according to the attribute field in the interface calling request and the target interface template file.
In another possible implementation manner, the obtaining of the request for modifying the interface template file by the request side includes:
receiving an acquisition request of the request end to the interface template file;
responding to the acquisition request, and generating an intermediate interface template file of the request terminal according to the interface template file;
returning the intermediate interface template file of the request end to the request end so that the request end can generate the modification request according to the intermediate interface template file;
and receiving a modification request of the request end to the interface template file.
In another possible implementation manner, before returning the intermediate interface template file of the request end to the request end, the method further includes:
judging whether the request end has the authority of modifying the interface template file of the request end;
if the request end has the authority of modifying the interface template file of the request end, returning the interface template file of the request end to the request end;
and if the request end does not have the authority of modifying the interface template file of the request end, returning an error prompt to the request end.
In another possible implementation manner, the modifying request includes an add sub-request and/or a delete sub-request, and modifying the interface template file according to the modifying request includes:
adding attribute fields, placeholder fields and/or logic fields in the interface template file according to the adding sub-request; and/or
And deleting the attribute fields, the placeholder fields and/or the logic fields in the interface template file according to the deletion sub-request.
In another possible implementation, the interface template file and the modified interface template file have the same non-modifiable default attribute fields and default placeholder fields.
In another possible implementation manner, the invoking the target interface of the server according to the attribute field in the interface invocation request and the target interface template file includes:
judging whether the interface calling request is legal or not according to the target interface template file;
if the interface calling request is legal, assigning the value of the attribute field in the interface calling request to the placeholder field corresponding to the attribute field of the target interface template file;
analyzing the target interface template file by using an interface template file engine to obtain a standard interface calling request;
sending the standard interface calling request to the server;
receiving interface calling data returned by the server end in response to the standard interface calling request;
and returning the interface calling data to the request end.
In another possible implementation manner, the method further includes:
recording log data generated in the execution process of the method;
detecting whether the log data is abnormal;
and if the log data is abnormal, sending out warning information.
A second aspect of the present application provides an interface invocation apparatus, the apparatus comprising:
the acquisition module is used for acquiring a modification request of a request end to an interface template file;
the modification module is used for modifying the interface template file according to the modification request to obtain a modified interface template file;
the receiving module is used for receiving an interface calling request of the request terminal to a target interface of a given type of the server terminal;
the matching module is used for matching the modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request end in the interface calling request, and the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server end;
the execution module is used for executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file;
and the calling module is used for calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
In another possible implementation manner, the obtaining of the request for modifying the interface template file by the request side includes:
receiving an acquisition request of the request end to the interface template file;
responding to the acquisition request, and generating an intermediate interface template file of the request terminal according to the interface template file;
returning the intermediate interface template file of the request end to the request end so that the request end can generate the modification request according to the intermediate interface template file;
and receiving a modification request of the request end to the interface template file.
In another possible implementation manner, the interface calling apparatus may further include a returning module, configured to determine whether the requesting end has an authority to modify the interface template file of the requesting end before returning the intermediate interface template file of the requesting end to the requesting end; if the request end has the authority of modifying the interface template file of the request end, returning the interface template file of the request end to the request end; and if the request end does not have the authority of modifying the interface template file of the request end, returning an error prompt to the request end.
In another possible implementation manner, the modifying request includes an add sub-request and/or a delete sub-request, and modifying the interface template file according to the modifying request includes:
adding attribute fields, placeholder fields and/or logic fields in the interface template file according to the adding sub-request; and/or
And deleting the attribute fields, the placeholder fields and/or the logic fields in the interface template file according to the deletion sub-request.
In another possible implementation, the interface template file and the modified interface template file have the same non-modifiable default attribute fields and default placeholder fields.
In another possible implementation manner, the invoking the target interface of the server according to the attribute field in the interface invocation request and the target interface template file includes:
judging whether the interface calling request is legal or not according to the target interface template file;
if the interface calling request is legal, assigning the value of the attribute field in the interface calling request to the placeholder field corresponding to the attribute field of the target interface template file;
analyzing the target interface template file by using an interface template file engine to obtain a standard interface calling request;
sending the standard interface calling request to the server;
receiving interface calling data returned by the server end in response to the standard interface calling request;
and returning the interface calling data to the request end.
In another possible implementation manner, the interface calling apparatus may further include an alert module, configured to record log data generated in the execution process of the method; detecting whether the log data is abnormal; and if the log data is abnormal, sending out warning information.
A third aspect of the application provides a computer apparatus comprising a processor for implementing the interface call method when executing a computer program stored in a memory.
A fourth aspect of the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the interface call method.
The method comprises the steps of obtaining a modification request of a request end to an interface template file; modifying the interface template file according to the modification request to obtain a modified interface template file; receiving an interface calling request of the request terminal to a target interface of a given type of a server terminal; matching a modified interface template file of a given type from the modified interface template file according to the identifier of the request terminal and the request type in the interface calling request, wherein the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server terminal; executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file; and calling a target interface of the server according to the attribute field in the interface calling request and the target interface template file. The invention improves the efficiency of interface calling and increases the scene adaptability of interface calling.
Drawings
Fig. 1 is a flowchart of an interface calling method according to an embodiment of the present invention.
Fig. 2 is a structural diagram of an interface calling apparatus according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a detailed description of the present invention will be given below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments and features of the embodiments of the present application may be combined with each other without conflict.
In the following description, numerous specific details are set forth to provide a thorough understanding of the present invention, and the described embodiments are merely a subset of the embodiments of the present invention, rather than a complete embodiment. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
Preferably, the interface calling method of the present invention is applied in one or more computer devices. The computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing equipment. The computer device can be in man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
Example one
Fig. 1 is a flowchart of an interface calling method according to an embodiment of the present invention. The interface calling method is applied to the computer device.
The interface calling method calls the interface of the server according to the interface calling request of the request terminal.
As shown in fig. 1, the interface calling method includes:
101, acquiring a modification request of a request end to an interface template file.
The interface template file includes default attribute fields, default placeholder fields, attribute fields, placeholder fields, type fields, and logical fields.
The interface template file conforms to the interface calling standard of the server and comprises general fields (default attribute fields and default placeholder fields) for calling the interface of the server. The interface calling is carried out through the interface template file, so that the condition that the interface calling standards of the interface calling requests sent by different request ends are different can be avoided.
In a specific embodiment, the obtaining a request for modifying an interface template file by a request port includes:
receiving an acquisition request of the request end to the interface template file;
responding to the acquisition request, and generating an intermediate interface template file of the request terminal according to the interface template file;
returning the intermediate interface template file of the request end to the request end so that the request end can generate the modification request according to the intermediate interface template file;
and receiving a modification request of the request end to the interface template file.
For example, the request for obtaining the interface template file from the receiving request terminal a is "create? channel _ code ═ hhqc' & & data ═ json data "", where "create" is the request type, corresponding to the type field in the interface template file; the 'channel _ code' is a key of the request end A, and the 'hhqc' is a value of the request end A; the data type in the interface template file with data as "jsondata" as a request is json type. And responding to the acquisition request, and generating an intermediate interface template file by combining the default attribute field and the default placeholder field in the interface template file and the attribute field, the placeholder field and the logic field belonging to the request terminal A (hqc) in the interface template file. The data type of the intermediate interface template file is json type, and the type field is "create". And returning the intermediate interface template file of the request terminal A to the request terminal A so that the request terminal A generates a modification request according to the intermediate interface template file.
A request for modification of an interface template file by a requesting port may be received through a visual interface. For example, selectable fields (for modifying the interface template file) may be provided in a visual interface in the form of drop-down boxes from a pool of preset fields that may include historically used fields or fields that may be used.
In another embodiment, before the intermediate interface template file of the request end is returned to the request end, whether the request end has the authority to modify the interface template file of the request end is judged; if the request end has the authority of modifying the interface template file of the request end, returning the interface template file of the request end to the request end; and if the request end does not have the authority of modifying the interface template file of the request end, returning an error prompt to the request end.
And 102, modifying the interface template file according to the modification request to obtain a modified interface template file.
The modification request comprises an add sub-request and/or a delete sub-request, and the modifying the interface template file according to the modification request comprises:
adding attribute fields, placeholder fields and/or logic fields in the interface template file according to the adding sub-request; and/or
And deleting the attribute fields, the placeholder fields and/or the logic fields in the interface template file according to the deletion sub-request.
For example, a logical field "<% if", an attribute field "" head product "", "" flower car credit ", a placeholder field" "head product code" "," $ { data _ product _ number | is added to the interface template file according to an add sub-request! ""}"".
The file name of the modified template file can be generated according to the value and the request type of the request end.
And the attribute fields and the placeholder fields of the modified interface template file correspond to each other one by one.
The interface template file and the modified interface template file have the same non-modifiable default attribute fields and default placeholder fields.
103, receiving an interface calling request of the request terminal to a target interface of a given type of the server terminal.
The interface call request may include an identifier and a request type of the request end, a logic parameter and an attribute field, and the like.
The identifier of the request end may be used to uniquely identify the request end, and the identifier of the request end in the interface invocation request corresponds to the value of the request end in the acquisition request, the value of the request end in the interface template file, and the value of the request end in the modified interface template file one to one, respectively.
The request type may include creating an order, updating an order, pushing an order status, and the like.
In a specific embodiment, the interface call request of the requesting end to the target interface of the given type of the server may be received through an HTTP connection.
And 104, matching the modified interface template file of the given type from the modified interface template file according to the identifier and the request type of the request end in the interface calling request, wherein the matched interface template file is an intermediate file meeting the protocol standard of the target interface of the given type of the server end.
In a specific embodiment, the interface template file of the created order may be matched from the modified interface template files according to the request type "create" (created order), and the matched interface template file may be obtained by matching the interface template file of the created order of the requesting end a from the interface template files of the created order according to the identifier "hhqc" of the requesting end a.
The modified interface template file may include a plurality of request-type interface template subfiles, and each request-type interface template subfile may include a plurality of request-side interface template subfiles for the request type.
The modified interface template file may include a plurality of request-type interface template modules (that is, the modified interface template file is an interface template file in which a plurality of request-type interface template modules form an integral whole), and each request-type interface template submodule may include a plurality of request-side interface template submodules of the request type.
105, executing the logic field in the matched interface template file according to the logic parameter in the interface calling request to obtain a target interface template file.
For example, the logic parameter in the interface call request is "a ═ 5'", where a is the parameter name of the logic parameter and 5 is the parameter value of the logic parameter. The logic field in the matched interface template file is "<% if (a ═ 5 ') {% > first part, <% } else {% > second part, <% } {% >, the logic field in the matched interface template file is executed, and a ═ 5', and the obtained target interface template file is the first part.
Wherein the first portion and the second portion may be attribute fields, for example, the first portion may be "" head product "": China car loan, "" subproductiltype ": PT _ NBRB _ HXTJ"; the second part may be "" head product "" "State travel vehicle loan" "," "subproductiType" "" PT _ NBRB _ XMGJ "".
106, calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
The calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file comprises the following steps:
(1) and judging whether the interface calling request is legal or not according to the target interface template file.
The determining whether the interface call request is legal according to the matched interface template file may include: if the attribute fields in the interface calling request correspond to the attribute fields of the matched interface template file one by one and the data type of the values of the attribute fields in the interface calling request is consistent with the required data type of the placeholder fields corresponding to the attribute fields of the matched interface template file, the interface calling request is legal; and if the attribute fields in the interface calling request do not correspond to the attribute fields of the matched interface template file one to one or the data type of the values of the attribute fields in the interface calling request is inconsistent with the required data type of the placeholder fields corresponding to the attribute fields of the matched interface template file, the interface calling request is illegal.
(2) And if the interface calling request is legal, assigning the value of the attribute field in the interface calling request to a placeholder field corresponding to the attribute field of the target interface template file.
For example, in the interface call request, the attribute field a is "subProductType": YATAI _ HDYX _ hxc ", where" subProductType "is the attribute name of the attribute field a," YATAI _ HDYX _ hxc "is the value of the attribute field a, the attribute field B of the target interface template file is" subProductType ": wherein" subProductType "is the attribute name of the attribute field B, and" $ subProductType "is the placeholder field of the attribute field B, then" YATAI _ HDYX _ hxx "is assigned to" $ subProductType ".
(3) And analyzing the target interface template file by using an interface template file engine to obtain a standard interface calling request.
The interface template file engine can analyze the parameter name and the parameter value required by the standard interface calling request from the target interface template file.
(4) And sending the standard interface calling request to the server.
(5) And receiving interface calling data returned by the server end in response to the standard interface calling request.
(6) And returning the interface calling data to the request end.
Before judging whether the interface calling request is legal according to the target interface template file, the method further comprises the following steps: and correspondingly converting the data format of the attribute field in the interface calling request according to the data format of the attribute field of the target interface template file.
The interface calling method of the first embodiment obtains a modification request of a request end to an interface template file; modifying the interface template file according to the modification request to obtain a modified interface template file; receiving an interface calling request of the request terminal to a target interface of a given type of a server terminal; matching a modified interface template file of a given type from the modified interface template file according to the identifier of the request terminal and the request type in the interface calling request, wherein the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server terminal; executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file; and calling a target interface of the server according to the attribute field in the interface calling request and the target interface template file. According to the embodiment, the interface of the server side is called according to the interface calling request of the request side, so that the efficiency of interface calling is improved, and the scene adaptability of interface calling is improved.
In another embodiment, the method further comprises:
recording log data generated in the execution process of the method;
detecting whether the log data is abnormal;
and if the log data is abnormal, sending out warning information.
Example two
Fig. 2 is a structural diagram of an interface calling apparatus according to a second embodiment of the present invention. The interface calling device 20 is applied to a computer device. The interface calling of the device calls the interface of the server side according to the interface calling request of the request side. As shown in fig. 2, the interface calling device 20 may include an obtaining module 201, a modifying module 202, a receiving module 203, a matching module 204, an executing module 205, and a calling module 206.
The obtaining module 201 is configured to obtain a modification request of the request end to the interface template file.
The interface template file includes default attribute fields, default placeholder fields, attribute fields, placeholder fields, type fields, and logical fields.
The interface template file conforms to the interface calling standard of the server and comprises general fields (default attribute fields and default placeholder fields) for calling the interface of the server. The interface calling is carried out through the interface template file, so that the condition that the interface calling standards of the interface calling requests sent by different request ends are different can be avoided.
In a specific embodiment, the obtaining a request for modifying an interface template file by a request port includes:
receiving an acquisition request of the request end to the interface template file;
responding to the acquisition request, and generating an intermediate interface template file of the request terminal according to the interface template file;
returning the intermediate interface template file of the request end to the request end so that the request end can generate the modification request according to the intermediate interface template file;
and receiving a modification request of the request end to the interface template file.
For example, the request for obtaining the interface template file from the receiving request terminal a is "create? channel _ code ═ hhqc' & & data ═ json data "", where "create" is the request type, corresponding to the type field in the interface template file; the 'channel _ code' is a key of the request end A, and the 'hhqc' is a value of the request end A; the data type in the interface template file with data as "jsondata" as a request is json type. And responding to the acquisition request, and generating an intermediate interface template file by combining the default attribute field and the default placeholder field in the interface template file and the attribute field, the placeholder field and the logic field belonging to the request terminal A (hqc) in the interface template file. The data type of the intermediate interface template file is json type, and the type field is "create". And returning the intermediate interface template file of the request terminal A to the request terminal A so that the request terminal A generates a modification request according to the intermediate interface template file.
A request for modification of an interface template file by a requesting port may be received through a visual interface. For example, selectable fields (for modifying the interface template file) may be provided in a visual interface in the form of drop-down boxes from a pool of preset fields that may include historically used fields or fields that may be used.
In another embodiment, the interface calling apparatus may further include a returning module, configured to determine whether the requesting end has an authority to modify the interface template file of the requesting end before returning the intermediate interface template file of the requesting end to the requesting end; if the request end has the authority of modifying the interface template file of the request end, returning the interface template file of the request end to the request end; and if the request end does not have the authority of modifying the interface template file of the request end, returning an error prompt to the request end.
And the modifying module 202 is configured to modify the interface template file according to the modification request, so as to obtain a modified interface template file.
The modification request comprises an add sub-request and/or a delete sub-request, and the modifying the interface template file according to the modification request comprises:
adding attribute fields, placeholder fields and/or logic fields in the interface template file according to the adding sub-request; and/or
And deleting the attribute fields, the placeholder fields and/or the logic fields in the interface template file according to the deletion sub-request.
For example, a logical field "<% if", an attribute field "" head product "", "" flower car credit ", a placeholder field" "head product code" "," $ { data _ product _ number | is added to the interface template file according to an add sub-request! ""}"".
The file name of the modified template file can be generated according to the value and the request type of the request end.
And the attribute fields and the placeholder fields of the modified interface template file correspond to each other one by one.
The interface template file and the modified interface template file have the same non-modifiable default attribute fields and default placeholder fields.
A receiving module 203, configured to receive an interface call request of the requesting end to a target interface of a given type of the server.
The interface call request may include an identifier and a request type of the request end, a logic parameter and an attribute field, and the like.
The identifier of the request end may be used to uniquely identify the request end, and the identifier of the request end in the interface invocation request corresponds to the value of the request end in the acquisition request, the value of the request end in the interface template file, and the value of the request end in the modified interface template file one to one, respectively.
The request type may include creating an order, updating an order, pushing an order status, and the like.
In a specific embodiment, the interface call request of the requesting end to the target interface of the given type of the server may be received through an HTTP connection.
A matching module 204, configured to match a modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request end in the interface call request, where the matched interface template file is an intermediate file meeting a protocol standard of a target interface of the given type of the service end.
In a specific embodiment, the interface template file of the created order may be matched from the modified interface template files according to the request type "create" (created order), and the matched interface template file may be obtained by matching the interface template file of the created order of the requesting end a from the interface template files of the created order according to the identifier "hhqc" of the requesting end a.
The modified interface template file may include a plurality of request-type interface template subfiles, and each request-type interface template subfile may include a plurality of request-side interface template subfiles for the request type.
The modified interface template file may include a plurality of request-type interface template modules (that is, the modified interface template file is an interface template file in which a plurality of request-type interface template modules form an integral whole), and each request-type interface template submodule may include a plurality of request-side interface template submodules of the request type.
And the execution module 205 is configured to execute the logic field in the matched interface template file according to the logic parameter in the interface call request, so as to obtain a target interface template file.
For example, the logic parameter in the interface call request is "a ═ 5'", where a is the parameter name of the logic parameter and 5 is the parameter value of the logic parameter. The logic field in the matched interface template file is "<% if (a ═ 5 ') {% > first part, <% } else {% > second part, <% } {% >, the logic field in the matched interface template file is executed, and a ═ 5', and the obtained target interface template file is the first part.
Wherein the first portion and the second portion may be attribute fields, for example, the first portion may be "" head product "": China car loan, "" subproductiltype ": PT _ NBRB _ HXTJ"; the second part may be "" head product "" "State travel vehicle loan" "," "subproductiType" "" PT _ NBRB _ XMGJ "".
And the calling module 206 is configured to call the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
The calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file comprises the following steps:
(1) and judging whether the interface calling request is legal or not according to the target interface template file.
The determining whether the interface call request is legal according to the matched interface template file may include: if the attribute fields in the interface calling request correspond to the attribute fields of the matched interface template file one by one and the data type of the values of the attribute fields in the interface calling request is consistent with the required data type of the placeholder fields corresponding to the attribute fields of the matched interface template file, the interface calling request is legal; and if the attribute fields in the interface calling request do not correspond to the attribute fields of the matched interface template file one to one or the data type of the values of the attribute fields in the interface calling request is inconsistent with the required data type of the placeholder fields corresponding to the attribute fields of the matched interface template file, the interface calling request is illegal.
(2) And if the interface calling request is legal, assigning the value of the attribute field in the interface calling request to a placeholder field corresponding to the attribute field of the target interface template file.
For example, in the interface call request, the attribute field a is "subProductType": YATAI _ HDYX _ hxc ", where" subProductType "is the attribute name of the attribute field a," YATAI _ HDYX _ hxc "is the value of the attribute field a, the attribute field B of the target interface template file is" subProductType ": wherein" subProductType "is the attribute name of the attribute field B, and" $ subProductType "is the placeholder field of the attribute field B, then" YATAI _ HDYX _ hxx "is assigned to" $ subProductType ".
(3) And analyzing the target interface template file by using an interface template file engine to obtain a standard interface calling request.
The interface template file engine can analyze the parameter name and the parameter value required by the standard interface calling request from the target interface template file.
(4) And sending the standard interface calling request to the server.
(5) And receiving interface calling data returned by the server end in response to the standard interface calling request.
(6) And returning the interface calling data to the request end.
The interface calling device 20 may further include a conversion module, configured to correspondingly convert the data format of the attribute field in the interface calling request according to the data format of the attribute field of the target interface template file before determining whether the interface calling request is legal according to the target interface template file.
The interface calling device 20 of the second embodiment obtains a modification request of a request port to an interface template file; modifying the interface template file according to the modification request to obtain a modified interface template file; receiving an interface calling request of the request terminal to a target interface of a given type of a server terminal; matching a modified interface template file of a given type from the modified interface template file according to the identifier of the request terminal and the request type in the interface calling request, wherein the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server terminal; executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file; and calling a target interface of the server according to the attribute field in the interface calling request and the target interface template file. And dynamically adjusting the interface of the server according to the interface calling request of the request terminal, so that the efficiency of interface calling is improved, and the scene adaptability of interface calling is improved.
In another embodiment, the interface calling device 20 may further include:
the warning module is used for recording log data generated in the execution process of the method; detecting whether the log data is abnormal; and if the log data is abnormal, sending out warning information.
EXAMPLE III
The present embodiment provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps in the foregoing interface invoking method embodiment, for example, 101-106 shown in fig. 1:
101, acquiring a modification request of a request end to an interface template file;
102, modifying the interface template file according to the modification request to obtain a modified interface template file;
103, receiving an interface calling request of the request terminal to a target interface of a given type of the server terminal;
104, matching a modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request terminal in the interface calling request, wherein the matched interface template file is an intermediate file meeting the protocol standard of a target interface of the given type of the server terminal;
105, executing the logic field in the matched interface template file according to the logic parameter in the interface calling request to obtain a target interface template file;
106, calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
Alternatively, the computer program, when executed by the processor, implements the functions of the modules in the above device embodiments, such as the module 201 and 206 in fig. 2:
an obtaining module 201, configured to obtain a modification request of a request end to an interface template file;
a modification module 202, configured to modify the interface template file according to the modification request, so as to obtain a modified interface template file;
a receiving module 203, configured to receive an interface call request of the request end to a target interface of a given type at a server end;
a matching module 204, configured to match a modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request end in the interface call request, where the matched interface template file is an intermediate file meeting a protocol standard of a target interface of the given type of the service end;
an executing module 205, configured to execute the logic field in the matched interface template file according to the logic parameter in the interface call request, so as to obtain a target interface template file;
and the calling module 206 is configured to call the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
Example four
Fig. 3 is a schematic diagram of a computer device according to a fourth embodiment of the present invention. The computer device 30 comprises a memory 301, a processor 302 and a computer program 303, such as an interface calling program, stored in the memory 301 and executable on the processor 302. The processor 302, when executing the computer program 303, implements the steps in the above-mentioned interface calling method embodiment, such as 101-106 shown in fig. 1:
101, acquiring a modification request of a request end to an interface template file;
102, modifying the interface template file according to the modification request to obtain a modified interface template file;
103, receiving an interface calling request of the request terminal to a target interface of a given type of the server terminal;
104, matching a modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request terminal in the interface calling request, wherein the matched interface template file is an intermediate file meeting the protocol standard of a target interface of the given type of the server terminal;
105, executing the logic field in the matched interface template file according to the logic parameter in the interface calling request to obtain a target interface template file;
106, calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
Alternatively, the computer program, when executed by the processor, implements the functions of the modules in the above device embodiments, such as the module 201 and 206 in fig. 2:
an obtaining module 201, configured to obtain a modification request of a request end to an interface template file;
a modification module 202, configured to modify the interface template file according to the modification request, so as to obtain a modified interface template file;
a receiving module 203, configured to receive an interface call request of the request end to a target interface of a given type at a server end;
a matching module 204, configured to match a modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request end in the interface call request, where the matched interface template file is an intermediate file meeting a protocol standard of a target interface of the given type of the service end;
an executing module 205, configured to execute the logic field in the matched interface template file according to the logic parameter in the interface call request, so as to obtain a target interface template file;
and the calling module 206 is configured to call the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
Illustratively, the computer program 303 may be partitioned into one or more modules that are stored in the memory 301 and executed by the processor 302 to perform the present method. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 303 in the computer device 30. For example, the computer program 303 may be divided into the obtaining module 201, the modifying module 202, the receiving module 203, the matching module 204, the executing module 205, and the calling module 206 in fig. 2, and the specific functions of each module are described in embodiment two.
The computer device 30 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. It will be understood by those skilled in the art that the schematic diagram 3 is merely an example of the computer apparatus 30, and does not constitute a limitation to the computer apparatus 30, and may include more or less components than those shown, or combine some components, or different components, for example, the computer apparatus 30 may further include an input and output device, a network access device, a bus, and the like.
The Processor 302 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor 302 may be any conventional processor or the like, the processor 302 being the control center of the computer device 30 and connecting the various parts of the overall computer device 30 using various interfaces and lines.
The memory 301 may be used to store the computer program 303, and the processor 302 may implement various functions of the computer device 30 by running or executing the computer program or module stored in the memory 301 and calling data stored in the memory 301. The memory 301 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to the use of the computer device 30, and the like. Further, the memory 301 may include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other non-volatile solid state storage device.
The modules integrated by the computer device 30 may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, Read-Only Memory (ROM).
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware form, and can also be realized in a form of hardware and a software functional module.
The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned. Furthermore, it is to be understood that the word "comprising" does not exclude other modules or steps, and the singular does not exclude the plural. A plurality of modules or means recited in the system claims may also be implemented by one module or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. An interface calling method, comprising:
acquiring a modification request of a request end to an interface template file;
modifying the interface template file according to the modification request to obtain a modified interface template file;
receiving an interface calling request of the request terminal to a target interface of a given type of a server terminal;
matching a modified interface template file of a given type from the modified interface template file according to the identifier of the request terminal and the request type in the interface calling request, wherein the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server terminal;
executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file;
and calling a target interface of the server according to the attribute field in the interface calling request and the target interface template file.
2. The method of claim 1, wherein obtaining a request for modification of an interface template file by a requesting port comprises:
receiving an acquisition request of the request end to the interface template file;
responding to the acquisition request, and generating an intermediate interface template file of the request terminal according to the interface template file;
returning the intermediate interface template file of the request end to the request end so that the request end can generate the modification request according to the intermediate interface template file;
and receiving a modification request of the request end to the interface template file.
3. The method of claim 2, wherein prior to said returning the intermediate interface template file of the requesting end to the requesting end, the method further comprises:
judging whether the request end has the authority of modifying the interface template file of the request end;
if the request end has the authority of modifying the interface template file of the request end, returning the interface template file of the request end to the request end;
and if the request end does not have the authority of modifying the interface template file of the request end, returning an error prompt to the request end.
4. The method of claim 1, wherein the modification request comprises an add sub-request and/or a delete sub-request, and wherein the modifying the interface template file according to the modification request comprises:
adding attribute fields, placeholder fields and/or logic fields in the interface template file according to the adding sub-request; and/or
And deleting the attribute fields, the placeholder fields and/or the logic fields in the interface template file according to the deletion sub-request.
5. The method of claim 1, wherein the interface template file and the modified interface template file have the same non-modifiable default attribute fields and default placeholder fields.
6. The method of claim 1, wherein the calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file comprises:
judging whether the interface calling request is legal or not according to the target interface template file;
if the interface calling request is legal, assigning the value of the attribute field in the interface calling request to the placeholder field corresponding to the attribute field of the target interface template file;
analyzing the target interface template file by using an interface template file engine to obtain a standard interface calling request;
sending the standard interface calling request to the server;
receiving interface calling data returned by the server end in response to the standard interface calling request;
and returning the interface calling data to the request end.
7. The method of any one of claims 1-6, further comprising:
recording log data generated in the execution process of the method;
detecting whether the log data is abnormal;
and if the log data is abnormal, sending out warning information.
8. An interface invocation apparatus, characterized in that said apparatus comprises:
the acquisition module is used for acquiring a modification request of a request end to an interface template file;
the modification module is used for modifying the interface template file according to the modification request to obtain a modified interface template file;
the receiving module is used for receiving an interface calling request of the request terminal to a target interface of a given type of the server terminal;
the matching module is used for matching the modified interface template file of a given type from the modified interface template file according to the identifier and the request type of the request end in the interface calling request, and the matched interface template file is an intermediate file which accords with the protocol standard of a target interface of the given type of the server end;
the execution module is used for executing the logic fields in the matched interface template file according to the logic parameters in the interface calling request to obtain a target interface template file;
and the calling module is used for calling the target interface of the server according to the attribute field in the interface calling request and the target interface template file.
9. A computer arrangement, characterized in that the computer arrangement comprises a processor for executing a computer program stored in a memory for implementing an interface call method according to any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the interface calling method according to any one of claims 1 to 7.
CN202010177379.9A 2020-03-13 2020-03-13 Interface calling method and device, computer device and readable storage medium Pending CN111562953A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010177379.9A CN111562953A (en) 2020-03-13 2020-03-13 Interface calling method and device, computer device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010177379.9A CN111562953A (en) 2020-03-13 2020-03-13 Interface calling method and device, computer device and readable storage medium

Publications (1)

Publication Number Publication Date
CN111562953A true CN111562953A (en) 2020-08-21

Family

ID=72071367

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010177379.9A Pending CN111562953A (en) 2020-03-13 2020-03-13 Interface calling method and device, computer device and readable storage medium

Country Status (1)

Country Link
CN (1) CN111562953A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860239A (en) * 2021-03-15 2021-05-28 京东数科海益信息科技有限公司 Data type conversion method and device, electronic equipment and storage medium
CN115514806A (en) * 2022-11-16 2022-12-23 江苏曼荼罗软件股份有限公司 Perception discovery method and system for discrete service cluster
CN117033032A (en) * 2023-09-28 2023-11-10 北京谷器数据科技有限公司 Platform for automatically analyzing and calling third-party service interface

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860239A (en) * 2021-03-15 2021-05-28 京东数科海益信息科技有限公司 Data type conversion method and device, electronic equipment and storage medium
CN115514806A (en) * 2022-11-16 2022-12-23 江苏曼荼罗软件股份有限公司 Perception discovery method and system for discrete service cluster
CN117033032A (en) * 2023-09-28 2023-11-10 北京谷器数据科技有限公司 Platform for automatically analyzing and calling third-party service interface

Similar Documents

Publication Publication Date Title
CN111562953A (en) Interface calling method and device, computer device and readable storage medium
CN113079072B (en) Vehicle data acquisition method and system, computer equipment and storage medium
CN110601880B (en) Cloud platform, service processing method, command interface and computer equipment
CN111400387B (en) Conversion method and device for import and export data, terminal equipment and storage medium
CN110489440B (en) Data query method and device
CN112527420A (en) Interface data flow processing method and device, computer equipment and medium
CN111818175B (en) Enterprise service bus configuration file generation method, device, equipment and storage medium
CN110472109B (en) Dynamic data quality analysis method and platform system
CN108255967B (en) Method and device for calling storage process, storage medium and terminal
CN111522574B (en) Differential packet generation method and related equipment
CN113626223A (en) Interface calling method and device
CN110598993B (en) Data processing method and device
CN109542398B (en) Business system generation method and device and computer readable storage medium
CN109814916B (en) IVR flow configuration method, device, storage medium and server
CN109558403B (en) Data aggregation method and device, computer device and computer readable storage medium
CN116795913A (en) Data export method, data import method and data export import system
CN111897529B (en) Front-end component conversion method, device, equipment and readable storage medium
CN109462576B (en) Permission policy configuration method and device and computer readable storage medium
CN112667631A (en) Method, device and equipment for automatically editing service field and storage medium
CN112199428B (en) Application management system, method and terminal equipment of functional data block
CN112733510A (en) Financial certificate generation method, device, equipment and computer readable storage medium
CN115659325B (en) Audit method, electronic device and storage medium
CN116861455B (en) Event data processing method, system, electronic device and storage medium
CN116880820A (en) Visual generation method and device for application, terminal equipment and storage medium
CN107911365B (en) Multi-network user information safety interaction method, terminal 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