CN111552578B - Third party interface calling method and device - Google Patents

Third party interface calling method and device Download PDF

Info

Publication number
CN111552578B
CN111552578B CN202010366952.0A CN202010366952A CN111552578B CN 111552578 B CN111552578 B CN 111552578B CN 202010366952 A CN202010366952 A CN 202010366952A CN 111552578 B CN111552578 B CN 111552578B
Authority
CN
China
Prior art keywords
party interface
request
class
mode
party
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
CN202010366952.0A
Other languages
Chinese (zh)
Other versions
CN111552578A (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.)
Chengdu Xinchao Media Group Co Ltd
Original Assignee
Chengdu Xinchao Media Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Xinchao Media Group Co Ltd filed Critical Chengdu Xinchao Media Group Co Ltd
Priority to CN202010366952.0A priority Critical patent/CN111552578B/en
Publication of CN111552578A publication Critical patent/CN111552578A/en
Application granted granted Critical
Publication of CN111552578B publication Critical patent/CN111552578B/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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention relates to the technical field of Internet, and discloses a method and a device for calling a third party interface, wherein the third party interface can be called through a third party interface class associated with the third party interface, namely, on one hand, the request and the returned logic of the associated third party interface can be intensively processed aiming at different service request sides by utilizing the third party interface class, thereby achieving the purposes of simple codes, convenient maintenance and easy management, and on the other hand, the method and the device can automatically switch a single request mode into a batch request mode when the interface request is initiated by calling the third party interface through changing calling parameters. In addition, the single request mode can be automatically switched back by the batch request mode through the new change of the calling parameters, and the method is particularly suitable for flexible switching in the calling process.

Description

