CN116599949A - Third party API protocol access method and system based on HTTP protocol - Google Patents

Third party API protocol access method and system based on HTTP protocol Download PDF

Info

Publication number
CN116599949A
CN116599949A CN202310518292.7A CN202310518292A CN116599949A CN 116599949 A CN116599949 A CN 116599949A CN 202310518292 A CN202310518292 A CN 202310518292A CN 116599949 A CN116599949 A CN 116599949A
Authority
CN
China
Prior art keywords
server
template
protocol
api
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310518292.7A
Other languages
Chinese (zh)
Inventor
周风余
苏大龙
尹磊
李伟
杨珂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Xinchen Artificial Intelligence Technology Co ltd
Original Assignee
Shandong Xinchen Artificial Intelligence Technology 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 Shandong Xinchen Artificial Intelligence Technology Co ltd filed Critical Shandong Xinchen Artificial Intelligence Technology Co ltd
Priority to CN202310518292.7A priority Critical patent/CN116599949A/en
Publication of CN116599949A publication Critical patent/CN116599949A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • H04L67/025Protocols based on web technology, e.g. hypertext transfer protocol [HTTP] for remote control or remote monitoring of applications
    • 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
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • H04L67/303Terminal profiles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]
    • 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
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Abstract

Third party API protocol access method and system based on HTTP protocol; the method comprises the following steps: the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server; the client creates an application program and sends the application program to the server; the client starts an application program and sends a starting instruction to the server; the client sends the request parameters to the server. The predefined functions of the third party application can be obtained without accessing source codes and without understanding the details of the internal working mechanism.

Description

