Interface calling method, device and system, gateway, storage medium and program product
By pre-registering and storing the protocol information of the demander and interface providers in the registration center and configuration center, and using the gateway to perform protocol adaptation and request forwarding, the problem of differences in protocol specifications when the demander and different interface providers is solved, automated and flexible protocol adaptation is achieved, development and maintenance costs are reduced, and system stability and scalability are improved.
Patent Information
- Application Number
- CN202411993719.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-06
AI Technical Summary
In business scenarios, the demander needs to connect with different interface providers. However, due to differences in protocol specifications and requirements, the demander needs to carry out customized development, which has problems such as high resource consumption, difficulty in maintenance, poor scalability, and dependence on development capabilities and technical knowledge.
By pre-registering and storing the protocol information of the demander and interface providers in the registry and configuration center, and setting adaptation policies between different protocol information in the configuration center, using the gateway to perform protocol adaptation and request forwarding, automated and flexible protocol adaptation between the demander and interface providers are achieved.
There is no need to conduct customized development on the demand side, so as to realize automated and flexible protocol adaptation between the demand side and each interface provider, eliminate protocol differences, reduce development and maintenance costs, and improve system stability and scalability.
Smart Images

Figure CN119946155A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an interface calling method, device, system, gateway, storage medium and program product. Background Art
[0002] In some business scenarios, the demand side usually needs to connect with different interface providers. Since different interface providers may use different protocol specifications and requirements, the demand side needs to carry out customized development according to the protocol standards of each interface provider, which requires a large amount of development resources, is difficult to maintain, has poor scalability, and is highly dependent on development capabilities and technical knowledge. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide an interface calling method, device, system, gateway, storage medium and program product, which are used to realize automatic and flexible protocol adaptation between the demander and different interface providers, and can effectively eliminate the protocol differences between the demander and the interface provider, and ensure the stability and scalability of system integration.
[0004] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions: In a first aspect, an embodiment of the present application provides an interface calling method, comprising: In response to receiving a first interface call request from a demander, acquiring from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; Acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; Based on the first adaptation strategy, converting the first interface call request into a second interface call request applicable to the first interface provider; The second interface call request is sent to the first interface provider.
[0005] In a second aspect, an embodiment of the present application provides an interface calling device, including: A response module, configured to, in response to receiving a first interface call request from a demander, obtain from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; an acquisition module, configured to acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; a conversion module, configured to convert the first interface call request into a second interface call request applicable to the first interface provider based on the first adaptation strategy; The first sending module is used to send the second interface calling request to the first interface provider.
[0006] In a third aspect, an embodiment of the present application provides a gateway, including: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the interface calling method provided in the first aspect.
[0007] In a fourth aspect, an embodiment of the present application provides an interface calling system, including: a registration center, a configuration center, and a gateway; The configuration center is used to store the adaptation strategy between different protocol information; The gateway is configured to, in response to receiving a first interface call request from the demander, obtain from the registration center the first protocol information and second protocol information used by the first interface provider corresponding to the first interface call request, and obtain from the configuration center a first adaptation strategy between the first protocol information and the second protocol information; The gateway is further configured to convert the first interface call request into a second interface call request applicable to the first interface provider based on the first adaptation strategy, and send the second interface call request to the first interface provider.
[0008] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the interface calling method provided in the first aspect.
[0009] In a sixth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the interface calling method provided in the first aspect.
[0010] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: The demander and each interface provider register the protocol information they use in advance to the registration center for subsequent query during docking; in addition, the adaptation strategy between different protocol information is set in the configuration center to realize the conversion between request messages using different protocols. On this basis, a gateway is added as a bridge for data interaction between the demander and each interface provider. The demander sends the first interface call request to the gateway, and the gateway obtains the first protocol information used by the demander and the second protocol information used by the first interface provider corresponding to the first interface call request from the registration center, and then obtains the first adaptation strategy between the first protocol information and the second protocol information from the configuration center, and based on the first adaptation strategy, converts the first interface call request into a second interface call request applicable to the first interface provider, which can eliminate the protocol differences between the demander and the first interface provider; afterwards, the gateway sends the second interface call request to the first interface provider, so that the first interface provider can identify the second interface call request to perform the corresponding response operation, thereby realizing the docking between the demander and the first interface provider. In this way, there is no need to carry out customized development on the demand side, and automatic and flexible protocol adaptation can be achieved between the demand side and various interface providers, which can simply and efficiently eliminate the protocol differences between the demand side and the interface providers to be connected. This can not only avoid the problems brought about by customized development, such as consumption of a large amount of development resources, difficult maintenance, poor scalability, high dependence on development capabilities and technical knowledge, but also be applicable to various complex business scenarios, and through the unified adaptation and request forwarding of the gateway, the stability and scalability of the system integration are guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A schematic diagram of a system architecture involved in an embodiment of the present application; Figure 2 A flowchart of an interface calling method provided for an embodiment of the present application; Figure 3 A flowchart of an interface calling method provided for another embodiment of the present application; Figure 4 A schematic diagram of the structure of an interface calling device provided for one embodiment of the present application; Figure 5 A schematic diagram of the structure of a gateway provided for one embodiment of the present application. DETAILED DESCRIPTION
[0012] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0013] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.
[0014] As mentioned above, the demand side usually needs to connect with different interface providers. Since different interface providers may use different protocol specifications and requirements, the demand side needs to carry out customized development according to the protocol standards of each interface provider. This approach has the following shortcomings: (1) High customized development costs: Since the protocol specifications and requirements of each interface provider may be different, the demander needs to spend a lot of time and resources on customized development and transformation, which increases development complexity and resource consumption; (2) Difficulty in maintenance: As the interface providers and the protocols they use change, the protocol conversion method needs to be continuously maintained and updated, which may require additional workload and attention, especially when the interface provider frequently adjusts the protocol specifications.
[0015] (3) Poor scalability: Since the protocol conversion method is customized based on a specific interface protocol, it becomes difficult to support new interfaces or protocols. Every time a new protocol is added or modified, it needs to be redeveloped and modified.
[0016] (4) High dependence on development capabilities and technical knowledge: The above-mentioned customized development solutions usually require the demander to have certain development capabilities and technical knowledge, which may limit the ability of some non-technical companies or individuals to participate in interface docking.
[0017] In view of this, the embodiment of the present application proposes an interface calling method to realize automatic and flexible protocol adaptation between the demander and different interface providers, which can effectively eliminate the protocol differences between the demander and the interface provider. Through the modular design of the system, the adaptation process becomes simple and efficient, and can be flexibly adjusted in complex scenarios. Finally, the adapted interface is registered and managed through the gateway, ensuring the stability and scalability of the system integration.
[0018] Before introducing the interface calling method provided in the embodiment of the present application in detail, a brief introduction to the system architecture involved in the embodiment of the present application is first given. Figure 1 , is a schematic diagram of a system architecture shown in an embodiment of the present application, wherein the system mainly includes a registration center, a configuration center and a gateway.
[0019] The demander and each interface provider (such as interface provider 1~interface provider n) register the protocol information they use in advance to the registration center for query during subsequent docking; in addition, the adaptation strategy between different protocol information is set in the configuration center to achieve conversion between request messages using different protocols.
[0020] The gateway acts as a bridge for data interaction between the demand side and various interface providers. The gateway platform has a built-in conversion engine for adapting and converting different protocol information.
[0021] The demander sends a first interface call request to the gateway, and the gateway obtains the first protocol information used by the demander and the second protocol information used by the first interface provider corresponding to the first interface call request from the registration center, and then obtains the first adaptation strategy between the first protocol information and the second protocol information from the configuration center, and calls the built-in conversion engine. Based on the first adaptation strategy, the first interface call request is converted into a second interface call request suitable for the first interface provider, which can eliminate the protocol differences between the demander and the first interface provider.
[0022] Afterwards, the gateway sends the second interface call request to the first interface provider, so that the first interface provider can identify the second interface call request to perform a corresponding response operation, thereby achieving docking between the demander and the first interface provider.
[0023] In this way, there is no need to carry out customized development on the demand side, and automatic and flexible protocol adaptation can be achieved between the demand side and various interface providers, which can simply and efficiently eliminate the protocol differences between the demand side and the interface providers to be connected. This can not only avoid the problems brought about by customized development, such as consumption of a large amount of development resources, difficult maintenance, poor scalability, high dependence on development capabilities and technical knowledge, but also be applicable to various complex business scenarios, and through the unified adaptation and request forwarding of the gateway, the stability and scalability of the system integration are guaranteed.
[0024] Based on the system architecture introduced above, the interface calling method provided in the embodiment of the present application is described in detail with reference to the accompanying drawings.
[0025] Please refer to Figure 2 , is a flow chart of an interface calling method provided by an embodiment of the present application, the method can be applied to a gateway, and the method includes the following steps: S202, in response to receiving a first interface call request from a demander, obtaining from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request.
[0026] The demander refers to a business party with an interface call requirement. The first interface provider corresponding to the first interface call request refers to the interface provider for responding to the first interface call request, that is, the interface provider of the first interface requested to be called by the first interface call request.
[0027] The first interface call request is used to request to call the first interface. The first interface call request is a request message sent by the demander using the first transmission protocol. The first transmission protocol can be set by the demander according to actual business needs. For example, the first transmission protocol can be HTTP (HyperText Transfer Protocol).
[0028] The first interface call request carries the corresponding message content, which may include, for example, but is not limited to, the name of the first interface requested to be called, the type of transmission protocol, the request encoding method, the request parameters and the return parameters. Among them, the request encoding method refers to the format of the request parameters, such as JSON (JavaScript Object Notation), XML (Extensible Markup Language), etc. The request parameters are used to represent the data sent to the interface provider of the first interface. The return parameters are used to represent the data returned by the interface provider in response to the first interface call request. These data generally include, but are not limited to, the result of the request, the status code, the error message or other related information.
[0029] The first protocol information is used to describe the protocol specifications and requirements used by the demander. As an example, the first protocol information may include the first transmission protocol used by the demander and the first message content corresponding to the first transmission protocol. The first message content corresponding to the first transmission protocol refers to the message content that can be carried when the demander uses the first transmission protocol to initiate an interface call. Specifically, the first message content may include, for example, but is not limited to: request method (such as POST, GET), request parameters, return parameters, etc.
[0030] The second protocol information is used to describe the protocol specifications and requirements used by the first interface provider. As an example, the second protocol information may include the second transmission protocol used by the first interface provider and the second message content corresponding to the second transmission protocol. The second transmission protocol may be different from the first transmission protocol, such as gRPC (Google Remote Procedure Call Protocol, a high-performance remote procedure call protocol), WebSocket, etc. The second message content corresponding to the second transmission protocol refers to the message content that the first interface provider can recognize based on the second transmission protocol. Specifically, the second message content may, for example, include but is not limited to: request method, request parameters, return parameters, etc.
[0031] In the above S202, the first protocol information and the second protocol information may be obtained in various appropriate ways.
[0032] In one embodiment, the registration center records the first registration information of the demander and the second registration information of the first interface provider. The first registration information includes the protocol information corresponding to the interface that the demander can request. The second registration information includes the protocol information corresponding to the interface provided by the first interface provider. In this case, the above S202 includes the following steps: from the first interface call request, parse and obtain the interface identifier of the first interface requested to be called by the first interface theft request; based on the interface identifier of the first interface, obtain the protocol information corresponding to the first interface from the first registration information as the first protocol information used by the demander; based on the interface identifier of the first interface, obtain the protocol information corresponding to the first interface from the second registration information as the second protocol information used by the first interface provider.
[0033] For example, the following Table 1 shows an example of registration information, which includes the interface identifier of the interface and the protocol information corresponding to the interface. Among them, the interface identifier may include: the unique identifier, name and URL of the interface, etc. The protocol information corresponding to the interface in the registration information includes: the transmission protocol used for the interface, the message content corresponding to the transmission protocol, etc. Among them, for the demander, the message content is used for the demander to carry in the interface call request when requesting the interface; for the interface provider, the message content is the message content that the interface provider can recognize based on the transmission protocol. The message content includes: the request method for the interface, the URL (Uniform Resource Locator) of the interface, request parameters, return parameters and other fields.
[0034] Table 1
[0035] Assuming that the first registration information of the demander includes the protocol information corresponding to interface 1, interface 2 and interface 3 respectively, and the second registration information of the first interface provider includes the protocol information corresponding to interface 1 and interface 4 respectively, the gateway parses the interface identifier of interface 1 from the first interface call request, then reads the protocol information corresponding to interface 1 from the first registration information as the first protocol information, and reads the protocol information corresponding to interface 1 from the second registration information as the second protocol information.
[0036] In the above implementation, the demander registers the protocol corresponding to the interface that it can request to the registration center, and each interface provider registers the protocol information corresponding to the interface provided by it to the registration information. After receiving the first interface call request from the demander, the gateway can quickly and accurately identify the first protocol information used by the demander to send the first interface call request and the second protocol information used by the first interface provider through the interface identifier carried in the first interface call request, thereby providing reliable data support for the subsequent accurate identification of the protocol differences between the demander and the first interface provider and the protocol adaptation between the demander and the first interface provider.
[0037] The above describes some implementation methods of the above S202. Of course, it should be understood that the above S202 can also be implemented in other ways, which are not limited in the present embodiment.
[0038] S204: Acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center.
[0039] The configuration center stores the adaptation strategies between different protocol information. The adaptation strategy is used to describe the adaptation method for adapting the corresponding two protocol information. The adaptation strategy between different protocol information can be generated by the configuration center according to the differences between different protocol information. In practical applications, the number of adaptation strategies between any two protocol information can be multiple. In this case, the configuration center can also arrange these adaptation strategies and store the arrangement information in the form of an arrangement configuration table to intuitively reflect the protocol information used by the demander of each interface, the protocol information used by the interface provider, the adaptation strategy between the two protocol information and the order of their execution. For example, the following Table 2 shows an example of an arrangement configuration table.
[0040] Table 2
[0041] As an example, for any two protocol information, if there are differences between the two in the transport protocols contained therein, but there are no differences in the message content corresponding to the transport protocols, then the adaptation strategy between the two protocol information includes a structure conversion strategy. Among them, the structure conversion strategy is used to convert the message structure of one transport protocol into the message structure of another transport protocol, so as to achieve the adaptation of the message structure of the request messages of the two parties of the two transport protocols in the interaction. For example, one transport protocol is HTTP and the other transport protocol is gRPC. There are differences in the message structures of the two transport protocols. Then the structure conversion strategy between the two is used to convert the message structure of HTTP into the message structure of gRPC.
[0042] As another example, for any two protocol information, if there are differences between the two not only in the transport protocols included, but also in the message contents corresponding to the transport protocols, then the adaptation strategy between the two protocol information also includes a content conversion strategy. The content conversion strategy is used to convert the message content corresponding to one transport protocol into the message content corresponding to another transport protocol, so as to achieve the adaptation of the message contents of the interactive request messages between the two parties of the two transport protocols.
[0043] Specifically, the content conversion strategy may include, but is not limited to, parameter mapping relationships, data structure mapping relationships, and encoding mapping relationships. The parameter mapping relationship is used to represent the mapping relationship between parameters in the message content corresponding to the two transmission protocols. For example, the parameter representing the applicant's ID number in the message content corresponding to HTTP is applyerPageCode, but the parameter representing the applicant's ID number in the message content corresponding to WebService is manCredentialNo, then the parameter mapping relationship includes the mapping relationship between applyerPageCode and manCredentialNo.
[0044] The data structure mapping relationship is used to represent the mapping relationship between the data structures of the parameters in the message content corresponding to the two transmission protocols. For example, the data structure of the parameter materialAttach representing the attachment information in the message content corresponding to HTTP is a form, but the parameter List representing the attachment information in the message content corresponding to WebService is <appointattachmentlistvo>If the data structure is a sequence, the data structure mapping relationship includes a mapping relationship between the form and the sequence.
[0045] The encoding mapping relationship is used to represent the mapping relationship between the encoding methods of the message content corresponding to two transmission protocols. For example, the encoding method of the message content corresponding to HTTP is application / json, but the encoding method of the message content corresponding to WebService is text / xml, then the encoding mapping relationship includes the mapping relationship between application / json and text / xml.
[0046] In the above S204, for each configuration strategy of the configuration center, if the two protocol information corresponding to the adaptation strategy respectively match the first protocol information and the second protocol information, the adaptation strategy is determined as the first adaptation strategy.
[0047] S206: Based on the first adaptation strategy, convert the first interface call request into a second interface call request applicable to the first interface provider.
[0048] Since the transmission protocol used by the demander is different from that used by the first interface provider, the first interface call request cannot be recognized by the first interface provider. Therefore, the gateway converts the first interface call request into a second interface call request to ensure that the second interface call request can be recognized by the first interface provider to perform a corresponding response operation, thereby achieving the connection between the demander and the first interface provider.
[0049] In the above S206, the gateway may convert the first interface calling request into the second interface calling request in various appropriate ways.
[0050] In one implementation, the first adaptation strategy includes: a first structure conversion strategy between the first transmission protocol and the second transmission protocol, and a first content conversion strategy between the first message content and the second message content.
[0051] The above S206 includes the following steps: S261, based on the structure conversion strategy, convert the message structure of the first interface call request into a target message structure corresponding to the second transmission protocol.
[0052] For example, if the message structure of the first interface call request is the HTTP message structure, and the second transmission protocol is WebService, the message structure corresponding to HTTP is converted to the WebService message structure. In addition, the conversion of the message structure may also include but is not limited to: adjustment of the request header information and conversion of the method type, thereby greatly simplifying the conversion process of the message structure.
[0053] Through the structural conversion strategy, the gateway can automatically adjust the message structure of the interface call request sent by the demander according to the protocol specifications of the interface provider, and automatically identify and adapt to multiple transmission protocols, such as HTTP, gRPC, WebSocket, etc., to achieve true multi-protocol compatibility and a wider range of applications.
[0054] S262: Based on the content conversion strategy, convert the message content carried in the first interface call request into target message content.
[0055] As an example, the above S262 includes the following steps: Step A1: Based on the first parameter mapping relationship, the request parameters in the message content are mapped to target request parameters.
[0056] For example, the parameter representing the applicant's ID number in the message content corresponding to HTTP is applyerPageCode, but the parameter representing the applicant's ID number in the message content corresponding to WebService is manCredentialNo. The first parameter mapping relationship includes the mapping relationship between applyerPageCode and manCredentialNo, and then according to the parameter mapping relationship, applyerPageCode is mapped to manCredentialNo.
[0057] In addition, the content conversion strategy also provides for adding default fields in the request parameters and deleting redundant fields to achieve alignment between the request parameters of the demander and the request parameters that can be recognized by the interface provider.
[0058] The above parameter mapping relationship provides a flexible parameter mapping mechanism, which can automatically convert the request parameters of the demander into request parameters that can be recognized by the interface provider, and supports adding default fields and deleting redundant fields, which significantly improves the flexibility and automation of parameter mapping.
[0059] Step A2: Based on the first data structure mapping relationship, determine the target data structure corresponding to the data structure of the request parameter in the message content.
[0060] For example, the data structure of the parameter materialAttach representing the attachment information in the HTTP corresponding message content is a form, but the parameter List representing the attachment information in the WebService corresponding message content is <appointattachmentlistvo>The data structure of materialAttach is a sequence, then the first data structure mapping relationship includes a mapping relationship between a form and a sequence, and then according to the data structure mapping relationship, the data structure of materialAttach is mapped from a form to a sequence.
[0061] Through the data structure mapping relationship, the gateway can automatically parse and reorganize the data structure of the request parameters to meet the requirements of the interface provider without manual intervention, greatly improving efficiency and accuracy.
[0062] Step A3: Based on the first encoding mapping relationship, determine a target encoding method corresponding to the encoding method of the request parameter in the message content.
[0063] For example, the encoding method of the message content corresponding to HTTP is application / json, but the encoding method of the message content corresponding to WebService is text / xml. The first encoding mapping relationship includes the mapping relationship between application / json and text / xml, and then according to the encoding mapping relationship, the encoding method is changed from application / json to text / xml.
[0064] Step A4, based on the target encoding method and the target data structure, encode the target request parameters to obtain the target message content.
[0065] Through the above encoding mapping relationship, the gateway can support automatic conversion between different encoding methods, ensuring that the request parameters are not distorted when transmitted between different encoding formats, simplifying the encoding conversion process and improving the reliability of data transmission.
[0066] S263: Generate a second interface call request suitable for the first interface provider based on the target message structure and the target message content.
[0067] Specifically, the target message content is assembled according to the target message structure to obtain the second interface calling request.
[0068] In another embodiment, the above S206 may include the following steps: comparing the message structure of the first interface call request with the message structure corresponding to the second transmission protocol used by the first interface provider, and comparing the message content carried by the first interface call request with the second message content corresponding to the second transmission protocol to obtain difference information; obtaining the adaptation strategy corresponding to the difference information from the first adaptation strategy, and converting the first interface call request into a second interface call request based on the selected adaptation strategy.
[0069] The conversion of message structure will not be described in detail.
[0070] For the adaptation of the message content, if the message content carried by the first interface call request differs from the second message content only in the request parameters, the parameter mapping relationship is selected from the first adaptation strategy to map the request parameters in the message content carried by the first interface call request to the corresponding target request parameters in the second message content.
[0071] If the message content carried by the first interface call request differs from the second message content only in the encoding method of the request parameters, a coding mapping relationship is selected from the first adaptation strategy, and a target encoding method corresponding to the encoding method of the request parameters is determined based on the coding mapping relationship, and then the request parameters are encoded using the target encoding method to obtain the target message content.
[0072] The above describes some implementation methods of the above S206. Of course, it should be understood that the above S206 can also be implemented in other ways, which are not limited in the present embodiment.
[0073] S208: Send the second interface call request to the first interface provider.
[0074] After the gateway sends the second interface call request to the first interface provider, the first interface provider can parse the second interface call request, obtain the first interface to be called by the demander, the request parameters provided by the demander, and the required return parameters, and then respond to the second interface call request based on this information, generate a first response message and return it to the gateway, which will then forward it to the demander.
[0075] In another embodiment, after the above S208, the interface calling method provided in the embodiment of the present application may further include the following steps: S210: Receive a first response message returned by the first interface provider.
[0076] S212: Based on the first adaptation strategy, convert the first response message into a second response message suitable for the demand side.
[0077] The specific implementation of the above S212 is similar to the specific implementation of the above S206 and will not be repeated here.
[0078] S214, sending the second response message to the demander.
[0079] In this embodiment, since the transmission protocol used by the demander is different from the transmission protocol used by the first interface provider, the first response message may not be recognized by the demander. Therefore, by converting the first response message into a second response message based on the first transmission protocol by the gateway, it is ensured that the second response message can be recognized by the demander to perform corresponding business processing, thereby realizing two-way interaction between the demander and the first interface provider.
[0080] The interface calling method provided in the embodiment of the present application can be applied to various business scenarios, and the embodiment of the present application does not limit this. Figure 3 and the above Figure 1 Each module in the system architecture shown provides a detailed description of the interface calling method provided in the embodiment of the present application.
[0081] In the process of building a business that can efficiently complete one thing, it is often necessary for the provincial business platform (demand side) to connect with the national, provincial, municipal, district and county self-built platforms (interface providers). The national platform cannot be modified, and the provincial, municipal, district and county platforms cannot achieve the connection between the self-built platform and the provincial business platform due to limited resources and insufficient development capabilities, resulting in the inability of the business to operate normally. For this reason, a set of interface call systems suitable for government data protocol adaptation and conversion has been redeveloped. The interface call system includes functional modules such as the registration center, configuration center, and gateway. Through the collaboration between these functional modules, the connection between different self-built platforms and the provincial business platform is realized, and the system can be adjusted as shown, with the advantages of pluggable and high degree of freedom.
[0082] Specifically, if Figure 3 As shown, each interface provider registers the interface it provides and its corresponding protocol information and other registration information in the registration center, and the demander registers the protocol information and other registration information corresponding to the interface provided by each interface provider in the registration center. For example, an interface provider registers an interface with a transmission protocol of HTTP and a request method of POST in the registration center, and the corresponding message content. The message content includes request parameters such as the applicant's ID number (applyPageCode), the applicant's gender (applyerSex), and the material attachment information (materialAttach). The demander registers the transmission protocol WebService used for the interface and the corresponding message content in the registration center. The message content includes: the applicant's ID number (manCredentialNo), the applicant's date of birth (manBirthday), the applicant's gender (manSex), and the attachment information (List <appointattachmentlistvo>).
[0083] Then, for each interface provider, the configuration center generates an adaptation strategy between the protocol information registered by the interface provider and the protocol information registered by the demander, so as to eliminate the protocol differences between the demander and the interface provider. In addition, the configuration center can also orchestrate the above adaptation strategies and store the orchestration information in the form of an orchestration configuration table. For example, the structural adaptation strategy in the adaptation strategy is to convert the HTTP message structure used by the demander into the WebService message structure used by the interface provider. The content adaptation strategy in the adaptation strategy includes: mapping the parameter mapping relationship of applyerPageCode to manCredentialNo, extracting the parameter mapping relationship of mapping the date of birth to manBirthday from applyPageCode, and converting the attachment type, attachment address and other parameters in materialAttach into List <appointattachmentlistvo>The data structure mapping relationship of mapping applyerSex to the parameter mapping relationship of manSex, etc.
[0084] If the demander needs to call an interface provided by an interface provider (i.e., the first interface provider) during the business process, the first interface call request for the interface is sent to the gateway. The gateway obtains the first protocol information used by the demander and the second protocol information used by the first interface provider from the registration center, and obtains the first adaptation strategy between the first protocol information and the second protocol information from the configuration center.
[0085] Further, the gateway calls the built-in conversion engine, and based on the first adaptation strategy, converts the message structure of the first call request into a target message structure corresponding to the second transmission protocol used by the first interface provider, and converts the message content carried by the first call request into target message content that can be recognized by the first interface provider, and then generates a second interface call request suitable for the first interface provider based on the target message structure and the target message content and forwards it to the first interface provider.
[0086] The first interface provider responds to the second interface call request, obtains a first response message and returns it to the gateway. The gateway converts the first response message into a second response message suitable for the demander based on the first adaptation strategy and forwards it to the demander.
[0087] In this way, the connection between the demander and the first interface provider is achieved.
[0088] One or more embodiments of the present application provide an interface calling method, in which the demander and each interface provider pre-register the protocol information used by themselves to the registration center for subsequent query during docking; in addition, an adaptation strategy between different protocol information is set in the configuration center to realize the conversion between request messages using different protocols. On this basis, a gateway is added as a bridge for data interaction between the demander and each interface provider, the demander sends a first interface call request to the gateway, and the gateway obtains the first protocol information used by the demander and the second protocol information used by the first interface provider corresponding to the first interface call request from the registration center, and then obtains the first adaptation strategy between the first protocol information and the second protocol information from the configuration center, and based on the first adaptation strategy, converts the first interface call request into a second interface call request applicable to the first interface provider, which can eliminate the protocol difference between the demander and the first interface provider; after that, the gateway sends the second interface call request to the first interface provider, so that the first interface provider can identify the second interface call request to perform the corresponding response operation, thereby realizing the docking between the demander and the first interface provider. In this way, there is no need to carry out customized development on the demand side, and automatic and flexible protocol adaptation can be achieved between the demand side and various interface providers, which can simply and efficiently eliminate the protocol differences between the demand side and the interface providers to be connected. This can not only avoid the problems brought about by customized development, such as consumption of a large amount of development resources, difficult maintenance, poor scalability, high dependence on development capabilities and technical knowledge, but also be applicable to various complex business scenarios, and through the unified adaptation and request forwarding of the gateway, the stability and scalability of the system integration are guaranteed.
[0089] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0090] Based on the same inventive concept, the present application embodiment also provides an interface calling device. Figure 4 , is a structural diagram of an interface calling device 400 provided in an embodiment of the present application. The device 400 can be applied to a gateway. The device 400 includes: A response module 410 is used for, in response to receiving a first interface call request from a demander, obtaining from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; An acquisition module 420 is used to acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; A conversion module 430, configured to convert the first interface call request into a second interface call request applicable to the first interface provider based on the first adaptation strategy; The first sending module 440 is configured to send the second interface calling request to the first interface provider.
[0091] In another embodiment, the registration center records the first registration information of the demander and the second registration information of the first interface provider, the first registration information includes the protocol information corresponding to the interface that the demander can request, and the second registration information includes the protocol information corresponding to the interface provided by the first interface provider; The response module is used to: Parsing the first interface call request to obtain an interface identifier of the first interface requested to be called by the first interface call request; Based on the interface identifier of the first interface, acquiring protocol information corresponding to the first interface from the first registration information as first protocol information used by the demander; Based on the interface identifier of the first interface, protocol information corresponding to the first interface is obtained from the second registration information as second protocol information used by the first interface provider.
[0092] In another embodiment, the first protocol information includes a first transmission protocol and a first message content corresponding to the first transmission protocol, and the second protocol information includes a second transmission protocol and a second message content corresponding to the second transmission protocol; The first adaptation strategy includes: a first structure conversion strategy between the first transmission protocol and the second transmission protocol, and a first content conversion strategy between the first message content and the second message content; The conversion module is used for: Based on the first structure conversion strategy, converting the message structure of the first interface call request into a target message structure corresponding to the second transmission protocol; Based on the first content conversion strategy, converting the message content carried by the first interface call request into target message content; Based on the target message structure and the target message content, a second interface call request suitable for the first interface provider is generated.
[0093] In another embodiment, the first content conversion strategy includes: a first parameter mapping relationship, a first data structure mapping relationship, and a first encoding mapping relationship; When the conversion module converts the message content carried in the first interface call request into the target message content based on the content conversion strategy, the conversion module performs the following operations: Based on the first parameter mapping relationship, mapping the request parameters in the message content to target request parameters; Mapping the first data structure to determine a target data structure corresponding to the data structure of the request parameter in the message content; Based on the first encoding mapping relationship, determine a target encoding method corresponding to an encoding method of the request parameter in the message content; Based on the target encoding mode and the target data structure, the target request parameters are encoded to obtain target message content.
[0094] In another embodiment, the interface calling device further includes a receiving module and a second sending module; The receiving module is used to receive a first response message returned by the first interface provider; The conversion module is further configured to convert the first response message into a second response message applicable to the demand side based on the first adaptation strategy; The second sending module is used to send the second response message to the demander.
[0095] Obviously, the interface calling device 400 provided in the embodiment of the present application can be used as the above Figure 2 The execution subject of the interface calling method shown in FIG. Figure 2 Since the principle is the same, the functions realized will not be described again here.
[0096] An embodiment of the present application also provides an interface calling system, which includes a registration center, a configuration center and a gateway.
[0097] Specifically, the registration center is used to store first protocol information used by the demander and second protocol information used by at least one interface provider.
[0098] The configuration center is used to store the adaptation strategy between different protocol information.
[0099] The gateway is used to obtain the first protocol information and the second protocol information used by the first interface provider corresponding to the first interface call request from the registration center in response to receiving the first interface call request from the demander, and obtain the first adaptation strategy between the first protocol information and the second protocol information from the configuration center.
[0100] The gateway is further configured to convert the first interface call request into a second interface call request applicable to the first interface provider based on the first adaptation strategy, and send the second interface call request to the first interface provider.
[0101] Figure 5 This is a schematic diagram of a gateway structure provided by an embodiment of the present application. Figure 5 At the hardware level, the gateway includes a processor, and optionally an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the gateway may also include hardware required for other services.
[0102] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0103] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0104] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming an interface calling device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations: In response to receiving a first interface call request from a demander, acquiring from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; Acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; Based on the first adaptation strategy, converting the first interface call request into a second interface call request applicable to the first interface provider; The second interface call request is sent to the first interface provider.
[0105] The above application Figure 2 The method performed by the interface calling device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0106] The gateway can also perform Figure 2 Method, and implement the interface calling device in Figure 2 , Figure 3 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0107] Of course, in addition to software implementation, the gateway of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, but can also be hardware or logic devices.
[0108] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a gateway including multiple application programs, enable the gateway to execute Figure 2 The method of the embodiment shown is specifically used to perform the following operations: In response to receiving a first interface call request from a demander, acquiring from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; Acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; Based on the first adaptation strategy, converting the first interface call request into a second interface call request applicable to the first interface provider; The second interface call request is sent to the first interface provider.
[0109] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps in the interface calling method provided in the embodiment of the present application.
[0110] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0111] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0112] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should also be noted that the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the existence of other identical elements in the process, method, commodity or device including the element.
[0114] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.< / appointattachmentlistvo> < / appointattachmentlistvo> < / appointattachmentlistvo> < / appointattachmentlistvo>
Claims
1. An interface calling method, characterized in that: include: In response to receiving a first interface call request from a demander, acquiring from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; Acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; Based on the first adaptation strategy, converting the first interface call request into a second interface call request applicable to the first interface provider; The second interface call request is sent to the first interface provider.
2. The method according to claim 1, characterized in that: The registration center records the first registration information of the demander and the second registration information of the first interface provider, wherein the first registration information includes the protocol information corresponding to the interface that the demander can request, and the second registration information includes the protocol information corresponding to the interface provided by the first interface provider; The acquiring, from the registration center, the first protocol information used by the demander and the second protocol information used by the first interface provider corresponding to the first interface call request includes: Parsing the first interface call request to obtain an interface identifier of the first interface requested to be called by the first interface call request; Based on the interface identifier of the first interface, acquiring protocol information corresponding to the first interface from the first registration information as first protocol information used by the demander; Based on the interface identifier of the first interface, protocol information corresponding to the first interface is obtained from the second registration information as second protocol information used by the first interface provider.
3. The method according to claim 1, characterized in that The first protocol information includes a first transmission protocol and a first message content corresponding to the first transmission protocol, and the second protocol information includes a second transmission protocol and a second message content corresponding to the second transmission protocol; The first adaptation strategy includes: a first structure conversion strategy between the first transmission protocol and the second transmission protocol, and a first content conversion strategy between the first message content and the second message content; The converting, based on the first adaptation strategy, the first interface call request into a second interface call request applicable to the first interface provider comprises: Based on the first structure conversion strategy, converting the message structure of the first interface call request into a target message structure corresponding to the second transmission protocol; Based on the first content conversion strategy, converting the message content carried by the first interface call request into target message content; Based on the target message structure and the target message content, a second interface call request suitable for the first interface provider is generated.
4. The method according to claim 3, characterized in that The first content conversion strategy includes: a first parameter mapping relationship, a first data structure mapping relationship, and a first encoding mapping relationship; The converting the message content carried by the first interface call request into the target message content based on the content conversion strategy includes: Based on the first parameter mapping relationship, mapping the request parameters in the message content to target request parameters; Mapping the first data structure to determine a target data structure corresponding to the data structure of the request parameter in the message content; Based on the first encoding mapping relationship, determine a target encoding method corresponding to an encoding method of the request parameter in the message content; Based on the target encoding mode and the target data structure, the target request parameters are encoded to obtain target message content.
5. The method according to claim 1, characterized in that: After sending the second interface call request to the first interface provider, the method further includes: Receiving a first response message returned by the first interface provider; Based on the first adaptation strategy, convert the first response message into a second response message applicable to the demand side; The second response message is sent to the demander.
6. An interface calling device, characterized in that: include: A response module, configured to, in response to receiving a first interface call request from a demander, obtain from a registration center first protocol information used by the demander and second protocol information used by a first interface provider corresponding to the first interface call request; an acquisition module, configured to acquire a first adaptation strategy between the first protocol information and the second protocol information from a configuration center, wherein the configuration center stores adaptation strategies between different protocol information; a conversion module, configured to convert the first interface call request into a second interface call request applicable to the first interface provider based on the first adaptation strategy; The first sending module is used to send the second interface calling request to the first interface provider.
7. A gateway, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the interface calling method as described in any one of claims 1 to 5.
8. An interface calling system, characterized in that: include: Registration center, configuration center and gateway; The registration center is used to store first protocol information used by the demander and second protocol information used by at least one interface provider; The configuration center is used to store the adaptation strategy between different protocol information; The gateway is configured to, in response to receiving a first interface call request from the demander, obtain from the registration center the first protocol information and second protocol information used by the first interface provider corresponding to the first interface call request, and obtain from the configuration center a first adaptation strategy between the first protocol information and the second protocol information; The gateway is further configured to convert the first interface call request into a second interface call request applicable to the first interface provider based on the first adaptation strategy, and send the second interface call request to the first interface provider.
9. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the interface calling method as described in any one of claims 1 to 5.
10. A computer program product, characterized in that The computer program product includes a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps in the interface calling method according to any one of claims 1 to 5.
Citation Information
Cited By
Request processing method and device, medium and product
CN121531041A