Third party interface calling method and device
Technical Field
The invention belongs to the technical field of Internet, and particularly relates to a third party interface calling method and device.
Background
With the continuous development and application of the current internet technology, the service architecture of the network service is gradually changed from the original stand-alone architecture to the micro-service architecture, such as the original e-commerce website, the back end is split into order service, warehouse service, member service, activity service and the like, so that when a certain service (e.g. activity service) processes one business logic, a plurality of third party interfaces of other services are called to request to acquire relevant response data of the services, and then the local business logic is completed by utilizing the response data, thereby achieving the external service purpose. By way of example, an active service requires a third party interface that invokes a number of other services, such as order services, warehouse services, membership services, and the like.
However, in the conventional third party interface management system, a plurality of other services (for example, order service, warehouse service, member service, etc. corresponding to an active service) are discretely distributed at different locations, and when the third party interface response system of a certain service is changed (for example, the response interface address, the response request parameter, the format of the response data, etc. are changed), the third party interface request (for example, the interface address, the request parameter, the response data receiving mode, the processing mode, etc.) for initiating the service request needs to be modified on different service request sides one by one, which results in the problems of complicated code, troublesome maintenance, and difficult management. In addition, the third party interface request mode is divided into a single request mode and a batch request mode, wherein the former can request to return single response data, and the latter can request to return a plurality of batch response data, but the technical scheme of flexibly switching the single request mode and the batch request mode is lacking at present, so that the call of the third party interface is troublesome to use, and the call experience is influenced.
Disclosure of Invention
In order to solve the problems that the existing method is not easy to manage and can not lack flexible switching of a single request mode and a batch request mode in the third party interface calling process, the invention aims to provide a third party interface calling method, a third party interface calling device, computer equipment and a computer readable storage medium, wherein the method, the device and the computer readable storage medium are convenient to manage and switch the request modes.
In a first aspect, the present invention provides a third party interface calling method, including:
initiating a single request of a third party interface for requesting to return single response data by using the attribute characteristics of the third party interface in the third party interface class and a single request mode to acquire the single response data;
calling a class judgment mode in the third party interface class after receiving the calling parameter;
judging whether the current third-party interface request mode is a single request mode or a batch request mode according to the calling parameters and the judging modes in the class;
and if the batch request mode is adopted, initiating a third-party interface batch request for requesting to return M pieces of response data by using a third-party interface attribute feature, an entity creation mode and a batch request mode in the third-party interface class, and acquiring the batch response data, wherein M is a natural number not less than 2.
Based on the above summary, the third party interface may be invoked by a third party interface class associated with the third party interface, that is, on one hand, the third party interface class may be utilized to process the associated request and return logic of the third party interface in a centralized manner for different service request sides, thereby achieving the purposes of code compaction, maintenance convenience and easy management, and on the other hand, the third party interface may be automatically switched from a single request mode to a batch request mode when the interface request is initiated by invoking the third party interface by changing the invocation parameters.
In one possible design, the third party interface batch request for requesting to return M response data is initiated using a third party interface attribute feature, an entity creation mode, and a batch request mode in the third party interface class, including:
according to the attribute characteristic configuration of the third party interface, a first interface address and a first request parameter for initiating the third party interface batch request are configured;
the entity creation mode is called for M times to obtain a request entity set containing M request entities;
and when the batch request mode is called, initiating the third-party interface batch request by using the first interface address, the first request parameter and the request entity set.
Through the design, the third party interface request can be initiated to the third party service provider in batches, and a single batch of multiple response data can be obtained, so that the batch request application scene is met.
In one possible design, using the third party interface attribute feature in the third party interface class and the single request mode to initiate a third party interface single request for requesting return of single response data includes:
according to the attribute characteristics of the third party interface, configuring a second interface address and a second request parameter for initiating a single request of the third party interface;
And when the single request mode is invoked, initiating the third party interface single request by using the second interface address and the second request parameter.
Through the design, the third party interface request can be individually initiated to the third party service provider, the response data can be acquired, and the single request application scene can be satisfied.
In one possible design, if the third party interface class further includes a response data processing manner;
after obtaining the batch response data, the method further comprises:
and processing the batch response data by using a response data processing mode which corresponds to the format and is in the third party interface class according to the format of the batch response data, so as to obtain a processing result.
Through the design, the third party interface class can be used for automatically processing the returned response data in batches, so that the request call can be further conveniently completed.
In one possible design, before invoking the in-class judgment in the third party interface class, the method further includes:
detecting a third-party interface class changing operation performed on a third-party interface management interface by an administrator, wherein the third-party interface class changing operation is an operation for enabling the third-party interface class changing to inherit another prefabricated abstract class or changing a third-party interface attribute characteristic and/or a third-party interface prefabricated execution mode in the third-party interface class, and the prefabricated abstract class comprises the third-party interface attribute characteristic and the third-party interface prefabricated execution mode;
And responding to the third-party interface class changing operation, so that the third-party interface class changing inherits another prefabricated abstract class, or the third-party interface attribute characteristics and/or the third-party interface prefabricated execution mode in the third-party interface class are changed, so as to obtain a changed third-party interface class.
Through the design, when the response mode of the third party interface is changed, only one place of the corresponding third party interface class is updated and modified, so that the third party interface requests initiated at different service request sides can be intensively adapted to the change of the interface response mode, and the centralized management of the third party interfaces is further facilitated.
In a second aspect, the present invention provides a third party interface management device, including a single request unit, a call unit, a judgment unit, and a batch request unit;
the single request unit is used for initiating a single request of a third party interface for requesting to return single response data by using the attribute characteristics of the third party interface in the class of the third party interface and a single request mode to acquire the single response data;
the calling unit is used for calling the judging mode in the class in the third party interface class after receiving the calling parameter;
The judging unit is in communication connection with the calling unit and is used for judging whether the current third party interface request mode is a single request mode or a batch request mode according to the calling parameters and the judging modes in the class;
and the batch request unit is in communication connection with the judging unit and is used for initiating a third-party interface batch request for requesting to return M pieces of response data by using the third-party interface attribute characteristics, the entity creation mode and the batch request mode in the third-party interface class when the batch request mode is adopted, and the batch response data is obtained, wherein M is a natural number not less than 2.
In one possible design, the batch request unit includes a first request configuration subunit, an entity creation subunit, and a first request initiation subunit;
the first request configuration subunit is configured to configure a first interface address and a first request parameter for initiating the third party interface batch request according to the attribute characteristics of the third party interface;
the entity creation subunit is configured to obtain a request entity set containing M request entities by invoking the entity creation manner M times;
the first request initiating subunit is in communication connection with the first request configuring subunit and the entity creating subunit, and is configured to initiate the third party interface batch request by using the first interface address, the first request parameter and the request entity set when the batch request mode is invoked.
In one possible design, the single request unit is communicatively connected to the judging unit, and is configured to, after initiating a third party interface batch request for requesting to return M pieces of response data by using a third party interface attribute feature in the third party interface class, an entity creation mode and a batch request mode, and when judging that the single request mode is the single request mode again according to new call parameters and the judging mode in the class, initiate a third party interface single request for requesting to return the single response data by using the third party interface attribute feature in the third party interface class and the single request mode, and acquire the single response data.
In one possible design, the single request unit includes a second request configuration subunit and a second request initiation subunit;
the second request configuration subunit is configured to configure a second interface address and a second request parameter for initiating the single request of the third party interface according to the attribute characteristics of the third party interface;
and the second request initiating subunit is configured to initiate, when the single request mode is invoked, the third party interface single request using the second interface address and the second request parameter.
In one possible design, the system further comprises a data processing unit;
the data processing unit is in communication connection with the batch request unit and is used for processing the batch response data by using the response data processing mode corresponding to the format and in the third-party interface class according to the format of the batch response data after the batch response data is acquired in the third-party interface class, so as to obtain a processing result.
In one possible design, the data processing unit is further communicatively connected to the single request unit, and is configured to further include a response data processing manner in the third party interface class, and after obtaining the single response data, process the single response data according to the format of the single response data, using the response data processing manner corresponding to the format of the single response data and in the third party interface class, to obtain a processing result.
In one possible design, the device further comprises a change operation detection unit and a change operation response unit;
the change operation detection unit is configured to detect a third party interface class change operation performed by an administrator on a third party interface management interface before invoking a judging manner in a class in a third party interface class, where the third party interface class change operation is an operation for enabling the third party interface class change to inherit another prefabricated abstract class or to change a third party interface attribute feature and/or a third party interface prefabrication execution manner in the third party interface class, and the prefabricated abstract class includes the third party interface attribute feature and the third party interface prefabrication execution manner;
The change operation response unit is in communication connection with the change operation detection unit and is used for responding to the change operation of the third-party interface class, so that the third-party interface class change inherits another prefabricated abstract class, or the attribute characteristics of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface are changed, so that the changed third-party interface class is obtained.
In a third aspect, the present invention provides a computer device comprising a memory and a processor in communication, wherein the memory is configured to store a computer program, and the processor is configured to read the computer program and execute the third party interface invoking method as described above in the first aspect or any one of the possible designs of the first aspect.
In a fourth aspect, the present invention provides a computer readable storage medium having instructions stored thereon which, when executed on a computer, perform the third party interface invocation method as may be devised in the first aspect or any one of the first aspects above.
In a fifth aspect, the present invention provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the third party interface invocation method as described above, or as may be devised in any of the first aspects.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, 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 schematic flow chart of a third party interface calling method provided by the invention.
Fig. 2 is an exemplary diagram of a third party interface attribute feature and a third party interface prefabrication implementation manner in an abstract class according to the present invention.
FIG. 3 is an exemplary diagram of inheritance relationships between abstract parent classes and abstract subclasses provided by the present invention.
Fig. 4 is a schematic structural diagram of a third party interface calling device provided by the present invention.
Fig. 5 is a schematic structural diagram of a computer device provided by the present invention.
Detailed Description
The invention will be further elucidated with reference to the drawings and to specific embodiments. The present invention is not limited to these examples, although they are described in order to assist understanding of the present invention. Specific structural and functional details disclosed herein are merely representative of example embodiments of the invention. This invention may, however, be embodied in many alternate forms and should not be construed as limited to the embodiments set forth herein.
It will be understood that, although the terms first, second, etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element. For example, a first element could be termed a second element, and, similarly, a second element could be termed a first element, without departing from the scope of example embodiments of the present invention.
It should be understood that for the term "and/or" that may appear herein, it is merely one association relationship that describes an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a alone, B alone, and both a and B; for the term "/and" that may appear herein, which is descriptive of another associative object relationship, it means that there may be two relationships, e.g., a/and B, it may be expressed that: a alone, a alone and B alone; in addition, for the character "/" that may appear herein, it is generally indicated that the context associated object is an "or" relationship.
It will be understood that when an element is referred to herein as being "connected," "connected," or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. In contrast, when an element is referred to herein as being "directly connected" or "directly coupled" to another element, it means that there are no intervening elements present. In addition, other words used to describe relationships between elements (e.g., "between … …" pair "directly between … …", "adjacent" pair "directly adjacent", etc.) should be interpreted in a similar manner.
It is to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments of the invention. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises," "comprising," "includes," "including" and/or "including," when used herein, specify the presence of stated features, integers, steps, operations, elements, and/or components, and do not preclude the presence or addition of one or more other features, quantities, steps, operations, elements, components, and/or groups thereof.
It should be appreciated that in some alternative designs, the functions/acts noted may occur out of the order in which the figures appear. For example, two figures shown in succession may in fact be executed substantially concurrently or the figures may sometimes be executed in the reverse order, depending upon the functionality/acts involved.
It should be understood that specific details are provided in the following description to provide a thorough understanding of the example embodiments. However, it will be understood by those of ordinary skill in the art that the example embodiments may be practiced without these specific details. For example, a system may be shown in block diagrams in order to avoid obscuring the examples with unnecessary detail. In other instances, well-known processes, structures, and techniques may be shown without unnecessary detail in order to avoid obscuring the example embodiments.
As shown in fig. 1, the third party interface calling method provided in the first aspect of the present embodiment may, but is not limited to, include the following steps S101 to S105.
S101, using the third-party interface attribute characteristics and a single request mode in a third-party interface class to initiate a third-party interface single request for requesting to return single response data, and acquiring the single response data.
In the step S101, the third party interface class is associated with the third party interface to be invoked and includes a third party interface attribute feature and a third party interface prefabrication execution mode. The third party interface class is used as an abstract class of a single third party interface or a plurality of third party interfaces associated with the third party interface class, wherein the abstract class is a common term in the internet technology and is mainly used for abstract expression of a third party interface object. In the abstract class, the third party interface attribute feature is used for abstract expression of specific interface attribute content, and may include, but is not limited to, a request mode feature, a request client feature, a request response end feature, a request response address feature, and/or a request parameter feature, so that the content of the third party interface attribute feature is enriched, and flexible management is facilitated; the third party interface prefabrication execution mode is used for expressing and calling the prefabrication execution mode of the third party interface, and can include, but is not limited to, a single request mode, a batch request mode, a request header adding mode, a response data processing mode, an entity creation mode for creating a request entity and the like, so that the content of the third party interface prefabrication execution mode is enriched, and flexible management and calling are facilitated.
In the step S101, specifically, taking a third party interface based on english hypertext preprocessor (Hypertext Preprocessor, PHP) as an example, an abstract class as shown in fig. 2 may be created in advance. In the third party interface attribute feature of the abstract class, the request mode feature is expressed by a body, and is used for abstracting a request mode of a service request side: post request mode, get request mode, etc.; the request client features are expressed by clients and are used for abstracting http clients, and can specifically refer to an open-source guzzlehttp/guzzle (http client of one PHP) extension package, wherein a curl function used for initiating a single request and a curl_multi function set used for initiating batch requests are packaged in the extension package; the request response end features are expressed by a system and are used for abstracting an array formed by the name and the code of each third party service so as to throw out the state in the abnormality and record the requirement of the log when reporting errors; the request response address feature is expressed in URL, and is used for abstracting a uniform resource locator (Uniform Resource Locator, URL) of each request, which is provided by a third party service; the request parameter feature is indicated by an option, and is used for abstracting parameters for calling the size extension packet, and the parameters can include, but are not limited to, a request header, a timeout time, asynchronism or not and the like. In the third party interface prefabrication execution mode of the abstract class, the single request mode is expressed by exec and is used for being called when a single http request is processed, and the single request mode can be prefabricated according to the existing single request mode; the batch request mode is expressed by mulitExec, is used for executing http requests in batches, and the main parameters comprise a request entity set (particularly an array) formed by executing results returned by the entity creation mode createCurl for a plurality of times, wherein the request entity set can be prefabricated according to the existing batch request mode; the request header adding mode is expressed by addHeader, and is used for adding the request header when executing, and the request header adding mode can be obtained by prefabricating according to the existing adding mode; the response data processing mode is represented by a dealFunction, and is used for returning an anonymous function for processing response data when the response data processing mode is executed, and because the data structure returned by each third party service is the same (if different, the response data are processed by being divided into different classes), the response data returned by the third party service can be processed by the same method/anonymous function, and the response data can be obtained by conventional prefabrication according to processing requirements, for example, a first response data processing mode for processing an xml format file, a second response data processing mode for processing an html format file, a third response data processing mode for processing a json format file and the like are obtained by prefabrication, and in different abstract classes, the response data processing modes are different; the entity creation means, i.e. createCurl, is represented for creating a requesting entity Curl at execution time and may also create an anonymous function for use in the response data processing means, which may be prefabricated according to existing creation means.
Before the step S101, an association relationship between the third party interface and the third party interface class needs to be established, that is, a suitable existing third party interface class needs to be specified or a new third party interface class needs to be created according to the characteristics of the third party interface. The manner of designating an appropriate existing third party interface class may be, but is not limited to, designating according to a format of response data returned by the third party interface, for example, designating that an existing third party interface class including the first response data processing manner is associated if the response data format is an xml format; if the response data format is the hypertext markup language html format, designating the existing third party interface class associated with the second response data processing mode; if the response data format is json (JavaScript Object Notation, JS object numbered musical notation) format, designating an existing third party interface class associated with the third response data processing mode. The method for creating a new third party interface class can specifically be to inherit a prefabricated abstract class, and then adaptively adjust or add a personalized third party interface prefabricated execution mode according to the characteristics of the third party interface, for example, change part of the attribute characteristics of the third party interface or the third party interface prefabricated execution mode, so as to achieve the purposes of simplifying codes and facilitating management. The number of the prefabricated abstract classes may be multiple, that is, as shown in fig. 3, after one abstract class is obtained, the abstract class may be used as an abstract parent class, and multiple abstract subclasses that inherit the abstract class may be created, for example, an abstract subclass XmlApi that inherits the abstract parent class Api (including the first response data processing mode), an abstract subclass HtmlApi (including the second response data processing mode), an abstract subclass JsonApi (including the third response data processing mode), and the like, where the newly-built third party interface class may directly inherit a certain adjacent abstract subclass according to the situation, or may inherit the abstract parent class, and then determine whether to reproduce the response data processing mode in the class according to the requirement.
In the step S101, a third party interface single request for requesting to return single response data is specifically initiated by using a third party interface attribute feature in a third party interface class and a single request mode, including: according to the attribute characteristics of the third party interface, configuring a second interface address and a second request parameter for initiating a single request of the third party interface; and when the single request mode is invoked, initiating the third party interface single request by using the second interface address and the second request parameter. In detail, when configuring the second interface address and the second request parameter, the second interface address may be, but is not limited to being, automatically configured in particular according to the request response address feature, and the second request parameter may be, but is not limited to being, automatically configured in particular according to the request mode feature, the request client feature, the request response side feature, and/or the request parameter feature. Furthermore, the way the second interface address and the second request parameter are used when a single request way is employed is an existing conventional way. Through the step of initiating the single request of the third party interface, the third party interface request can be independently initiated to the third party service provider, response data can be obtained, and the single request application scene can be met.
S102, calling the judging mode in the class in the third party interface class after receiving the calling parameter.
In step S102, the judging manner in the class is added by an administrator in the class after the third party interface is created and inherits a prefabricated abstract class, so as to serve as one of the personalized third party interface prefabricated execution manners, and the judging manner is convenient to use when the third party interface associated with the class is called. The in-class judging mode is used for judging whether the current third-party interface request mode adopts a single request mode or a batch request mode according to the calling parameters. The judging mode in the class can be specifically a logic function predefined by an administrator, and after the calling parameter is imported, a response judging result can be returned: whether the current third party request mode adopts a single request mode or a batch request mode. The calling parameters are later than the request for calling the third party interface, and can be input by a caller according to the change condition of the use scene of the third party interface, and can also be acquired automatically by a prefabricated acquisition program according to the change condition of the use scene of the third party interface; for example, the calling parameter may simply be an input boolean value, and the in-class determination method may be, but is not limited to,: when the input Boolean value is 1, the current third party request mode is judged to adopt a single request mode, and when the input Boolean value is 0, the current third party request mode is judged to adopt a batch request mode.
S103, judging whether the current third-party interface request mode is a single request mode or a batch request mode according to the calling parameters and the judging modes in the class.
S104, if the batch request mode is adopted, a third party interface batch request for requesting to return M pieces of response data is initiated by using a third party interface attribute feature, an entity creation mode and a batch request mode in the third party interface class, and the batch response data is obtained, wherein M is a natural number not smaller than 2.
In step S104, if the determination result is that the current third party interface request mode adopts the batch request mode, the method indicates that the use scenario of the third party interface needs to be switched from the single request mode to the batch request mode, where the M value indicates the number of requests to obtain the response data or the number of times of the current remaining requests during the switching. For example, for a usage scenario in which a single request is 100 times targeted and 80 times of single requests are completed, if the single request is considered to be slower, and the remaining 20 pieces of response data are wanted to be acquired more quickly, the third party interface batch request with the M value of 20 can be initiated through the change of the call parameter.
In the step S104, a third party interface batch request for requesting to return M response data is initiated by using a third party interface attribute feature, an entity creation mode and a batch request mode in the third party interface class, which includes: according to the attribute characteristics of the third party interface, a first interface address and a first request parameter for initiating the third party interface batch request are configured; the entity creation mode is called for M times to obtain a request entity set containing M request entities; and when the batch request mode is called, initiating the third-party interface batch request by using the first interface address, the first request parameter and the request entity set. In detail, when configuring the first interface address and the first request parameter, the first interface address may be, but is not limited to being, automatically configured according to the request response address feature, and the first request parameter may be, but is not limited to being, automatically configured according to the request mode feature, the request client feature, the request response end feature, and/or the request parameter feature. In addition, the method of calling the entity creation method and obtaining the request entity set, and the method of using the first interface address, the first request parameter and the request entity set when adopting the batch request method are all existing conventional methods. Therefore, through the step of initiating the third-party interface batch request, the third-party interface request can be initiated to the third-party service provider in batches, and a single batch of multiple (for example, 20) response data can be acquired, so that the batch request application scene is satisfied.
S105, if the single request mode is judged according to the new calling parameters and the judging modes in the class, the third party interface attribute features and the single request mode in the third party interface class are used for initiating a third party interface single request for requesting to return single response data, and the single response data are obtained.
In step S105, if it is determined that the current request mode of the third party interface adopts the single request mode according to the new call parameter and the in-class determination mode, it indicates that the use scenario for the third party interface needs to be switched from the batch request mode to the single request mode. For example, after the batch request mode is adopted, there is a use scenario that batch response data cannot be obtained late due to unknown reasons (such as poor network communication quality or slow response data, etc.), in order to acquire a small amount of response data as soon as possible, a single request mode may be switched back by new changes to the call parameters so as to request to feed back single response data one by one.
The third party interface calling method described in detail in the foregoing steps S101 to S105 may call the third party interface by associating the third party interface class of the third party interface, that is, on one hand, the third party interface class may be utilized to process the request and the return logic of the associated third party interface for different service request sides in a centralized manner, thereby achieving the purposes of code compaction, maintenance convenience and easy management, and on the other hand, the method may automatically switch from a single request mode to a batch request mode when the interface request is initiated by calling the third party interface by changing the calling parameters. In addition, the single request mode can be automatically switched back by the batch request mode through the new change of the calling parameters, and the method is particularly suitable for flexible switching in the calling process.
The embodiment further provides a possible design one for processing response data after the call, that is, after the step S104, if the third party interface class further includes a response data processing manner, processing the batch of response data according to the format of the batch of response data by using the response data processing manner corresponding to the format and in the third party interface class, so as to obtain a processing result. Specifically, if the format is an xml format, the first response data processing mode can be called to process the batch response data, so that a corresponding processing result is obtained, and the third party interface class can be utilized to automatically process the returned response data in batches, so that the request call can be further conveniently completed. Similarly, after the step S101 or S105, the single response data may be processed according to the format of the single response data by using a response data processing manner corresponding to the format of the single response data and in the third party interface class, so as to obtain a processing result.
The present embodiment further specifically proposes a second possible design for changing the third party interface class on the basis of the foregoing first aspect, that is, before the step S101, the following steps S1001 and S1002 are further included.
S1001, detecting a third-party interface class changing operation performed by an administrator on a third-party interface management interface, wherein the third-party interface class changing operation is an operation for enabling the third-party interface class changing to inherit another prefabricated abstract class or changing a third-party interface attribute characteristic and/or a third-party interface prefabricated execution mode in the third-party interface class, and the prefabricated abstract class comprises the third-party interface attribute characteristic and the third-party interface prefabricated execution mode.
In step S1001, the third party interface management interface is a man-machine interaction interface facing the administrator, the hardware entity may be, but not limited to, a smart phone display screen or a computer display screen, and the software entity may be, but not limited to, a web page or a program page. The third party interface class change operation is mainly triggered and generated by an administrator and is used for achieving the purposes of changing and inheriting another prefabricated abstract class, updating the attribute characteristics of a third party interface in the class and/or the prefabricated execution mode of the third party interface, for example, inheriting another proper prefabricated abstract class or the existing third party interface class according to the characteristic change of the third party interface, and updating the request mode characteristics, the request client side characteristics, the request response end characteristics, the request response address characteristics, the request parameter characteristics, the single request mode, the batch request mode, the request header adding mode, the response data processing mode, the entity creation mode and the like, so that the third party interface requests initiated at different service request sides can be intensively adapted to the change of the interface response mode. In addition, when the administrator triggers the change operation of the third party interface class, the administrator may determine to perform the change operation according to the format change condition of the response data returned by the corresponding third party interface; and the format of the returned response data can be identified through a prefabricated identification program, and then another proper prefabricated abstract class is inherited by the triggering change according to the identification result, so that the purpose of automatically completing the change operation is realized.
S1002, responding to the third-party interface class changing operation, enabling the third-party interface class changing to inherit another prefabricated abstract class, or changing the attribute characteristics of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface to obtain a changed third-party interface class.
Through the foregoing steps S1001 to S1002, when the response mode of the third party interface is changed, only a place corresponding to the third party interface class needs to be updated and modified, so that the third party interface requests initiated at different service request sides can be adapted to the change of the interface response mode in a centralized manner, and centralized management of the third party interfaces is further facilitated.
As shown in fig. 4, in a second aspect of the present embodiment, a virtual device implementing the third party interface calling method of the first aspect or any one of the possible designs of the first aspect is provided, where the virtual device includes a single request unit, a calling unit, a judging unit, and a batch request unit;
the single request unit is used for initiating a single request of a third party interface for requesting to return single response data by using the attribute characteristics of the third party interface in the class of the third party interface and a single request mode to acquire the single response data;
The calling unit is used for calling the judging mode in the class in the third party interface class after receiving the calling parameter;
the judging unit is in communication connection with the calling unit and is used for judging whether the current third party interface request mode is a single request mode or a batch request mode according to the calling parameters and the judging modes in the class;
and the batch request unit is in communication connection with the judging unit and is used for initiating a third-party interface batch request for requesting to return M pieces of response data by using the third-party interface attribute characteristics, the entity creation mode and the batch request mode in the third-party interface class when the batch request mode is adopted, and the batch response data is obtained, wherein M is a natural number not less than 2.
In one possible design, the batch request unit includes a first request configuration subunit, an entity creation subunit, and a first request initiation subunit;
the first request configuration subunit is configured to configure a first interface address and a first request parameter for initiating the third party interface batch request according to the attribute characteristics of the third party interface;
the entity creation subunit is configured to obtain a request entity set containing M request entities by invoking the entity creation manner M times;
The first request initiating subunit is in communication connection with the first request configuring subunit and the entity creating subunit, and is configured to initiate the third party interface batch request by using the first interface address, the first request parameter and the request entity set when the batch request mode is invoked.
In one possible design, the single request unit is communicatively connected to the judging unit, and is configured to, after initiating a third party interface batch request for requesting to return M pieces of response data by using a third party interface attribute feature in the third party interface class, an entity creation mode and a batch request mode, and when judging that the single request mode is the single request mode again according to new call parameters and the judging mode in the class, initiate a third party interface single request for requesting to return the single response data by using the third party interface attribute feature in the third party interface class and the single request mode, and acquire the single response data.
In one possible design, the single request unit includes a second request configuration subunit and a second request initiation subunit;
the second request configuration subunit is configured to configure a second interface address and a second request parameter for initiating the single request of the third party interface according to the attribute characteristics of the third party interface;
And the second request initiating subunit is configured to initiate, when the single request mode is invoked, the third party interface single request using the second interface address and the second request parameter.
In one possible design, the system further comprises a data processing unit;
the data processing unit is in communication connection with the batch request unit and is used for processing the batch response data by using the response data processing mode corresponding to the format and in the third-party interface class according to the format of the batch response data after the batch response data is acquired in the third-party interface class, so as to obtain a processing result.
In one possible design, the data processing unit is further communicatively connected to the single request unit, and is configured to further include a response data processing manner in the third party interface class, and after obtaining the single response data, process the single response data according to the format of the single response data, using the response data processing manner corresponding to the format of the single response data and in the third party interface class, to obtain a processing result.
In one possible design, the device further comprises a change operation detection unit and a change operation response unit;
The change operation detection unit is configured to detect a third party interface class change operation performed by an administrator on a third party interface management interface before invoking a judging manner in a class in a third party interface class, where the third party interface class change operation is an operation for enabling the third party interface class change to inherit another prefabricated abstract class or to change a third party interface attribute feature and/or a third party interface prefabrication execution manner in the third party interface class, and the prefabricated abstract class includes the third party interface attribute feature and the third party interface prefabrication execution manner;
the change operation response unit is in communication connection with the change operation detection unit and is used for responding to the change operation of the third-party interface class, so that the third-party interface class change inherits another prefabricated abstract class, or the attribute characteristics of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface are changed, so that the changed third-party interface class is obtained.
The working process, working details and technical effects of the foregoing apparatus provided in the second aspect of the present embodiment may refer to the first aspect or any one of the first aspect may design the third party interface calling method, which is not described herein again.
As shown in fig. 5, a third aspect of the present embodiment provides a computer device for executing the third party interface calling method according to the first aspect or any one of the first aspects, where the computer device includes a memory and a processor that are communicatively connected, where the memory is configured to store a computer program, and the processor is configured to read the computer program and execute the third party interface calling method according to the first aspect or any one of the first aspects. As specific examples, the Memory may include, but is not limited to, random-Access Memory (RAM), read-Only Memory (ROM), flash Memory (Flash Memory), first-in first-out Memory (FIFO, first Input First Output), and/or first-in last-out Memory (FILO, first Input Last Output), etc.; the processor may not be limited to use with a microprocessor model number of the STM32F105 family. In addition, the computer device may include, but is not limited to, a power module, a display screen, and other necessary components.
The working process, working details and technical effects of the foregoing computer device provided in the third aspect of the present embodiment may refer to the first aspect or any one of the first aspects may design the third party interface calling method, which is not described herein.
A fourth aspect of the present embodiment provides a computer readable storage medium storing instructions comprising the first aspect or any one of the first aspects of the possible designs of the third party interface invoking method, i.e. the computer readable storage medium has instructions stored thereon that when executed on a computer perform the third party interface invoking method as described in the first aspect or any one of the first aspects of the possible designs of the first aspect. The computer readable storage medium refers to a carrier for storing data, and may include, but is not limited to, a floppy disk, an optical disk, a hard disk, a flash Memory, and/or a Memory Stick (Memory Stick), etc., where the computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
The working process, working details and technical effects of the foregoing computer readable storage medium provided in the fourth aspect of the present embodiment may refer to the first aspect or any one of the first aspects, and may possibly design the third party interface calling method, which is not described herein again.
A fifth aspect of the present embodiment provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the third party interface invocation method as described in the first aspect or any of the possible designs of the first aspect. Wherein the computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus.
The embodiments described above are merely illustrative and may or may not be physically separate if reference is made to the unit being described as a separate component; if a component is referred to as being a unit, it may or may not be a physical unit, may be located in one place, or may be distributed over multiple network elements. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some of the 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 invention.
Finally, it should be noted that the invention is not limited to the alternative embodiments described above, but can be used by anyone in various other forms of products in the light of the present invention. The above detailed description should not be construed as limiting the scope of the invention, which is defined in the claims and the description may be used to interpret the claims.

