CN111367690A - Method and device for supporting combined API service calling - Google Patents
Method and device for supporting combined API service calling Download PDFInfo
- Publication number
- CN111367690A CN111367690A CN202010138232.9A CN202010138232A CN111367690A CN 111367690 A CN111367690 A CN 111367690A CN 202010138232 A CN202010138232 A CN 202010138232A CN 111367690 A CN111367690 A CN 111367690A
- Authority
- CN
- China
- Prior art keywords
- api
- calling
- combined
- dependency
- sequence
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/549—Remote execution
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephonic Communication Services (AREA)
Abstract
The invention provides a method and a device for supporting combined API service calling, wherein the method for supporting combined API service calling comprises the following steps: receiving a request message constructed by a calling party according to the parameters of the combined API; determining the order dependency attribute of the combined API according to the request message; and calling the combined API according to the request message and the sequence dependency attribute. The invention can make the calling party finish the business process only by one API call, thereby reducing the network consumption and other expenses of the business process. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
Description
Technical Field
The invention relates to the technical field of information, in particular to the technical field of combination of information technology and data service, and particularly relates to a method and a device for supporting combined API service calling.
Background
With the rise of the open platform, more and more enterprise internal API interfaces provide services to the outside through the open platform. In the traditional development platform calling, if a service flow relates to a plurality of API interfaces and a calling sequence exists among the API calls, a calling party needs to initiate a plurality of API interface calls in sequence, and a processing party for each API interface call can complete the whole flow. And the multiple calls relate to multiple http/http requests, which inevitably brings long http/http transmission time consumption and occupies a large proportion of the whole transaction time consumption.
In addition, from the perspective of service providers, the providers of various services are becoming more and more clear, the functions provided by a single enterprise internal API are relatively single, and often cannot achieve the user's goal, and a complete service usually needs to contain several basic enterprise internal APIs. For example, a travel service for a country may be composed of several API services, such as airline reservations, hotel reservations, car rentals, etc. Therefore, in order to realize complete functions to meet various demands made by users, it is necessary to combine separate individual API services efficiently and flexibly to form a combined API service with added value.
Disclosure of Invention
Aiming at the problems in the prior art, the method and the device for calling the support combination API service can enable a calling party to finish a business process only by calling the API once, thereby reducing the network consumption and other expenses of the business process. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
In order to solve the technical problems, the invention provides the following technical scheme:
in a first aspect, the present invention provides a method for supporting a combined API service call, including:
receiving a request message constructed by a calling party according to the parameters of the combined API;
determining the order dependency attribute of the combined API according to the request message;
and calling the combined API according to the request message and the sequence dependency attribute.
Preferably, the parameters are a parameter set of all internal APIs of the combined API, the parameter set including: JSON arrays, and XML objects.
Preferably, the order dependency attribute comprises: sequential dependency and non-sequential dependency.
Preferably, the calling the combined API according to the request packet and the sequence dependency attribute includes:
when the sequence dependency attribute is a sequence dependency type, extracting parameters required by each API in the combined API according to a preset calling sequence so as to call each API interface;
and when the sequential dependency attribute is non-sequential dependency, calling each API interface by using a serial or parallel method.
Preferably, the method for supporting combined API service call further comprises:
and when the sequence dependency attribute is a sequence dependency type, analyzing the return code of each API to judge whether calling the corresponding API is successful.
In a second aspect, the present invention provides an apparatus for supporting a combined API service call, the apparatus comprising:
a request message receiving unit, configured to receive a request message constructed by a caller according to the parameters of the combined API;
a sequence determining unit, configured to determine a sequence dependency attribute of the combined API according to the request packet;
and the API calling unit is used for calling the combined API according to the request message and the sequence dependency attribute.
Preferably, the parameters are a parameter set of all internal APIs of the combined API, the parameter set including: JSON arrays, and XML objects.
Preferably, the order dependency attribute comprises: sequential dependency and non-sequential dependency.
Preferably, the API calling unit includes:
a sequential API calling module, configured to, when the sequential dependency attribute is a sequential dependency type, extract parameters required by each API in the combined API according to a preset calling order, so as to call each API interface;
and the non-sequential API calling module is used for calling each API interface by using a serial or parallel method when the sequential dependency attribute is a non-sequential dependency type.
Preferably, the apparatus for supporting API service call combination further comprises:
and the return code analysis unit is used for analyzing the return code of each API when the sequence dependency attribute is the sequence dependency type so as to judge whether calling the corresponding API is successful.
In a third aspect, the present invention provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of supporting the combined API service call method when executing the program.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of supporting a combinational API service call method.
It can be known from the above description that the combined API service supporting method and apparatus provided by the present invention maintain a combined API at the open platform API gateway, where the API is composed of multiple internal APIs, and maintain the calling order of the multiple internal APIs in advance according to the service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
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 introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a first flowchart illustrating a method for supporting a combined API service call according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating method steps 300 for supporting a combined API service invocation in an embodiment of the present invention;
FIG. 3 is a first flowchart illustrating a method for supporting a combined API service call according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for supporting a combinational API service invocation in an exemplary implementation of the present invention;
FIG. 5 is a first schematic diagram illustrating a structure of a device for supporting API service invocation in combination according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of an API call unit in an embodiment of the present invention;
FIG. 7 is a second schematic structural diagram of a combined API service invocation supported device in an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device in an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In view of the fact that in the multiple API calling processes of the existing traditional development platform, longer http/https transmission time consumption exists, and a large proportion of the whole transaction time consumption is occupied. The embodiment of the present invention provides a specific implementation manner of a method for supporting a combined API service call, and referring to fig. 1, the method specifically includes the following contents:
step 100: and receiving a request message constructed by a calling party according to the parameters of the combined API.
It is understood that an API (Application Programming Interface) refers to some predefined function or to a convention for linking different components of a software system. The build is designed to provide applications and developers the ability to access a set of routines based on certain software or hardware without having to access native code or understand the details of the internal workings.
In addition, the parameters of the composition API in step 100 are parameter sets of all internal APIs involved in the composition API, and may be organized in the form of JSON array, XML object, etc., where each element in the array or object is all parameters required for each internal service.
Step 200: and determining the sequence dependency attribute of the combined API according to the request message.
Specifically, statistical analysis can be performed on the kernel interface by combining with the structural features of the source code, the order dependency rules of the API interface are mined and extracted by using statistical information, the extracted rules are used for detecting the use violation in the existing source code, the reliability is improved in an auxiliary mode, and a developer is not required to provide additional comments and labels, so that compared with the traditional method, the method has the following advantages: and a user is not required to define a specific API (application program interface) use rule, and mining and detecting the serialization rule are carried out according to the statistical information. The usage specification extraction of the interface is done directly across functions. And combining the source code structure information and the statistical information, no additional label is required to be provided by a program.
Step 300: and calling the combined API according to the request message and the sequence dependency attribute.
And aiming at the extracted calling sequence, by analyzing the parameter of each API interface function and the dependence of the parameter and the return value between the interface functions in the return value extraction sequence, the support is provided for the subsequent structure derivation and statistics. And making a combined API call according to the extracted dependency relation and the sequential dependency of the call sequence.
As can be seen from the above description, the combined API service supporting method and the combined API service supporting method provided by the present invention maintain a combined API at the open platform API gateway, where the API is composed of multiple internal APIs, and maintain the calling order of the multiple internal APIs in advance according to a service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
In one embodiment, the parameters are a parameter set of all internal APIs of the combined API, the parameter set including: JSON arrays, and XML objects.
It will be appreciated that each element in the JSON array or XML object is all the parameters required for each internal service. Specifically, the type of array value in JSON includes a string, number, object, array, boolean, or null. Preferably, a JavaScript expression is also included, including a function, a date, and undefined.
In one embodiment, the order dependency attribute comprises: sequential dependency and non-sequential dependency.
It will be understood that sequentially lazy refers to the calling order of the API combinations being a predetermined order relationship, the calling order of the APIs being specific, whereas non-sequentially dependent refers to the calling order of the API combinations being non-specific, and the APIs within the API combinations being called serially or in parallel.
In one embodiment, referring to fig. 2, step 300 comprises:
step 301: and when the sequence dependency attribute is a sequence dependency type, extracting parameters required by each API in the combined API according to a preset calling sequence so as to call each API interface.
Step 302: and when the sequential dependency attribute is non-sequential dependency, calling each API interface by using a serial or parallel method.
In particular, for non-sequentially dependent APIs, there is no sequential dependency between the calls of the internal APIs that the combined API involves. The calling of the internal API can be carried out in a serial or parallel mode, the return codes of the internal API related to the non-sequential dependency type combined API are not analyzed, and a response result is not returned to a calling party until all internal API calls are completed. For parallel mode calling, calling the related internal APIs in parallel by means of multithreading and the like, and combining the internal time consumption of the API calling into the time consumption of calling the API which consumes the longest time in all the related internal APIs. For serial calling, the related internal API calls are carried out in sequence, and the internal time consumption of the combined API is the sum of the time consumption of all the related internal API calls. The parallel mode can obviously improve the response efficiency compared with the serial mode, and reduce the waiting time of the calling side. In addition, the parallel call is processed by the open platform gateway, so that the use threshold of a calling party is reduced.
In one embodiment, referring to fig. 3, the method for supporting a combined API service call further comprises:
step 400: and when the sequence dependency attribute is a sequence dependency type, analyzing the return code of each API to judge whether calling the corresponding API is successful.
When the step 400 is implemented, the following steps are specifically performed: for the sequential dependent type combined API, the request parameters required by each internal API are sequentially extracted strictly according to the preset calling sequence, and the calling of each internal API interface is carried out. Each internal API provides a uniform return message format (uniform return code and return information, and service parameters can be defined in the return information) in the form of JSON, XML, and the like. When each internal API is called, whether the internal API is called successfully or not is judged according to the return code. If the calling fails or the response message return code is an error return code, the calling process of the whole internal API is terminated, and an error response is directly returned to the calling party. Otherwise, all internal APIs involved in the combined API are called in the agreed order. And after the calling is finished, aggregating the calling results of all the internal APIs and returning the aggregated calling results to the calling party.
As can be seen from the above description, the combined API service call method provided by the present invention maintains a combined API at the open platform API gateway, where the API is composed of multiple internal APIs, and maintains the call sequence of the multiple internal APIs in advance according to the service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
To further illustrate the present solution, the present invention provides a specific application example supporting the combined API service invocation method by taking an open platform as an example, and the specific application example specifically includes the following contents, see fig. 4.
S0: and the calling party constructs a request message according to the parameters of the combined API and sends the request message to the open platform gateway.
The open platform provides a unified combined API maintenance framework, selects related internal APIs related to the combined API, defines combined API interface information, and maintains the calling sequence of the internal APIs under the combined API. The request parameters of the composition API are parameter sets of all internal APIs involved by the composition API, and may be organized in the form of JSON arrays, XML objects, etc., where each element in an array or object is all parameters required for each internal service. The calling party calls according to the request parameters of the combined API, only the combined API interface needs to be called once, the internal API interface related to the combined API interface can be automatically completed by the open platform API gateway, and the calling party carries out service flow processing according to the response result returned by the open platform API gateway.
S1: and determining the sequence dependency attribute of the combined API according to the request message.
The order dependent property of the combined API (classified as order dependent and non-order dependent APIs) is set. And the external distribution is a uniform combined API interface. The related information of the combined API is assembled and exposed to the outside in the open platform gateway in the form of a general parameter table, can be rapidly configured, and does not need to be additionally developed.
S2: and assembling corresponding messages of the combined API.
The response message of the combined API is assembled by the open platform gateway, and the open platform gateway extracts the response result of the internal API and returns the response message to the caller after assembling the response message. If any internal API calls error report, returning an error report of the internal API and an internal API with the calling sequence before the internal API interface to return a message result set.
S3: and calling the combined API according to the request message and the sequence dependency attribute.
And the open platform API gateway carries out internal calling processing of the combined API service according to the request parameters sent by the calling party. For the sequential dependent type combined API, the request parameters required by each internal API are sequentially extracted strictly according to the preset calling sequence, and the calling of each internal API interface is carried out.
For non-order dependent APIs, there is no order dependency between the calls of the internal APIs that the combined API involves. The open platform gateway may make calls to internal APIs in a serial or parallel fashion,
for a combined API interface which consumes a long time, the open platform gateway provides the support of asynchronous call, and only the configuration of the asynchronous call attribute needs to be added on the combined API. For the asynchronous call combination API, a calling party needs to register in advance or send a url address for receiving a response result in a request, the calling party immediately returns a response to the calling party after the request of the calling party reaches the open platform gateway, and the response prompts that the request of the calling party is processed. After the open platform gateway processes the request, the response result is pushed to the calling party according to the url registered by the calling party in advance, so that the long-time invalid waiting of the calling party is avoided.
S4: and judging whether calling the corresponding API is successful or not.
For non-sequential dependent APIs, each internal API provides a uniform return message format (uniform return code and return information, service parameters may be defined within the return information) in the form of JSON, XML, etc. When each internal API is called, whether the internal API is called successfully or not is judged according to the return code. If the calling fails or the response message return code is an error return code, the calling process of the whole internal API is terminated, and an error response is directly returned to the calling party. Otherwise, all internal APIs involved in the combined API are called in the agreed order. And after the calling is finished, aggregating the calling results of all the internal APIs and returning the aggregated calling results to the calling party.
For the non-sequential dependent API, the open platform gateway does not analyze the return codes of the internal APIs related to the non-sequential dependent combined API, and the response result is not returned to the caller until all internal API calls are completed. For parallel mode calling, calling the related internal APIs in parallel by means of multithreading and the like, and combining the internal time consumption of the API calling into the time consumption of calling the API which consumes the longest time in all the related internal APIs. For serial calling, the related internal API calls are carried out in sequence, and the internal time consumption of the combined API is the sum of the time consumption of all the related internal API calls. The parallel mode can obviously improve the response efficiency compared with the serial mode, and reduce the waiting time of the calling side. In addition, the parallel call is processed by the open platform gateway, so that the use threshold of a calling party is reduced.
S5: fuse control is performed on a single API dimension.
When each combined API is called, the open platform gateway can count the transaction time consumption, the calling success rate of the internal API related to the combined API and the like, and can perform fusing control on the combined API and a single internal API dimension aiming at the transaction time consumption, the success rate and the like. The success rate can be set as a threshold value as required, for example, fusing is performed when the success rate is lower than 70%. For the fusing control of the transaction time consumption dimension, for example, the fusing control can be performed when the average time consumption of a single API transaction is more than 500 milliseconds, and the fusing control can be performed when the average time consumption of a combined API is more than 1 second.
In addition, multiple nodes can be generally deployed for each internal API service, and discovery, registration and the like of the service can be performed through a registry. By means of the registration center, the internal API service node periodically uploads the node information to the registration center, the open platform gateway periodically acquires the internal API service node information from the registration center, and one of the nodes is selected to initiate a request according to a pre-configured load balancing strategy. In addition, the internal API service node can directly and periodically inform the open platform gateway of the node information without a registration center.
Besides the above functions, the open platform gateway also needs to complete functions such as authentication, identity authentication, current limiting, ip white list, etc., wherein the current limiting can combine API, internal API, etc. into granularity. The open platform gateway signs the response result, and prevents the response result from being intercepted and tampered in the network link. The open platform gateway can convert different protocols, shield the difference of internal multi-protocols to the outside, and support internal API interfaces of grpc, Dubbo and the like based on remote procedure call protocols to be exposed to the outside in an http/https mode. For a calling party with smaller bandwidth or longer network delay, the open platform gateway supports the return of the response message compressed in the gzip, deflate and other modes, and reduces the time consumption of message transmission by reducing the size of the return message.
As can be seen from the above description, the combined API service call method provided by the present invention maintains a combined API at the open platform API gateway, where the API is composed of multiple internal APIs, and maintains the call sequence of the multiple internal APIs in advance according to the service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
Based on the same inventive concept, the embodiment of the present application further provides a device for supporting combined API service invocation, which can be used to implement the methods described in the above embodiments, such as the following embodiments. Because the principle of supporting the combined API service calling device to solve the problem is similar to that of supporting the combined API service calling method, the implementation of the device for supporting the combined API service calling may refer to the implementation of the method for supporting the combined API service calling, and repeated details are not described herein. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. While the system described in the embodiments below is preferably implemented in software, implementations in hardware, or a combination of software and hardware are also possible and contemplated.
An embodiment of the present invention provides a specific implementation manner of a combined API service call supporting device capable of implementing a method for supporting a combined API service call, and referring to fig. 5, the combined API service call supporting device specifically includes the following contents:
a request message receiving unit 10, configured to receive a request message constructed by a caller according to the parameters of the API;
a sequence determining unit 20, configured to determine a sequence dependency attribute of the combined API according to the request packet;
and the API calling unit 30 is configured to call the combined API according to the request packet and the sequence dependency attribute.
Preferably, the parameters are a parameter set of all internal APIs of the combined API, the parameter set including: JSON arrays, and XML objects.
Preferably, the order dependency attribute comprises: sequential dependency and non-sequential dependency.
Preferably, referring to fig. 6, the API calling unit 30 includes:
a sequential API calling module 301, configured to, when the sequential dependency attribute is a sequential dependency type, extract parameters required by each API in the combined API according to a preset calling order, so as to call each API interface;
a non-sequential API calling module 302, configured to call each API interface by using a serial or parallel method when the sequential dependency attribute is non-sequential dependency.
Preferably, referring to fig. 7, the apparatus for supporting a composition API service call further comprises:
and the return code analyzing unit 40 is configured to analyze the return code of each API when the sequential dependency attribute is a sequential dependency type, so as to determine whether calling the corresponding API succeeds.
As can be seen from the above description, the combined API service call device provided by the present invention maintains a combined API at the open platform API gateway, where the API is composed of multiple internal APIs, and maintains the call sequence of the multiple internal APIs in advance according to the service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
An embodiment of the present application further provides a specific implementation manner of an electronic device capable of implementing all steps in the method for supporting API service invocation in the foregoing embodiment, and referring to fig. 8, the electronic device specifically includes the following contents:
a processor (processor)1201, a memory (memory)1202, a communication interface 1203, and a bus 1204;
the processor 1201, the memory 1202 and the communication interface 1203 complete communication with each other through the bus 1204; the communication interface 1203 is configured to implement information transmission between related devices, such as a server-side device, an interface device, and a client device.
The processor 1201 is configured to call the computer program in the memory 1202, and the processor executes the computer program to implement all the steps in the method for calling the API service in support of composition described in the above embodiments, for example, to implement the following steps when the processor executes the computer program:
step 100: and receiving a request message constructed by a calling party according to the parameters of the combined API.
Step 200: and determining the sequence dependency attribute of the combined API according to the request message.
Step 300: and calling the combined API according to the request message and the sequence dependency attribute.
As can be seen from the above description, in the electronic device in the embodiment of the present application, a combined API is maintained at the open platform API gateway, where the API is composed of multiple internal APIs, and a calling sequence of the multiple internal APIs is maintained in advance according to a service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
Embodiments of the present application further provide a computer-readable storage medium capable of implementing all steps in the method for supporting combined API service invocation in the foregoing embodiments, where the computer-readable storage medium stores a computer program, and the computer program, when executed by a processor, implements all steps in the method for supporting combined API service invocation in the foregoing embodiments, for example, when the processor executes the computer program, the following steps are implemented:
step 100: and receiving a request message constructed by a calling party according to the parameters of the combined API.
Step 200: and determining the sequence dependency attribute of the combined API according to the request message.
Step 300: and calling the combined API according to the request message and the sequence dependency attribute.
As can be seen from the above description, in the computer-readable storage medium in the embodiment of the present application, a combined API is maintained at the open platform API gateway, where the API is composed of multiple internal APIs, and a calling sequence of the multiple internal APIs is maintained in advance according to a service scenario, so as to expose a combined API service to the outside. The calling party only needs to call the API service once, and the open platform API gateway calls the internal API service in sequence to complete the whole service flow. By combining the introduction of the API, the calling process of the calling party is simplified, the calling party can complete the service process only by calling the API once, and the network consumption and other expenses of the service process can be reduced. In addition, the exposure of the combined API can be completed only through general configuration, additional development work is not needed, and the internal APIs of the enterprise can be quickly combined according to the business scene to form the combined API for publishing.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Although the present application provides method steps as in an embodiment or a flowchart, more or fewer steps may be included based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or client product executes, it may execute sequentially or in parallel (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or methods shown in the figures.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (12)
1. A method for supporting a combinational API service call, comprising:
receiving a request message constructed by a calling party according to the parameters of the combined API;
determining the order dependency attribute of the combined API according to the request message;
and calling the combined API according to the request message and the sequence dependency attribute.
2. The method of claim 1, wherein the parameter is a set of parameters of all internal APIs of the composed API, the set of parameters comprising: JSON arrays, and XML objects.
3. The method of claim 1, wherein the order dependent attributes comprise: sequential dependency and non-sequential dependency.
4. The method according to claim 3, wherein the calling the combined API according to the request packet and the sequence dependency attribute comprises:
when the sequence dependency attribute is a sequence dependency type, extracting parameters required by each API in the combined API according to a preset calling sequence so as to call each API interface;
and when the sequential dependency attribute is non-sequential dependency, calling each API interface by using a serial or parallel method.
5. The method of supporting composed API service calls of claim 4, further comprising:
and when the sequence dependency attribute is a sequence dependency type, analyzing the return code of each API to judge whether calling the corresponding API is successful.
6. An apparatus for supporting a composed API service call, comprising:
a request message receiving unit, configured to receive a request message constructed by a caller according to the parameters of the combined API;
a sequence determining unit, configured to determine a sequence dependency attribute of the combined API according to the request packet;
and the API calling unit is used for calling the combined API according to the request message and the sequence dependency attribute.
7. The apparatus according to claim 6, wherein the parameter is a parameter set of all internal APIs of the composition API, the parameter set comprising: JSON arrays, and XML objects.
8. The apparatus of claim 6, wherein the order dependent attribute comprises: sequential dependency and non-sequential dependency.
9. The apparatus of claim 8, wherein the API call unit comprises:
a sequential API calling module, configured to, when the sequential dependency attribute is a sequential dependency type, extract parameters required by each API in the combined API according to a preset calling order, so as to call each API interface;
and the non-sequential API calling module is used for calling each API interface by using a serial or parallel method when the sequential dependency attribute is a non-sequential dependency type.
10. The apparatus for supporting API service invocation combining according to claim 8, further comprising:
and the return code analysis unit is used for analyzing the return code of each API when the sequence dependency attribute is the sequence dependency type so as to judge whether calling the corresponding API is successful.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method of supporting a composed API service call of any of claims 1 to 5 when executing the program.
12. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of supporting a composed API service call of any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010138232.9A CN111367690A (en) | 2020-03-03 | 2020-03-03 | Method and device for supporting combined API service calling |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010138232.9A CN111367690A (en) | 2020-03-03 | 2020-03-03 | Method and device for supporting combined API service calling |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111367690A true CN111367690A (en) | 2020-07-03 |
Family
ID=71208366
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010138232.9A Pending CN111367690A (en) | 2020-03-03 | 2020-03-03 | Method and device for supporting combined API service calling |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111367690A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112437126A (en) * | 2020-11-10 | 2021-03-02 | 中国联合网络通信集团有限公司 | Task flow processing method and device based on atomic interface |
CN114006754A (en) * | 2021-10-29 | 2022-02-01 | 重庆长安汽车股份有限公司 | Method for protecting API (application programming interface) interface configuration security policy data and method and system for calling open platform service based on gateway |
US11928532B1 (en) * | 2022-10-07 | 2024-03-12 | Ideatec Co., Ltd. | Gateway device for integrally processing APIs with security function, and method of operating same |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107846435A (en) * | 2016-09-20 | 2018-03-27 | ***通信有限公司研究院 | Business realizing system and method |
CN107920094A (en) * | 2016-10-08 | 2018-04-17 | 阿里巴巴集团控股有限公司 | Data capture method, device, server and the network equipment |
CN108228369A (en) * | 2018-01-19 | 2018-06-29 | 北京邮电大学 | Visualization API combined systems and method based on JSON trees |
CN109857377A (en) * | 2019-01-07 | 2019-06-07 | 平安科技(深圳)有限公司 | A kind of API method of combination and device |
US10540270B1 (en) * | 2018-01-25 | 2020-01-21 | Amazon Technologies, Inc. | Representation-based automated software testing |
-
2020
- 2020-03-03 CN CN202010138232.9A patent/CN111367690A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107846435A (en) * | 2016-09-20 | 2018-03-27 | ***通信有限公司研究院 | Business realizing system and method |
CN107920094A (en) * | 2016-10-08 | 2018-04-17 | 阿里巴巴集团控股有限公司 | Data capture method, device, server and the network equipment |
CN108228369A (en) * | 2018-01-19 | 2018-06-29 | 北京邮电大学 | Visualization API combined systems and method based on JSON trees |
US10540270B1 (en) * | 2018-01-25 | 2020-01-21 | Amazon Technologies, Inc. | Representation-based automated software testing |
CN109857377A (en) * | 2019-01-07 | 2019-06-07 | 平安科技(深圳)有限公司 | A kind of API method of combination and device |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112437126A (en) * | 2020-11-10 | 2021-03-02 | 中国联合网络通信集团有限公司 | Task flow processing method and device based on atomic interface |
CN114006754A (en) * | 2021-10-29 | 2022-02-01 | 重庆长安汽车股份有限公司 | Method for protecting API (application programming interface) interface configuration security policy data and method and system for calling open platform service based on gateway |
US11928532B1 (en) * | 2022-10-07 | 2024-03-12 | Ideatec Co., Ltd. | Gateway device for integrally processing APIs with security function, and method of operating same |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107329861B (en) | Multi-interface testing method and device | |
CN106998343B (en) | Remote procedure call processing method, device and system | |
CN107920094B (en) | Data acquisition method and device, server and network equipment | |
CN111367690A (en) | Method and device for supporting combined API service calling | |
CN108228444B (en) | Test method and device | |
CN111090423B (en) | Webhook framework system and method for realizing active calling and event triggering | |
US10831565B2 (en) | Fault tolerant adapter system to consume database as a service | |
CN109254854A (en) | Asynchronous invoking method, computer installation and storage medium | |
CN111200523B (en) | Method, device, equipment and storage medium for configuring middle platform system | |
CN106713469B (en) | Dynamic loading method, device and system for distributed container | |
CN111478956A (en) | Deployment and preview method and device of small program package | |
CN112817565A (en) | Micro-service combination method, device, equipment and storage medium | |
CN110781180A (en) | Data screening method and data screening device | |
CN107517188A (en) | A kind of data processing method and device based on Android system | |
US20210373984A1 (en) | Automatic code generation for api mashups | |
CN112667204A (en) | Data processing method and device for microservice application and computer equipment | |
CN112423024A (en) | Video transcoding method and device, computer equipment and storage medium | |
CN110389754B (en) | Service processing method, system, server, terminal, electronic equipment and storage medium | |
CN112788078B (en) | Data transmission method, receiving device, sending device and computer equipment | |
CN108076067B (en) | Method and system for authorized crawler configuration simulation login | |
CN113485942A (en) | Automatic testing method and device based on independent module | |
CN112929453A (en) | Method and device for sharing session data | |
CN111949260A (en) | Mobile terminal service configuration method and system | |
CN102148755A (en) | Mainframe injection component and method for manipulating data packets communicated between emulators and mainframes | |
CN108170536B (en) | Expanding method and device of WEB program |
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 |