Third party API protocol access method and system based on HTTP protocol
Technical Field
The invention relates to the technical field of communication, in particular to a third party API protocol access method and system based on an HTTP protocol.
Background
The statements in this section merely relate to the background of the present disclosure and may not necessarily constitute prior art.
The low-code development platform is a development platform which can quickly generate application programs without coding or through a small amount of coding.
After purchasing the low-code development platform, if the user needs to install a new application program to the low-code development platform server by self through the client, there is a technical problem to be solved:
the interface of the new application program and the interface between the low-code development platform servers are in butt joint, and a professional programming developer is required to be dispatched by a developer of the low-code development platform to assist in programming, so that more manpower is required to be input, and the time of a user is wasted.
In the prior art, the HTTP interface is realized by adopting a code mode, programming developers are required to be input, the HTTP interface is changed and adjusted, and development manpower is required to be input again.
Disclosure of Invention
In order to solve the defects of the prior art, the invention provides a third party API protocol access method and system based on the HTTP protocol; the invention creates a set of third party API protocol access method and system based on the HTTP protocol, and can acquire the function predefined by the third party application program without accessing source codes and understanding the details of an internal working mechanism.
In a first aspect, the present invention provides a third party API protocol access method based on the HTTP protocol;
the third party API protocol access method based on the HTTP protocol comprises the following steps:
the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server; the server persists configuration information in an API protocol template based on the HTTP protocol to a database for the first time;
the client creates an application program and sends the application program to the server; the method comprises the steps that a gateway template is prefabricated by a server, a debugging template is prefabricated by the server, and after an application program is received by the server, basic parameters in the prefabricated gateway template and the prefabricated debugging template are correspondingly replaced by the basic parameters of the application program;
the server pulls the API protocol template based on the HTTP protocol of the corresponding type from the database according to the type of the API protocol template of the application program, analyzes the data of the pulled API protocol template based on the HTTP protocol, and persists the analyzed data to the database for the second time;
the client starts an application program and sends a starting instruction to the server; after receiving the starting instruction, the server starts gateway service according to the prefabricated gateway template, starts debugging service according to the prefabricated debugging template, loads the second lasting API protocol template based on HTTP protocol, starts timing task, actively requests a third party interface of an application program configured by the timing task according to configuration information of the timing task, and sustains the acquired third party interface configuration of the application program into a memory;
the client sends the request parameters to the server; the server acquires the request parameters, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol according to the request interface address of the request parameters, encapsulates the request parameters according to the third party interface configuration of the application program, judges whether the request parameters have associated calling interface mapping, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol again according to the request interface address if the request parameters have associated calling interface mapping, and forwards the encapsulated interface object to the application program of the client if the request interface configuration does not have associated calling interface mapping.
In a second aspect, the present invention provides a third party API protocol access system based on the HTTP protocol;
a third party API protocol access system based on HTTP protocol, comprising: a client and a server;
the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server; the server persists configuration information in an API protocol template based on the HTTP protocol to a database for the first time;
the client creates an application program and sends the application program to the server; the method comprises the steps that a gateway template is prefabricated by a server, a debugging template is prefabricated by the server, and after an application program is received by the server, basic parameters in the prefabricated gateway template and the prefabricated debugging template are correspondingly replaced by the basic parameters of the application program;
the server pulls the API protocol template based on the HTTP protocol of the corresponding type from the database according to the type of the API protocol template of the application program, analyzes the data of the pulled API protocol template based on the HTTP protocol, and persists the analyzed data to the database for the second time;
the client starts an application program and sends a starting instruction to the server; after receiving the starting instruction, the server starts gateway service according to the prefabricated gateway template, starts debugging service according to the prefabricated debugging template, loads the second lasting API protocol template based on HTTP protocol, starts timing task, actively requests a third party interface of an application program configured by the timing task according to configuration information of the timing task, and sustains the acquired third party interface configuration of the application program into a memory;
the client sends the request parameters to the server; the server acquires the request parameters, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol according to the request interface address of the request parameters, encapsulates the request parameters according to the third party interface configuration of the application program, judges whether the request parameters have associated calling interface mapping, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol again according to the request interface address if the request parameters have associated calling interface mapping, and forwards the encapsulated interface object to the application program of the client if the request interface configuration does not have associated calling interface mapping.
Compared with the prior art, the invention has the beneficial effects that:
the invention realizes the quick access of the client application program interface and the low-code development platform interface, reduces the limitation of expanding the application program, and improves the flexibility of expanding the application program. Supporting cross-platform, the HTTP interface docking can be configured and debugged by opening the browser, development manpower is not required, and the protocol docking can be realized by only adjusting relevant parameters in configuration when the interface is changed.
The invention solves the problem of data synchronization among a plurality of systems by one set of system and one data. The interface file, interface debugging, data Mock and interface test can be directly used without redefining as long as the interface file, interface debugging, data Mock and interface test are defined. The interface document and the interface development and debugging use the same tool, and the interface can be ensured to be completely consistent with the definition of the interface document after the interface debugging is finished.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention.
Fig. 1 is a flow chart of a method according to a first embodiment.
Detailed Description
It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the invention. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
It is noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of exemplary embodiments according to the present invention. As used herein, the singular forms also are intended to include the plural forms unless the context clearly indicates otherwise, and furthermore, it is to be understood that the terms "comprise" and "have" and any variations thereof are intended to cover non-exclusive inclusions, for example, including: a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those listed or inherent to such process, method, article, or apparatus but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Embodiments of the invention and features of the embodiments may be combined with each other without conflict.
All data acquisition in the embodiment is legal application of the data on the basis of meeting laws and regulations and agreements of users.
The API (Application Programming Interface ) is a number of predefined functions that are intended to provide the application and developer the ability to access a set of routines based on some software or hardware without having to access source code or understand the details of the internal operating mechanisms. An API refers to a description document of the API, also called a help document, in addition to the meaning of an application "application program interface".
Example 1
The embodiment provides a third party API protocol access method based on HTTP protocol;
as shown in fig. 1, the third party API protocol access method based on HTTP protocol includes:
s101: the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server; the server persists configuration information in an API protocol template based on the HTTP protocol to a database for the first time;
s102: the client creates an application program and sends the application program to the server; the method comprises the steps that a gateway template is prefabricated by a server, a debugging template is prefabricated by the server, and after an application program is received by the server, basic parameters in the prefabricated gateway template and the prefabricated debugging template are correspondingly replaced by the basic parameters of the application program;
the server pulls the API protocol template based on the HTTP protocol of the corresponding type from the database according to the type of the API protocol template of the application program, analyzes the data of the pulled API protocol template based on the HTTP protocol, and persists the analyzed data to the database for the second time;
s103: the client starts an application program and sends a starting instruction to the server; after receiving the starting instruction, the server starts gateway service according to the prefabricated gateway template, starts debugging service according to the prefabricated debugging template, loads the second lasting API protocol template based on HTTP protocol, starts timing task, actively requests a third party interface of an application program configured by the timing task according to configuration information of the timing task, and sustains the acquired third party interface configuration of the application program into a memory;
s104: the client sends the request parameters to the server; the server acquires the request parameters, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol according to the request interface address of the request parameters, encapsulates the request parameters according to the third party interface configuration of the application program, judges whether the request parameters have associated calling interface mapping, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol again according to the request interface address if the request parameters have associated calling interface mapping, and forwards the encapsulated interface object to the application program of the client if the request interface configuration does not have associated calling interface mapping.
Further, the server is a low code development platform.
Further, in S101, the API protocol template based on the HTTP protocol includes: API protocol type, API protocol template name, and authorized application.
The API protocol type is used for distinguishing application scenes of the API template based on the http protocol, and the template can be selected from a database according to the application scenes when the template is called after the template is created; an application scenario comprising: social, life service, e-commerce shopping, commerce, traffic geography, internet of things, artificial intelligence, blockchain, and the like.
API protocol template naming, which plays a role equivalent to id, can be queried according to naming when querying, and has uniqueness.
The name of the API protocol template is autonomously named by a user according to the actual template application scene, is usually a certain industry, has representativeness, and can enable the user to quickly understand the relevant application scene of the template when in use, and the name can be non-unique.
The API authorizes the application, is a multi-system, multi-tenant scenario. The authorization application is to select whether to authorize the use of some of the low-code development platforms, and the A platform can only use the template after authorizing the use of the template, otherwise, the A platform cannot use the template.
Further, in S102, the application refers to: the computer program, which is run on the client to perform the specified task, interacts with the user and has a visual user interface.
Further, in S102, the server performs a gateway template, which refers to a third party API protocol configuration template, loads configuration parameters into a gateway running file according to the configuration parameters, and after the gateway is started, operates the configuration template as a gateway program of a service or a project according to the configuration parameters.
Further, the step S102: the server prefabricated gateway template comprises the following specific processes: protocol reception, policy, forwarding and response mechanisms.
Protocol reception, namely developing a document in a project with a front end separated from a back end so that the front end calls a back end interface (generated by Swagger), and the back end is used for returning data and operation data; the return data is in a unified return data format after the back end communicates with the front end, so that the operation of the front end (iOS Android, web) on the data is more consistent and easier;
the strategy is to define a plurality of logic modes in the transparent transmission process, and the data is directly transparent in the normal transparent transmission process. The custom logic modes refer to: preprocessing the data in the request at the gateway layer, such as: and adding a unified identifier to the data in a unified way, and then delivering the data to a corresponding back-end service (an exposed interface of the low-code development platform) for processing according to the identifier.
Forwarding refers to forwarding different services through gateway party swagger 2. The Gateway is also called Gateway connector and protocol converter. The default gateway implements network interconnection above the network layer, which is the most complex network interconnection device, and is only used for network interconnection where two higher-layer protocols are different. The structure of the gateway is also similar to the router, except for the interconnect layer. The gateway may be used for both wide area network and local area network interconnections. Performing identity authentication and authority verification on the user request; routing the user request to the micro-service and realizing load balancing; the user request is limited.
swagger is a real-time interface document generation tool. The interface document is an indispensable tool in the current front-end and back-end separation project, the back-end needs to go out of the interface document before the front-end and the back-end are developed, the front-end develops the project according to the interface document, and joint debugging test is carried out after the development of the front-end and the back-end is finished. The swagger is divided into two common versions of swagger2 and swagger 3.
And the swagger2 generates an api specification document of each module according to the specification, and generates an interface. The gateway serves as a data transfer station, collects data together and transfers the data to each interface through the gateway.
The response mechanism refers to a code which enables a client and a file system to be updated as a server at the same speed by utilizing a swagger (Web service for generating, describing, calling and visualizing RESTful styles), and a method, parameters and a model of the file are tightly integrated to the server side, so that an API is allowed to keep synchronization all the time.
Swagger is a generated interface development document generated according to the resumptful style and supports a piece of middleware that makes a test.
Background code, comprising: http port number, http username, mapping address, mapping port, forwarding policy.
The basic attributes of the gateway template in the http page include: communication protocol, domain name/ip, port, management user name, password, terminal registration authorization id, long-term access token, response timeout.
Gateway communication protocol refers to the protocol used in communication between different types of networks. The gateway communication protocol is a key component for connecting different networks, and can realize data conversion and transmission.
The terminal registration authorization ID refers to that in some application scenarios, in order to ensure the validity of the terminal device, the terminal device needs to be registered and authorized. The registration authority ID is typically a unique identifier for distinguishing between different terminal devices. When an application is installed on a terminal device, it is necessary to associate the registration authorization ID of the terminal device with the application, so as to ensure that only the authorized terminal device can use the application.
A Long term access token (Long-lived Access Token) refers to an access token with a longer validity period. Typically, an access token is a short term access credential with a short validity period, whereas a long term access token may be used for long term access to an application or service, with a validity period of up to days, weeks or months. The long-term access token may avoid the inconvenience of frequent re-authentication of the user, as compared to the short-term access token, while also improving the performance and efficiency of the application or service.
Reaction Timeout (Response Timeout) refers to when a client sends a request while network communication, if the server does not return a Response within a prescribed time, the client will stop waiting for the Response and throw a Timeout error.
The reaction timeout is set to avoid the client waiting for a response without limitation. In conducting network communications, a server may fail to respond to client requests in time for various reasons, such as network delay, server busyness, etc. If the client does not set a reaction timeout, it will wait for the server to respond all the time, which will reduce the response speed and performance of the application. By setting the reaction timeout, the client can wait for the server to respond within a prescribed time, and if the timeout occurs, the client can timely process errors and take corresponding measures.
A debug template, comprising: params configuration information, header configuration information, cookie configuration information, body configuration information.
URL, api_key, api_secret represent URL, API KEY, and API SECRET of the gateway, respectively, and may be modified according to actual situations. headers represents request header information, wherein X-API-KEY and X-API-seclet are API KEYs and API SECRET for authentication, respectively, and Content-Type represents the format of request data. data represents request data, and can be modified according to actual conditions. The requests. POST method is used to send POST requests, where JSON indicates that the requested data is in JSON format. Finally, the status code and response data of the response are output using response.status_code and response.json () respectively.
This is a simple gateway debug template that can be modified and extended according to the specific circumstances. In actual development, functions such as log recording and exception handling can be added as required to improve the reliability and robustness of the application.
And a correlation module:
swagger-tools, provide various tools for integration and interaction with Swagger. Such as pattern inspection,
Swagger-core Swagger implementation for Java/Scala. Integrated with JAX-RS (Jersey, resteasy, cxf.) frames, services, and playframes.
Swagger-js Swagger implementation for JavaScript.
Swagger-node-Express Swagger Module for Express web application framework of node. Js.
Swagger-ui: a set of independent HTML, JS, and CSS can dynamically generate graceful documents for Swagger compatible APIs.
Swagger-codegen: a template driven engine generates client code in various languages by analyzing user Swagger resource declarations.
Further, in S102, a debug template is prefabricated, where the debug template refers to that after the gateway is started, the installed protocol can simulate a request and a response through debug engineering.
The debugging template is a development mode for simulating front-end and back-end separation, the front-end is simulated to call a back-end interface (simulate the forwarding of data through a gateway), and the protocol mounted after the gateway engineering is started can simulate a request and a response through the debugging engineering.
Prefabricating a debugging template, wherein the concrete process comprises the following steps: analog request and response mechanisms of the protocol;
the simulation request of the protocol refers to capturing a request data packet, separating from a host, retransmitting the captured data packet once, simulating a real data capture packet, then simulating the request, achieving the re-package, realizing a set function based on the request packet, and the set function comprises the following steps: login protocol, check-in protocol, preemptive purchase protocol, game package, and then functions such as login, check-in, etc. can be implemented without relying on the host (i.e., without logging into a browser or application device).
The response mechanism refers to updating the client and file system as a server at the same speed using the swagger software (Web service for generating, describing, invoking and visualizing RESTful styles). The method, parameters and model of the file are tightly integrated into the code at the server side, allowing the API to stay synchronized at all times.
Further, in S102, the client creates an application program, including:
the client creates an application program item, and the client configures an application name, an application program catalog and an associated protocol template for the application program item, and then configures a gateway address, an interface and a debugging address of the application program item.
Further, in S102, the basic parameters in the prefabricated gateway template and the prefabricated debug template are replaced by the basic parameters of the application program correspondingly, where the basic parameters include: type, interface, document, or parsing template.
Further, in S102, the parsing the pulled data of the API template based on the HTTP protocol, and persisting the parsed data to the database, specifically includes: and analyzing the API interface method, the request address, the name and the request data.
Further, the step S102: the client creates an application program, specifically comprising:
creating an application program interface API template, the application program interface API template comprising: the device comprises a configuration part, an interface part, a document part, a parsing template part, a pulling data part and a deleting part.
A configuration section including: basic configuration of an API template; basic configuration of an API template, comprising: API type, API template naming, API template name, authorizing application, displaying icon, descriptive information, whether enabled, whether belonging to system user template, whether locking template. The user can modify the API template information in the system in the part, and the modified content can be automatically stored in the corresponding database.
An interface section comprising: interfaces to various APIs; interfaces to various APIs, including: GET, POST, PUT, DELETE, OPTIONS interface type.
The document part is a document with some Markdown in a common API, the Markdown document is added to a database, and after the database is added, a server synchronously updates and generates a corresponding document.
The analysis template part is in an API analysis general template, has strong universality and can meet the use in a certain scene or even certain scenes. The analysis template part may define response data analysis or request data analysis. After the analysis definition is finished, the background automatically generates a logic code through an algorithm, and a parser can be selected in the template for analysis.
And pulling the data part, namely pulling the existing API template, and automatically generating an interface and a document part by a server after pulling.
Further, the interface section includes: API interface setup, request configuration, response configuration, structure parsing, and interface debugging.
Each API interface in the API interface setting includes: self icon, global ID, name, request address, request method, request data analysis, response data analysis, text link, description information, whether to display, whether to enable, and whether to perform lower layer display. The global ID must be unique and the names are divided according to the traffic scenario. The request address is the address information (part before the parameter after the port number) in a complete request, and the address is spliced by an algorithm. The type of request to send is selected from the request methods and includes GET, POST, PUT, DELETE, OPTIONS. The request data analysis and the response data analysis can select the well defined data analysis type in the system, and can also be written and then called in a custom mode. This portion may be optional depending on the actual scenario if use is not required.
Requesting configuration, comprising: params configuration information, header configuration information, cookie configuration information, body configuration information.
The response configuration is the type of response, and 200 success types and 404 non-response types are common. The user can collect various types of response types in the actual operation in the use process, and then the system automatically generates corresponding types of response configurations.
The structure analysis is divided into a request data analyzer and a response data analyzer, a user does not have a proper analysis protocol template in an actual scene, the analyzer can be written online in the structure analysis, and after the writing is completed, a system automatically generates a logic code to return the analysis to the code.
Interface debugging, direct online debugging, debugging after configuration is completed, and the system automatically debugs according to the algorithm and returns the result type and data information.
Further, the prarm configuration information is a parameter part after the complete request, the prarm configuration information is determined according to parameter information following the actual request, and the number of parameters, the names and types of the parameters and the like can be filled in the prarm configuration information, and the prarm configuration information is spelled into the complete request after the completion of filling.
The Header configuration information is similar to the Cookie configuration information, and when the token is contained in the Header or the Cookie, the parameter information of the token can be filled in the corresponding place. And automatically generating logic codes and algorithms at the rear end after filling to realize the splicing of the complete request.
Body configuration information, including: the Swagger structure with all information and the RequestBody structure that needs to return information. The internal json format information is the returned request format.
Further, the interface configuration includes: hypertext transfer protocol format, method, request address, request data protocol, response data parsing.
Further, in S104, the association calls an interface mapping, which means that when a certain interface is requested, another interface needs to be called.
The HTTP access flow only needs to create a protocol template, create an application, start the application and request access at the user level.
The method comprises the steps of creating a protocol template, managing in an API module, creating an application, starting the application, and requesting access to the API application.
Creating a protocol template: the user configures the protocol interface address, the port, the mapping parameter and the general parameter on the page, and the information configured after the configuration is completed is persisted into the database.
Creating an application: the method comprises the steps of configuring in API application management, creating corresponding application items in an API application management page by a user, configuring application names, application catalogues and associated protocol templates, and configuring gateway addresses, gateway address interfaces, debugging addresses and debugging address interfaces of the corresponding items after the configuration is completed.
After the debugging interface is configured, the server automatically copies the core codes configured by the user, then finds the original pre-defined gateway template and debugging template of the system, replaces the original default core code part of the template, pulls the replaced associated protocol template and persists the interface information into the service file code.
Starting an application: after the application project is created, service starting is carried out according to the configuration when the application is created, a prefabricated gateway template and a prefabricated debugging template are replaced during starting, a persistence protocol template is loaded after starting, then a timing task is started, after the timing task is set, a third party interface configured by the timing task is actively requested according to a setting logic, and then the information return value is persistence to a memory.
For example, a timing task is set, the time for requesting the user to acquire the API interface last time is detected, and if the corresponding time is exceeded, the token credential needs to be acquired again; if the third party interface is not timed out, the token credential is directly obtained from the memory without re-requesting the third party interface.
Request access: acquiring the configured request parameters, acquiring the corresponding interface configuration in the service persistence template according to the request interface address and the method, judging whether the parameters have associated calling interface mapping according to the template interface configuration encapsulation parameters after the acquisition, returning to the template again to find the corresponding interface configuration if the parameters have associated calling interface mapping until all the associations are found, encapsulating the data format, and forwarding the data format to the request third party service.
The method is divided into two major categories, namely API template management and API application management.
There are two forms of creating templates in terms of API template management:
one is to create a complete API template, requiring the self-entry of a third party API template type;
the other is that the user can pull the existing third party template on the internet, and corresponding information is automatically generated in the platform. The technical contents mentioned below can be written and used on line on the basis of the original platform.
Self-entry requires the user to enter a name, an authorized application, a display icon, descriptive information, whether enabled, whether belonging to a system user template, whether to lock the template. And after the creation is completed, the template information is stored in a database.
The client creates an application program and sends the application program to the server; the API application management is divided according to different projects, and the same template can be applied to different projects. The API application management is to create corresponding application management according to the actual condition of the project by calling the existing API template (if not, the API template needs to be created, and then the API template is created. The API application management mainly comprises three parts of interface configuration, interface debugging and interface synchronization. And basic information such as whether gateway service is started, whether gateway service is available, whether gateway service is a system item, whether gateway service is locked, and description information is contained.
Interface configuration, configuration service domain name, authorization interface, token mapping field, and setting of timing time basic configuration. The service domain name obtains information data through an intranet penetration technology. The parameter configuration needs to configure information of Params, header and Cookie.
Interface debugging is a communicating part of an API interface in a debugging project. Returning all data in the Swagger structure when the interface is successfully debugged; the corresponding data type is returned when the failure occurs. When sending the debugging information, the local request can be called to an API interface of a third party through a logic algorithm, and then a set of logic codes is generated in the background.
And the interface synchronizing part is used for synchronizing information in the current interface configuration of the item and finding out corresponding data through intranet penetration. And then the information is quickly synchronized through an algorithm.
Example two
The embodiment provides a third party API protocol access system based on HTTP protocol;
a third party API protocol access system based on HTTP protocol, comprising: a client and a server;
the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server; the server persists configuration information in an API protocol template based on the HTTP protocol to a database for the first time;
the client creates an application program and sends the application program to the server; the method comprises the steps that a gateway template is prefabricated by a server, a debugging template is prefabricated by the server, and after an application program is received by the server, basic parameters in the prefabricated gateway template and the prefabricated debugging template are correspondingly replaced by the basic parameters of the application program;
the server pulls the API protocol template based on the HTTP protocol of the corresponding type from the database according to the type of the API protocol template of the application program, analyzes the data of the pulled API protocol template based on the HTTP protocol, and persists the analyzed data to the database for the second time;
the client starts an application program and sends a starting instruction to the server; after receiving the starting instruction, the server starts gateway service according to the prefabricated gateway template, starts debugging service according to the prefabricated debugging template, loads the second lasting API protocol template based on HTTP protocol, starts timing task, actively requests a third party interface of an application program configured by the timing task according to configuration information of the timing task, and sustains the acquired third party interface configuration of the application program into a memory;
the client sends the request parameters to the server; the server acquires the request parameters, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol according to the request interface address of the request parameters, encapsulates the request parameters according to the third party interface configuration of the application program, judges whether the request parameters have associated calling interface mapping, acquires the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol again according to the request interface address if the request parameters have associated calling interface mapping, and forwards the encapsulated interface object to the application program of the client if the request interface configuration does not have associated calling interface mapping.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. The third party API protocol access method based on the HTTP protocol is characterized by comprising the following steps:
the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server;
the client creates an application program and sends the application program to the server;
the client starts an application program and sends a starting instruction to the server;
the client sends the request parameters to the server.
2. The HTTP protocol-based third party API protocol access method as recited in claim 1, wherein after the client creates the HTTP protocol-based API protocol template and transmits the HTTP protocol-based API protocol template to the server, the client creates the application and before transmitting the application to the server, further comprising:
the server persists configuration information in the HTTP protocol-based API protocol template to the database for the first time.
3. The HTTP protocol-based third-party API protocol access method as recited in claim 1, wherein after the client creates the application and transmits the application to the server, the client starts the application and transmits the start instruction to the server, further comprising:
and the server prefabricates the gateway template, the server prefabricates the debugging template, and after receiving the application program, the server correspondingly replaces basic parameters in the prefabricated gateway template and the prefabricated debugging template with the basic parameters of the application program.
4. The method for accessing a third party API protocol based on HTTP protocol according to claim 3, wherein after replacing the basic parameters in the prefabricated gateway template and the prefabricated debug template with the basic parameters of the application program, the client starts the application program and before sending the start instruction to the server, further comprising:
and the server pulls the API protocol template based on the HTTP protocol of the corresponding type from the database according to the type of the API protocol template of the application program, analyzes the data of the pulled API protocol template based on the HTTP protocol, and persists the analyzed data to the database for the second time.
5. The HTTP protocol-based third-party API protocol access method as recited in claim 1, wherein after the client starts the application program and sends the start instruction to the server, before the client sends the request parameter to the server, the method further comprises:
after the server receives the starting instruction, the server starts gateway service according to the prefabricated gateway template, the server starts debugging service according to the prefabricated debugging template, the server loads the second lasting API protocol template based on the HTTP protocol, the server starts the timing task, the server actively requests a third party interface of the application program configured by the timing task according to the configuration information of the timing task, and the acquired third party interface configuration of the application program is lasting to the memory.
6. The HTTP protocol-based third-party API protocol access method as recited in claim 1, wherein after the client sends the request parameter to the server, further comprising:
the server obtains the request parameters, and according to the request interface address of the request parameters, the server obtains the third party interface configuration of the corresponding application program in the API protocol template based on the HTTP protocol, and encapsulates the request parameters according to the third party interface configuration of the application program.
7. The HTTP protocol-based third party API protocol access method as recited in claim 6, further comprising, after encapsulating the request parameters according to the third party interface configuration of the application:
judging whether the request parameters have associated calling interface mapping, if so, acquiring third-party interface configuration of the corresponding application program in the API template based on the HTTP protocol again according to the request interface address, and if not, forwarding the packaged interface object to the application program of the client.
8. The HTTP protocol-based third party API protocol access method as recited in claim 1, wherein the HTTP protocol-based API protocol template includes: API protocol type, API protocol template name, and authorized application.
9. The third party API protocol access method based on HTTP protocol according to claim 3, wherein the server pre-forms gateway template, wherein the gateway template is third party API protocol configuration template, the configuration parameters are loaded into gateway operation file according to the configuration parameters, after the gateway is started, the configuration template is operated as gateway program of business or project according to the configuration parameters; a debug template, comprising: params configuration information, header configuration information, cookie configuration information, body configuration information.
10. A third party API protocol access system based on HTTP protocol, comprising: a client and a server;
the client creates an API protocol template based on the HTTP protocol and sends the API protocol template based on the HTTP protocol to the server;
the client creates an application program and sends the application program to the server;
the client starts an application program and sends a starting instruction to the server;
the client sends the request parameters to the server.
CN202310518292.7A 2023-05-06 2023-05-06 Third party API protocol access method and system based on HTTP protocol Pending CN116599949A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310518292.7A CN116599949A (en) 2023-05-06 2023-05-06 Third party API protocol access method and system based on HTTP protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310518292.7A CN116599949A (en) 2023-05-06 2023-05-06 Third party API protocol access method and system based on HTTP protocol

Publications (1)

Publication Number Publication Date
CN116599949A true CN116599949A (en) 2023-08-15

Family

ID=87607327

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310518292.7A Pending CN116599949A (en) 2023-05-06 2023-05-06 Third party API protocol access method and system based on HTTP protocol

Country Status (1)

Country Link
CN (1) CN116599949A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573390A (en) * 2023-11-20 2024-02-20 航天信息(广东)有限公司 Data processing method, cloud, client and data processing system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573390A (en) * 2023-11-20 2024-02-20 航天信息(广东)有限公司 Data processing method, cloud, client and data processing system

Similar Documents

Publication Publication Date Title
CN106776313B (en) Method and device for simulating service and centralized management platform
US6253325B1 (en) Apparatus and method for securing documents posted from a web resource
US7437275B2 (en) System for and method of multi-location test execution
US8856735B2 (en) System and method of generating REST2REST services from WADL
US7992127B2 (en) Method and system of encapsulating web site transactions for computer-aided generation of web services
US6728884B1 (en) Integrating heterogeneous authentication and authorization mechanisms into an application access control system
KR102243793B1 (en) Method and apparatus for code virtualization and remote process call generation
US6804816B1 (en) Method and template for developing device-centric network management applications
US20070168997A1 (en) Debugging of remote application software on a local computer
CN108304207A (en) Mix the resource regeneration method and system of APP application programs
CN104536890B (en) Test system, method and apparatus
CN103198130B (en) The method and apparatus realizing the login unified with webpage at client
JPH10187575A (en) Client-object api/gateway for enabling oltp through internet
US20050210135A1 (en) System for ubiquitous network presence and access without cookies
CN111143207B (en) Method for checking model training notice and training log at mobile terminal
CN100512158C (en) Network measuring system structure and realizing method thereof
CN112835782B (en) Interface access test method and system
CN116599949A (en) Third party API protocol access method and system based on HTTP protocol
CN107196936A (en) Interface retransmission method, system, computer equipment and storage medium
US20040260806A1 (en) System supporting communication between a web enabled application and another application
CN108446105A (en) A kind of Lightweight AP I Server Development Frameworks and development approach
CN107888451A (en) The method of testing and device of a kind of Web server
US6968356B1 (en) Method and apparatus for transferring data between a client and a host across a firewall
CN112954658B (en) Business card system suitable for data exchange of communication protocol layer and data exchange method
JP5191076B2 (en) Information providing apparatus and method

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