Claims (10)

1. A third party interface invoking method, comprising:
initiating a single request of a third party interface for requesting to return single response data by using the attribute characteristics of the third party interface in the third party interface class and a single request mode to acquire the single response data;
calling a class judgment mode in the class of the third party interface after receiving a calling parameter, wherein the calling parameter is later than a request for calling the third party interface, and is acquired automatically by a prefabricated acquisition program according to the use scene change condition of the third party interface when a single request mode is found to be slower and residual response data is wanted to be acquired faster, the calling parameter is changed into a mode for enabling the class judgment mode to judge whether the current third party interface request mode adopts a batch request mode according to the calling parameter when the single request mode is found to be slower and the residual response data is wanted to be acquired faster, and the class judgment mode is used for judging whether the current third party interface request mode adopts the single request mode or the batch request mode according to the calling parameter;
judging whether the current third-party interface request mode is a single request mode or a batch request mode according to the calling parameters and the judging modes in the class;
And if the batch request mode is adopted, initiating a third-party interface batch request for requesting to return M pieces of response data by using a third-party interface attribute feature, an entity creation mode and a batch request mode in the third-party interface class, and acquiring the batch response data, wherein M is a natural number not less than 2.
2. The method of claim 1, wherein initiating a third party interface batch request for requesting to return M response data using a third party interface attribute feature, an entity creation means, and a batch request means in the third party interface class comprises:
according to the attribute characteristics of the third party interface, a first interface address and a first request parameter for initiating the third party interface batch request are configured;
the entity creation mode is called for M times to obtain a request entity set containing M request entities;
and when the batch request mode is called, initiating the third-party interface batch request by using the first interface address, the first request parameter and the request entity set.
3. The method of claim 1, wherein initiating a third party interface single request for requesting return of single response data using a third party interface attribute feature and a single request mode in a third party interface class comprises:
According to the attribute characteristics of the third party interface, configuring a second interface address and a second request parameter for initiating a single request of the third party interface;
and when the single request mode is invoked, initiating the third party interface single request by using the second interface address and the second request parameter.
4. The method of claim 1, wherein if the third party interface class further includes a response data processing means;
after obtaining the batch response data, the method further comprises:
and processing the batch response data by using a response data processing mode which corresponds to the format and is in the third party interface class according to the format of the batch response data, so as to obtain a processing result.
5. The method of claim 1, wherein prior to invoking the in-class determination in the third party interface class, the method further comprises:
detecting a third-party interface class changing operation performed on a third-party interface management interface by an administrator, wherein the third-party interface class changing operation is an operation for enabling the third-party interface class changing to inherit another prefabricated abstract class or changing a third-party interface attribute characteristic and/or a third-party interface prefabricated execution mode in the third-party interface class, and the prefabricated abstract class comprises the third-party interface attribute characteristic and the third-party interface prefabricated execution mode;
And responding to the third-party interface class changing operation, so that the third-party interface class changing inherits another prefabricated abstract class, or the third-party interface attribute characteristics and/or the third-party interface prefabricated execution mode in the third-party interface class are changed, so as to obtain a changed third-party interface class.
6. The third party interface calling device is characterized by comprising a single request unit, a calling unit, a judging unit and a batch request unit;
the single request unit is used for initiating a single request of a third party interface for requesting to return single response data by using the attribute characteristics of the third party interface in the class of the third party interface and a single request mode to acquire the single response data;
the calling unit is used for calling a class judging mode in the class of the third party interface after receiving a calling parameter, wherein the calling parameter is later than a request for calling the third party interface, and is automatically acquired by a prefabricated acquisition program according to the use scene change condition of the third party interface when a single request mode is found to be slower and residual response data are required to be acquired more quickly, the calling parameter is changed into a mode for enabling the class judging mode to judge whether the current third party interface request mode adopts a batch request mode according to the calling parameter when the single request mode is found to be slower and the residual response data are required to be acquired more quickly, and the class judging mode is used for judging whether the current third party interface request mode adopts the single request mode or the batch request mode according to the calling parameter;
The judging unit is in communication connection with the calling unit and is used for judging whether the current third party interface request mode is a single request mode or a batch request mode according to the calling parameters and the judging modes in the class;
and the batch request unit is in communication connection with the judging unit and is used for initiating a third-party interface batch request for requesting to return M pieces of response data by using the third-party interface attribute characteristics, the entity creation mode and the batch request mode in the third-party interface class when the batch request mode is adopted, and the batch response data is obtained, wherein M is a natural number not less than 2.
7. The apparatus of claim 6, further comprising a data processing unit;
the data processing unit is in communication connection with the batch request unit and is used for processing the batch response data by using the response data processing mode corresponding to the format and in the third-party interface class according to the format of the batch response data after the batch response data is acquired in the third-party interface class, so as to obtain a processing result.
8. The apparatus according to claim 6, further comprising a change operation detecting unit and a change operation responding unit;
The change operation detection unit is configured to detect a third party interface class change operation performed by an administrator on a third party interface management interface before invoking a judging manner in a class in a third party interface class, where the third party interface class change operation is an operation for enabling the third party interface class change to inherit another prefabricated abstract class or to change a third party interface attribute feature and/or a third party interface prefabrication execution manner in the third party interface class, and the prefabricated abstract class includes the third party interface attribute feature and the third party interface prefabrication execution manner;
the change operation response unit is in communication connection with the change operation detection unit and is used for responding to the change operation of the third-party interface class, so that the third-party interface class change inherits another prefabricated abstract class, or the attribute characteristics of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface are changed, so that the changed third-party interface class is obtained.
9. A computer device comprising a memory and a processor in communication, wherein the memory is adapted to store a computer program and the processor is adapted to read the computer program and to perform a third party interface invoking method as claimed in any of claims 1 to 5.
10. A computer readable storage medium having instructions stored thereon which, when executed on a computer, perform the third party interface invocation method of any of claims 1-5.
CN202010366952.0A 2020-04-30 2020-04-30 Third party interface calling method and device Active CN111552578B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010366952.0A CN111552578B (en) 2020-04-30 2020-04-30 Third party interface calling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010366952.0A CN111552578B (en) 2020-04-30 2020-04-30 Third party interface calling method and device

