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

Third-party interface calling method and device Download PDF

Info

Publication number
CN111552578A
CN111552578A CN202010366952.0A CN202010366952A CN111552578A CN 111552578 A CN111552578 A CN 111552578A CN 202010366952 A CN202010366952 A CN 202010366952A CN 111552578 A CN111552578 A CN 111552578A
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.)
Granted
Application number
CN202010366952.0A
Other languages
Chinese (zh)
Other versions
CN111552578B (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

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • 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

Landscapes

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

Abstract

The invention relates to the technical field of internet, and discloses a third party interface calling method and a third party interface calling device, 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 third party interface class can be utilized to intensively process the request and return logic of the associated third party interface aiming at different service request sides, so that the purposes of code simplification, convenient maintenance and easy management are achieved, and on the other hand, through the change of calling parameters, when the third party interface is called to initiate an interface request, a single request mode is automatically switched into a batch request mode. In addition, the batch request mode can be automatically switched back to the single request mode through 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 structure to the micro-service structure, for example, the original e-commerce website, and the back end can be split into order service, warehouse service, member service, activity service, and the like, so that when a certain service (e.g., an activity service) processes a business logic, a plurality of third-party interfaces of other services are called to request for obtaining the relevant response data of the services, and then the local business logic is completed by using the response data, thereby achieving the purpose of external service. For example, an active service may require a third party interface that invokes a number of other services, such as order services, warehousing services, and membership services.
However, in the conventional third-party interface management method, since a plurality of other services (for example, order service, warehousing service, member service, and the like with respect to active service) are discretely distributed at different locations, when a third-party interface response method of a certain service is changed (for example, a change occurs in a response interface address, a response request parameter, a format of returned response data, and the like), it is necessary to modify a third-party interface request (for example, an interface address, a request parameter, a response data receiving method, a processing method, and the like) for initiating a service request on a different service request side one by one, which causes problems of complicated codes, 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, the former can request to return single response data, and the latter can request to return a plurality of batch response data.
Disclosure of Invention
In order to solve the problems that management is not easy and a single request mode and a batch request mode cannot be flexibly switched in the existing 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 which are convenient for managing and switching the request modes.
In a first aspect, the present invention provides a third-party interface invoking method, including:
using third party interface attribute characteristics in a third party interface class and a single request mode to initiate a third party interface single request for requesting to return single response data, and acquiring the single response data;
after receiving the calling parameter, calling a class-in judgment mode in the third-party interface class;
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 in-class judgment mode;
and if the request is the batch request mode, initiating a third-party interface batch request for requesting to return M 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 batch response data, wherein M is a natural number not less than 2.
Based on the above invention, the third-party interface can be called by associating the third-party interface class of the third-party interface, that is, on one hand, the third-party interface class can be used to centrally process the request and return logic of the associated third-party interface for different service request sides, so as to achieve the purposes of code simplification, convenient maintenance and easy management, and on the other hand, by changing the calling parameters, when the third-party interface is called to initiate an interface request, the third-party interface can be automatically switched from a single request mode to a batch request mode.
In one possible design, the third-party interface batch request for requesting to return M pieces of 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:
configuring a first interface address and a first request parameter for initiating the third-party interface batch request according to the third-party interface attribute characteristics;
calling the entity creating mode 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 batch, a single batch of multiple response data can be acquired, and the application scene of the batch request can be met.
In one possible design, initiating a third party interface single request for requesting return of a single response data using the third party interface attribute features in a third party interface class and a single request mode includes:
configuring 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 when the single request mode is called, 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 singly initiated to the third-party service provider, the response data can be obtained, and the single request application scene can be met.
In one possible design, if the third-party interface class further includes a response data processing mode;
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 to obtain a processing result.
Through the design, the returned response data can be automatically processed in batch by utilizing the third-party interface class, and the request calling is further conveniently completed.
In one possible design, before the invoking the intra-class determination in the third party interface class, the method further includes:
detecting third-party interface class change operation performed by an administrator on a third-party interface management interface, wherein the third-party interface class change operation is an operation for enabling the third-party interface class to change and inherit another prefabricated abstract class or changing third-party interface attribute characteristics 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 characteristics and the third-party interface prefabricated execution mode;
responding to the third-party interface class change operation, enabling the third-party interface class to change and inherit another prefabricated abstract class, or changing the third-party interface attribute characteristics and/or the third-party interface prefabricated execution mode in the third-party interface class, so as to obtain the changed third-party interface class.
Through the design, when the response mode of the third-party interface is changed, the third-party interface requests initiated at different service request sides can be intensively adapted to the change of the interface response mode only by updating and modifying one place of the corresponding third-party interface type, and the centralized management of the third-party interface is further facilitated.
In a second aspect, the present invention provides a third-party interface management apparatus, 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 third-party interface request 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, and acquiring the single response data;
the calling unit is used for calling the in-class judgment mode 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 intra-class judging mode;
the batch request unit is in communication connection with the judgment unit and is used for 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 when the batch request mode is the batch request mode, and acquiring batch response data, 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, according to the third-party interface attribute feature, a first interface address and a first request parameter for initiating the third-party interface batch request;
the entity creating subunit is used for calling the entity creating mode for M times to obtain a request entity set containing M request entities;
the first request initiating subunit is communicatively connected to 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 determining 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, an entity creation manner, and a batch request manner in the third-party interface class, and when determining that the single request manner is again based on a new call parameter and the determination manner in the class, initiate a third-party interface single request for requesting to return a single piece of response data by using the third-party interface attribute feature and the single request manner in the third-party interface class, and acquire a single piece of 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, according to the third-party interface attribute feature, a second interface address and a second request parameter for initiating the single third-party interface request;
and the second request initiating subunit is configured to initiate the third-party interface single request by using the second interface address and the second request parameter when the single request mode is called.
In one possible design, a data processing unit is also included;
and the data processing unit is in communication connection with the batch request unit and is used for processing the batch response data in a 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, so as to obtain a processing result.
In a 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 acquiring the single response data, process the single response data in the response data processing manner in the third-party interface class corresponding to the format of the single response data according to the format of the single response data, so as to obtain a processing result.
In one possible design, the system further comprises a change operation detection unit and a change operation response unit;
the change operation detection unit is used for detecting the change operation of the third-party interface class performed on a third-party interface management interface by an administrator before calling a class-in-class judgment mode in the third-party interface class, wherein the change operation of the third-party interface class is an operation for enabling the third-party interface class to change and inherit another prefabricated abstract class or changing the attribute characteristic of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface, and the prefabricated abstract class comprises the attribute characteristic of the third-party interface and the prefabricated execution mode of the third-party interface;
and 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 changes and inherits another prefabricated abstract class, or changes 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 the changed third party interface class.
In a third aspect, the present invention provides a computer device, comprising a memory and a processor, wherein the memory is used for storing a computer program, and the processor is used for reading the computer program and executing the third party interface calling method as described 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 stored thereon instructions which, when executed on a computer, perform the third party interface invocation method as described in the first aspect or any one of the possible designs of the first aspect.
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 call method as described above in the first aspect or any one of the possible designs of the first aspect.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a third-party interface calling method provided by the present invention.
FIG. 2 is an exemplary diagram of third party interface attribute features and third party interface pre-production implementations in abstract classes provided by the present invention.
FIG. 3 is an exemplary diagram of an inheritance relationship between abstract parent classes and abstract child classes provided by the present invention.
Fig. 4 is a schematic structural diagram of a third-party interface invoking device provided in the present invention.
Fig. 5 is a schematic structural diagram of a computer device provided by the present invention.
Detailed Description
The invention is further described with reference to the following figures and specific embodiments. It should be noted that the description of the embodiments is provided to help understanding of the present invention, but the present invention is not limited thereto. Specific structural and functional details disclosed herein are merely illustrative 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. 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" as may appear herein, it is merely an associative relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, B exists alone, and A and B exist at the same time; for the term "/and" as may appear herein, which describes another associative object relationship, it means that two relationships may exist, e.g., a/and B, may mean: a exists independently, and A and B exist independently; in addition, for the character "/" that may appear herein, it generally means that the former and latter associated objects are in 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. Conversely, if a unit is referred to herein as being "directly connected" or "directly coupled" to another unit, it is intended that no intervening units are present. In addition, other words used to describe the relationship between elements should be interpreted in a similar manner (e.g., "between … …" versus "directly between … …", "adjacent" versus "directly adjacent", etc.).
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" and/or "including," when used herein, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, numbers, steps, operations, elements, components, and/or groups thereof.
It should also be noted that, in some alternative designs, the functions/acts noted may occur out of the order noted in the figures. 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 facilitate a thorough understanding of 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, systems may be shown in block diagrams in order not to obscure the examples in unnecessary detail. In other instances, well-known processes, structures and techniques may be shown without unnecessary detail in order to avoid obscuring example embodiments.
As shown in fig. 1, the third-party interface invoking method provided in the first aspect of this embodiment may include, but is not limited to, the following steps S101 to S105.
S101, initiating a single third-party interface request for requesting to return single response data by using the third-party interface attribute characteristics and a single request mode in a third-party interface class, and acquiring the single response data.
In the step S101, the third party interface class is associated with a third party interface to be called and includes a third party interface attribute feature and a third party interface pre-made 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 performing abstract expression on a third party interface object. In the abstract class, the third-party interface attribute feature is used for performing abstract expression on specific interface attribute contents, 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, and the like, so that the contents of the third-party interface attribute feature can be enriched, and flexible management is facilitated; the third-party interface prefabricated execution mode is used for expressing a prefabricated execution mode for calling a third-party interface, and can be but not limited to a single request mode, a batch request mode, a request header adding mode, a response data processing mode and/or an entity creating mode for creating a request entity and the like, so that the content of the third-party interface prefabricated execution mode can be enriched, and flexible management and calling are facilitated.
In the step S101, specifically, taking a third-party interface based on the english 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 represented by body, and is used for the request mode of the abstract service request side: a Post request mode, a Get request mode, and the like; the request client is characterized by being represented by a client, is used for abstracting an http client, can specifically quote a guzzlehttp/guzzle (http client of a PHP) extension packet with an open source, and encapsulates a curl function for initiating a single request and a curl _ multi function array for initiating a batch request; the request response end is characterized by being represented by a system and 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 exception and the requirement of recording a log when an error is reported; the request response address feature is expressed in URL, and is used for abstracting Uniform Resource Locator (URL) of each request, and the URL is provided by a third-party service; the request parameter characteristics are represented by options, and parameters for abstracting and calling the folder extension packet can include, but are not limited to, a request header, timeout time, whether asynchronous 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, is used for being called when a single http request is processed, and can be prefabricated according to the existing single request mode; the batch request mode is expressed by mulitExec and is used for executing http requests in batches, and the main parameters include a request entity set (specifically, an array) formed by executing results returned by the entity creation mode createCurl for multiple times, and the request entity set can be obtained by prefabricating according to the existing batch request mode; the request head adding mode is represented by addHeader, is used for adding the request head header during execution and can be obtained by prefabricating according to the existing adding mode; the response data processing mode is expressed by dealFunction, and is used for returning an anonymous function for processing response data during execution, and as the data structures returned by each third-party service are the same (if different, the data structures 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 can be obtained by performing 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 jml-format file and the like are obtained by prefabrication, and in different abstract classes, the response data processing modes are different; said entity creation means is represented by createCurl for creating a requesting entity curl upon execution and may also create an anonymous function for use in said response data handling means, which may be pre-made 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 method for specifying a suitable existing third-party interface class may be, but is not limited to, specifying according to a format of response data returned by the third-party interface, for example, if the format of the response data is an xml format, specifying to associate an existing third-party interface class including the first response data processing method; if the response data format is a hypertext markup language html format, the existing third party interface class which contains the second response data processing mode is appointed to be associated; and if the response data format is a json (JavaScript Object Notation) format, specifying and associating the existing third party interface class including the third response data processing mode. The creating of a new third-party interface class may 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 third-party interface attribute features 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 an abstract class is obtained, the abstract class may be used as an abstract parent class, and then multiple abstract subclasses inheriting the abstract parent class are created, for example, an abstract subclass xmilapi (including the first response data processing mode), an abstract subclass HtmlApi (including the second response data processing mode), and an abstract subclass jsonnai (including the third response data processing mode) of the abstract parent class Api, and the like, where the newly created third party interface class may directly inherit an approaching abstract subclass according to the situation, or inherit the abstract parent class, and then determine whether to re-perform the response data processing mode in the abstract class according to the requirement.
In step S101, specifically, initiating a third-party interface single request for requesting to return single response data by using the third-party interface attribute feature and the single request mode in the third-party interface class, including: configuring 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 when the single request mode is called, 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 according to the request response address characteristic, and the second request parameter may be, but is not limited to being, automatically configured according to the request mode characteristic, the request client characteristic, the request response end characteristic, and/or the request parameter characteristic. In addition, the manner of using the second interface address and the second request parameter when adopting the single request manner is the conventional manner. Therefore, through the step of initiating the single third-party interface request, the third-party interface request can be initiated to the third-party service provider individually, response data can be acquired, and the single request application scene can be met.
And S102, after receiving the calling parameter, calling a class-in judgment mode in the third-party interface class.
In the step S102, after the third-party interface is created and inherits a pre-made abstract class, the judgment mode in the class is added by an administrator to be used as one of the personalized third-party interface pre-made execution modes, so that the judgment mode is convenient to use when the associated third-party interface is called. And 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 parameter. The intra-class judgment mode may specifically be a logic function predefined by an administrator, and after the call parameter is imported, a judgment result of a response may be returned: the current third party request mode is either a single request mode or a batch request mode. The calling parameter is later than the calling parameter which is obtained by inputting the calling parameter by a caller according to the change condition of the use scene of the third party interface or automatically acquiring the calling parameter by a prefabricated acquisition program according to the change condition of the use scene of the third party interface; for example, the call parameter may be simply an input boolean value, and the intra-class determination method may be, but is not limited to: and when the input Boolean value is '1', judging that the current third party request mode adopts a single request mode, and when the input Boolean value is '0', judging that the current third party request mode adopts a batch request mode.
And 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 intra-class judgment mode.
And S104, if the request mode is the batch request mode, initiating a third-party interface batch request for requesting to return M 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 batch response data, wherein M is a natural number not less than 2.
In the step S104, if the determination result is that the current third-party interface request mode adopts a batch request mode, it indicates that a single request mode needs to be switched to the batch request mode for the usage scenario of the third-party interface, where the M value indicates the number of response data that needs to be acquired or the number of times of current remaining requests during switching. For example, for a usage scenario targeting 100 single requests and having completed 80 single requests, if it is considered that the single request manner is slow and it is desired to acquire the remaining 20 response data more quickly, the third-party interface batch request with the M value of 20 may be initiated by changing the call parameter.
In step S104, specifically, initiating a third-party interface batch request for requesting to return M pieces of response data by using the third-party interface attribute feature, the entity creation mode, and the batch request mode in the third-party interface class includes: configuring a first interface address and a first request parameter for initiating the third-party interface batch request according to the third-party interface attribute characteristics; calling the entity creating mode 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 characteristic, and the first request parameter may be, but is not limited to being, automatically configured according to the request mode characteristic, the request client characteristic, the request response end characteristic, and/or the request parameter characteristic. In addition, the manner of calling the entity creation manner and obtaining the request entity set, and the manner of using the first interface address, the first request parameter and the request entity set when the batch request manner is adopted are all conventional manners. Therefore, through the step of initiating the batch request of the third party interface, the third party interface request can be initiated to the third party service provider in batch, and a single batch of multiple (for example, 20) response data can be acquired, so that the application scenario of the batch request is satisfied.
And S105, if the single request mode is determined again according to the new calling parameters and the judgment mode in the class, initiating a single third-party interface request for requesting to return single response data by using the third-party interface attribute characteristics in the third-party interface class and the single request mode, and acquiring the single response data.
In the step S105, if it is determined again that the current third-party interface request mode adopts the single request mode according to the new call parameter and the intra-class determination mode, it indicates that the batch request mode needs to be switched back to the single request mode for the use scenario of the third-party interface. For example, after the batch request method is adopted, there is a usage scenario in which batch response data cannot be obtained later due to unknown reasons (for example, poor network communication quality or slow response data), and in order to obtain a small amount of response data as soon as possible, a single request method may be switched back by a new change to the call parameter, so as to request feedback of single response data one by one.
Therefore, by the third-party interface calling method described in detail in the foregoing steps S101 to S105, the third-party interface can be called by associating the third-party interface class of the third-party interface, that is, on one hand, the third-party interface class can be used to centrally process the request and return logic of the associated third-party interface for different service request sides, so as to achieve the purposes of code simplification, convenient maintenance and easy management, and on the other hand, by changing the calling parameter, when the third-party interface is called to initiate an interface request, the single request mode is automatically switched to the batch request mode. In addition, the batch request mode can be automatically switched back to the single request mode through new change of the calling parameters, and the method is particularly suitable for flexible switching in the calling process.
In this embodiment, on the basis of the first aspect, a first possible design for processing response data after the call is further specifically provided, that is, after the step S104, if a response data processing manner is further included in the third-party interface class, the batch response data is processed by using the response data processing manner corresponding to the format and in the third-party interface class according to the format of the batch response data, so as to obtain a processing result. Specifically, if the format is an xml format, the first response data processing mode may be invoked to process the batch response data to obtain a corresponding processing result, so that the third-party interface class may be used to automatically perform batch processing on the returned response data, thereby further facilitating completion of request invocation. Similarly, after step S101 or S105, the single response data may be processed by using a response data processing manner corresponding to the format of the single response data and in the third-party interface class according to the format of the single response data, so as to obtain a processing result.
In this embodiment, on the basis of the first aspect, a second possible design for changing the third-party interface class is further specifically proposed, that is, before the step S101, the following steps S1001 and S1002 are further included.
S1001, detecting 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 to change and inherit another prefabricated abstract class or change third party interface attribute characteristics 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 characteristics and the third party interface prefabricated execution mode.
In step S1001, the third-party interface management interface is a human-computer interaction interface facing to an administrator, the hardware entity may be, but is not limited to, a smartphone display screen or a computer display screen, and the software entity may be, but is not limited to, a web page or a program page. The third-party interface class change operation is mainly triggered by an administrator and is used for achieving the purposes that the change inherits another prefabricated abstract class and updates the attribute characteristics of the third-party interface in the class and/or the prefabricated execution mode of the third-party interface, for example, inheriting another suitable pre-formed abstract class or an existing third party interface class according to the third party interface characteristic change specification, updating the request mode feature, the request client side feature, the request response address feature, the request parameter feature, the single request mode, the batch request mode, the request header adding mode, the response data processing mode and/or the entity creating mode and the like, so as to enable the third party interface requests initiated at different service request sides to be intensively adapted to the change of the interface response mode. In addition, when the administrator triggers the third-party interface class change operation, the administrator may determine to perform the change operation according to, but not limited 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 the change is triggered to inherit another proper prefabricated abstract class according to the identification result, so that the purpose of automatically finishing the change operation is realized.
S1002, responding to the third party interface class changing operation, enabling the third party interface class to change and 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 steps S1001 to S1002, when the response mode of the third-party interface is changed, only one place of the corresponding third-party interface type needs to be updated and modified, so that the third-party interface requests initiated at different service request sides can be made to intensively adapt to the change of the interface response mode, and the centralized management of the third-party interface is further facilitated.
As shown in fig. 4, a second aspect of this embodiment provides a virtual device for implementing the third-party interface calling method in any one of the first aspect or the first aspect, where the virtual device includes a single request unit, a calling unit, a determining unit, and a batch request unit;
the single request unit is used for initiating a single third-party interface request 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, and acquiring the single response data;
the calling unit is used for calling the in-class judgment mode 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 intra-class judging mode;
the batch request unit is in communication connection with the judgment unit and is used for 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 when the batch request mode is the batch request mode, and acquiring batch response data, 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, according to the third-party interface attribute feature, a first interface address and a first request parameter for initiating the third-party interface batch request;
the entity creating subunit is used for calling the entity creating mode for M times to obtain a request entity set containing M request entities;
the first request initiating subunit is communicatively connected to 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 determining 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, an entity creation manner, and a batch request manner in the third-party interface class, and when determining that the single request manner is again based on a new call parameter and the determination manner in the class, initiate a third-party interface single request for requesting to return a single piece of response data by using the third-party interface attribute feature and the single request manner in the third-party interface class, and acquire a single piece of 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, according to the third-party interface attribute feature, a second interface address and a second request parameter for initiating the single third-party interface request;
and the second request initiating subunit is configured to initiate the third-party interface single request by using the second interface address and the second request parameter when the single request mode is called.
In one possible design, a data processing unit is also included;
and the data processing unit is in communication connection with the batch request unit and is used for processing the batch response data in a 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, so as to obtain a processing result.
In a 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 acquiring the single response data, process the single response data in the response data processing manner in the third-party interface class corresponding to the format of the single response data according to the format of the single response data, so as to obtain a processing result.
In one possible design, the system further comprises a change operation detection unit and a change operation response unit;
the change operation detection unit is used for detecting the change operation of the third-party interface class performed on a third-party interface management interface by an administrator before calling a class-in-class judgment mode in the third-party interface class, wherein the change operation of the third-party interface class is an operation for enabling the third-party interface class to change and inherit another prefabricated abstract class or changing the attribute characteristic of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface, and the prefabricated abstract class comprises the attribute characteristic of the third-party interface and the prefabricated execution mode of the third-party interface;
and 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 changes and inherits another prefabricated abstract class, or changes 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 the changed third party interface class.
For a working process, working details, and technical effects of the foregoing apparatus provided in the second aspect of this embodiment, reference may be made to the third-party interface invoking method possibly designed in any one of the first aspect or the first aspect, which is not described herein again.
As shown in fig. 5, a third aspect of this embodiment provides a computer device for executing any one of the first aspect or the first aspect that may design the third-party interface calling method, where the computer device includes a memory and a processor, where the memory is used for storing a computer program, and the processor is used for reading the computer program and executing the third-party interface calling method as any one of the first aspect or the first aspect that may design. For example, the Memory may include, but is not limited to, a Random-Access Memory (RAM), a Read-Only Memory (ROM), a Flash Memory (Flash Memory), a First-in First-out (FIFO) Memory, and/or a First-in Last-out (FILO) Memory, and the like; the processor may not be limited to the microprocessor of the model number employing the STM32F105 family. In addition, the computer device may also include, but is not limited to, a power module, a display screen, and other necessary components.
For the working process, the working details, and the technical effects of the foregoing computer device provided in the third aspect of this embodiment, reference may be made to the third-party interface invoking method possibly designed in any one of the first aspect or the first aspect, which is not described herein again.
A fourth aspect of this embodiment provides a computer-readable storage medium storing instructions that include any one of the first aspect or the first aspect for possibly designing the third-party interface invoking method, that is, the computer-readable storage medium stores instructions that, when executed on a computer, perform the third-party interface invoking method according to any one of the first aspect or the first aspect. The computer-readable storage medium refers to a carrier for storing data, and may include, but is not limited to, floppy disks, optical disks, hard disks, flash memories, flash disks and/or Memory sticks (Memory sticks), etc., and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
For a working process, working details, and technical effects of the foregoing computer-readable storage medium provided in the fourth aspect of this embodiment, reference may be made to the first aspect or any one of the first aspects that may be designed to implement the third-party interface invoking method, which is not described herein again.
A fifth aspect of the present invention provides a computer program product comprising instructions, which when run on a computer, cause the computer to execute the third party interface invocation method according to the first aspect or any one of the possible designs of the first aspect. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable devices.
The embodiments described above are merely illustrative, and may or may not be physically separate, if referring to units illustrated as separate components; if reference is made to a component displayed as a unit, it may or may not be a physical unit, and may be located in one place or distributed over a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present 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: modifications may be made to the embodiments described above, or equivalents may be substituted for some of the features described. And such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Finally, it should be noted that the present invention is not limited to the above alternative embodiments, and that various other forms of products can be obtained by anyone in light of the present invention. The above detailed description should not be taken as limiting the scope of the invention, which is defined in the claims, and which the description is intended to be interpreted accordingly.

Claims (10)

1. A third party interface calling method is characterized by comprising the following steps:
using third party interface attribute characteristics in a third party interface class and a single request mode to initiate a third party interface single request for requesting to return single response data, and acquiring the single response data;
after receiving the calling parameter, calling a class-in judgment mode in the third-party interface class;
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 in-class judgment mode;
and if the request is the batch request mode, initiating a third-party interface batch request for requesting to return M 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 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 return of M response data using third party interface attribute features, entity creation means, and batch request means in the third party interface class comprises:
configuring a first interface address and a first request parameter for initiating the third-party interface batch request according to the third-party interface attribute characteristics;
calling the entity creating mode 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 a single response data using third party interface attribute features in a third party interface class and a single request mode comprises:
configuring 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 when the single request mode is called, 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 to obtain a processing result.
5. The method of claim 1, wherein prior to invoking the in-class determination mode in the third party interface class, the method further comprises:
detecting third-party interface class change operation performed by an administrator on a third-party interface management interface, wherein the third-party interface class change operation is an operation for enabling the third-party interface class to change and inherit another prefabricated abstract class or changing third-party interface attribute characteristics 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 characteristics and the third-party interface prefabricated execution mode;
responding to the third-party interface class change operation, enabling the third-party interface class to change and inherit another prefabricated abstract class, or changing the third-party interface attribute characteristics and/or the third-party interface prefabricated execution mode in the third-party interface class, so as to obtain the changed third-party interface class.
6. A 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 third-party interface request 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, and acquiring the single response data;
the calling unit is used for calling the in-class judgment mode 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 intra-class judging mode;
the batch request unit is in communication connection with the judgment unit and is used for 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 when the batch request mode is the batch request mode, and acquiring batch response data, wherein M is a natural number not less than 2.
7. The apparatus of claim 6, further comprising a data processing unit;
and the data processing unit is in communication connection with the batch request unit and is used for processing the batch response data in a 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, so as to obtain a processing result.
8. The apparatus of claim 6, further comprising a change operation detection unit and a change operation response unit;
the change operation detection unit is used for detecting the change operation of the third-party interface class performed on a third-party interface management interface by an administrator before calling a class-in-class judgment mode in the third-party interface class, wherein the change operation of the third-party interface class is an operation for enabling the third-party interface class to change and inherit another prefabricated abstract class or changing the attribute characteristic of the third-party interface in the third-party interface class and/or the prefabricated execution mode of the third-party interface, and the prefabricated abstract class comprises the attribute characteristic of the third-party interface and the prefabricated execution mode of the third-party interface;
and 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 changes and inherits another prefabricated abstract class, or changes 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 the changed third party interface class.
9. A computer device comprising a memory and a processor, wherein the memory is used for storing a computer program, and the processor is used for reading the computer program and executing the third party interface calling method according to any one of claims 1-6.
10. A computer-readable storage medium having stored thereon instructions for performing the third party interface call method according to any one of claims 1 to 6 when the instructions are run on a computer.
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 true CN111552578A (en) 2020-08-18
CN111552578B 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)

Cited By (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 (10)

* 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
CN1867898A (en) * 2003-10-14 2006-11-22 国际商业机器公司 Method and apparatus for processing service requests in a service-oriented architecture
US20090248698A1 (en) * 2008-03-31 2009-10-01 Stephan Rehmann Managing Consistent Interfaces for Internal Service Request Business Objects Across Heterogeneous Systems
CN103345420A (en) * 2013-06-03 2013-10-09 百度在线网络技术(北京)有限公司 Method for massively calling API interfaces, system for massively calling API interfaces and device for massively calling API interfaces
CN104217314A (en) * 2014-08-26 2014-12-17 北京京东尚科信息技术有限公司 Routing information capturing method and device
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal
CN108762955A (en) * 2018-05-30 2018-11-06 平安普惠企业管理有限公司 Interface call method, device, computer equipment and storage medium
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
US20190370033A1 (en) * 2018-06-03 2019-12-05 Apple Inc. Multi-process model for cross-platform applications

Patent Citations (10)

* 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
CN1867898A (en) * 2003-10-14 2006-11-22 国际商业机器公司 Method and apparatus for processing service requests in a service-oriented architecture
US20090248698A1 (en) * 2008-03-31 2009-10-01 Stephan Rehmann Managing Consistent Interfaces for Internal Service Request Business Objects Across Heterogeneous Systems
CN103345420A (en) * 2013-06-03 2013-10-09 百度在线网络技术(北京)有限公司 Method for massively calling API interfaces, system for massively calling API interfaces and device for massively calling API interfaces
CN104217314A (en) * 2014-08-26 2014-12-17 北京京东尚科信息技术有限公司 Routing information capturing method and device
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal
CN108762955A (en) * 2018-05-30 2018-11-06 平安普惠企业管理有限公司 Interface call method, device, computer equipment and storage medium
US20190370033A1 (en) * 2018-06-03 2019-12-05 Apple Inc. Multi-process model for cross-platform applications
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 (3)

* Cited by examiner, † Cited by third party
Title
MATT WELSH 等: "SEDA: an architecture for well-conditioned, scalable internet services", 《ACM SIGOPS OPERATING SYSTEMS REVIEW》, vol. 35, no. 5, pages 230 - 243, XP002954712, DOI: 10.1145/502059.502057 *
冯雪 等: "信息网络Python批量操作系统应用分析", 《内蒙古电力技术》, vol. 37, no. 3, pages 56 - 59 *
皮成: "基于Android平台的即时通信中间件的研究与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 11, pages 136 - 242 *

Cited By (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

Also Published As

Publication number Publication date
CN111552578B (en) 2023-08-04

Similar Documents

Publication Publication Date Title
CN110691136B (en) Data interaction method and device, electronic equipment and storage medium
AU2012271774B2 (en) Automated user interface object transformation and code generation
US9703761B2 (en) Delayed code parsing for reduced startup latency
JP2019520624A (en) Page component dynamic layout
CA2788899C (en) Widget framework, real-time service orchestration, and real-time resource aggregation
AU2012271774A1 (en) Automated user interface object transformation and code generation
US10397051B1 (en) Configuration and testing of network-based service platform resources using a service platform specific language
US11799849B2 (en) Secure web application delivery platform
RU2608472C2 (en) Techniques for adapting interpretive run time application to multiple clients
WO2021169150A1 (en) Application interface implementation method and apparatus in host platform layer, and device and medium
US20130254780A1 (en) Techniques to remotely access object events
US20210224055A1 (en) Data interface processing method, device, server and medium
AU2012271775A1 (en) Techniques for adapting an interpretive run time application to multiple clients
JP2012515972A (en) Web-based diagram visual extensibility
WO2017143747A1 (en) Network request method and system for network terminal
US11930096B2 (en) Systems and methods for rendering interactive web pages
CN110633959A (en) Method, device, equipment and medium for creating approval task based on graph structure
CN111552578A (en) Third-party interface calling method and device
US10503572B2 (en) Hybrid remote controller
KR101383056B1 (en) Method for providing web application linkaging whith netive menu using script and the smart terminal thereof
CN113760487B (en) Service processing method and device
WO2015010574A1 (en) Method, apparatus and terminal for webpage content browsing
CN113626001A (en) API dynamic editing method and device based on script
CN113448751A (en) DSL-based interface response method, device, equipment and medium
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