Publications (2)

Publication Number Publication Date
CN111552578A CN111552578A (en) 2020-08-18
CN111552578B true CN111552578B (en) 2023-08-04

Family

ID=72000385

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010366952.0A Active CN111552578B (en) 2020-04-30 2020-04-30 Third party interface calling method and device

Country Status (1)

Country Link
CN (1) CN111552578B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112015494A (en) * 2020-08-27 2020-12-01 中国平安财产保险股份有限公司 Third-party API tool calling method, system and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal
CN109240838A (en) * 2018-09-20 2019-01-18 深圳市牛鼎丰科技有限公司 Interface call method, device, computer equipment and storage medium
CN109656807A (en) * 2018-11-01 2019-04-19 平安科技(深圳)有限公司 Interface mock test method, device, equipment and storage medium based on information security

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6715147B1 (en) * 1997-03-31 2004-03-30 International Business Machines Corporation Method and system for interfacing a plurality of applications conforming to a standard
US20050080930A1 (en) * 2003-10-14 2005-04-14 International Business Machines Corporation Method and apparatus for processing service requests in a service-oriented architecture
US8577991B2 (en) * 2008-03-31 2013-11-05 Sap Ag Managing consistent interfaces for internal service request business objects across heterogeneous systems
CN103345420B (en) * 2013-06-03 2017-12-22 百度在线网络技术(北京)有限公司 Batch calls the mthods, systems and devices of api interface
CN104217314B (en) * 2014-08-26 2018-01-09 北京京东尚科信息技术有限公司 Routing iinformation grasping means and device
CN108762955A (en) * 2018-05-30 2018-11-06 平安普惠企业管理有限公司 Interface call method, device, computer equipment and storage medium
US10684871B2 (en) * 2018-06-03 2020-06-16 Apple Inc. Multi-process model for cross-platform applications

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal
CN109240838A (en) * 2018-09-20 2019-01-18 深圳市牛鼎丰科技有限公司 Interface call method, device, computer equipment and storage medium
CN109656807A (en) * 2018-11-01 2019-04-19 平安科技(深圳)有限公司 Interface mock test method, device, equipment and storage medium based on information security

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Android平台的即时通信中间件的研究与实现;皮成;《中国优秀硕士学位论文全文数据库 信息科技辑》(第11期);I136-242 *

Also Published As

Publication number Publication date
CN111552578A (en) 2020-08-18

Similar Documents

Publication Publication Date Title
JP6740373B2 (en) Page component dynamic layout
US9904585B1 (en) Error handling in executing workflow state machines
WO2020233369A1 (en) Method for improving software integration system on basis of simulated port, and related device
US9766927B1 (en) Data flow management in processing workflows
CN108415804B (en) Method for acquiring information, terminal device and computer readable storage medium
CN106569856B (en) A kind of loading method and device of application view resource file
CN103942225A (en) Method and system for invoking resources of Hybrid App client and client
CN110224896B (en) Network performance data acquisition method and device and storage medium
US10284660B1 (en) Data flow tokens to trace execution of services in a service provider network
US11699073B2 (en) Network off-line model processing method, artificial intelligence processing device and related products
CN108647032B (en) Application loading method and device, computer device and computer readable storage medium
US20220032192A1 (en) User interface processing method and device
CN103530338A (en) Frame for carrying out page rendering on calculation equipment and page generation method
CN110598135A (en) Network request processing method and device, computer readable medium and electronic equipment
CN111552578B (en) Third party interface calling method and device
CN108595698A (en) picture loading method, terminal device and medium
US9830307B1 (en) Ahead of time compilation of content pages
US9916391B2 (en) Method, apparatus and terminal for webpage content browsing
CN115809056A (en) Component multiplexing implementation method and device, terminal equipment and readable storage medium
CN108804088A (en) Protocol processes method and apparatus
WO2022099913A1 (en) Interface configuration method and apparatus, and device and medium
CN116136772A (en) Buried point data acquisition method and device
CN113448751A (en) DSL-based interface response method, device, equipment and medium
CN105939227B (en) Service configuration method, system and server based on CMDB
CN111399806A (en) Component 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