Configuration Method, Device, Computer Equipment and Storage Medium for Interface Call
By developing back-end interface registration functional modules in web applications, dynamically managing and calling external interfaces, the security and convenience of cross-domain interface configuration are solved, and the secure and efficient configuration of cross-domain interfaces is achieved.
Patent Information
- Application Number
- CN202111520618.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-13
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2041-12-13
AI Technical Summary
In web applications, cross-domain interface configuration has security and convenience problems, especially the front-end cannot obtain interface parameters, resulting in the inability to perform interface authentication, and the system changes frequently, which is not conducive to the security and rapid configuration of the interface.
By developing back-end interface registration functional modules in the system, dynamic management and call of interfaces are realized. The specific steps include obtaining the feature information of the external interface, identifying the interface to write features to obtain the interface address, request parameters, authentication methods and authentication information, mapping the external interface with the general interface, and registering it to the back-end interface management library. When the current end initiates a call request through a general interface, it parses the request, obtains the target external interface information, and calls the target interface through the backend interface management library, obtains the call result and transmits it to the front end.
It realizes the secure and convenient configuration of cross-domain interfaces, breaks through the limitations of browser homologous policies, and improves the efficiency of dynamic interface management and call.
Smart Images

Figure CN114237931B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cross - domain interface configuration, and particularly to a configuration method, device, computer device and storage medium for interface call. Background Art
[0002] During the use of web applications, interfaces for different functions may come from different services, so the problem of web cross - domain needs to be solved. Cross - domain security has always been a key issue in WEB development. Currently, the SWIM process platform is used for cross - domain development of web applications. When a request is initiated from the front - end of the SWIM process platform, interface parameters cannot be obtained, so the interface cannot be authenticated. Moreover, if new resources are accessed, the system services need to be developed again, and the system changes too frequently, which is not conducive to the safe and rapid configuration of interfaces. Summary of the Invention
[0003] The main purpose of this application is to provide a configuration method, device, computer device and storage medium for interface call, aiming to solve the problems of security and convenience in cross - domain interface configuration.
[0004] To achieve the above - mentioned invention purpose, this application proposes a configuration method for interface call, including:
[0005] Obtain the external interface to be accessed and the characteristic information of the external interface;
[0006] Identify the characteristic information according to the interface writing, and obtain the address, call request parameters, authentication method and authentication information of the external interface;
[0007] Map the external interface to a general interface according to the address, call request parameters, authentication method and authentication information of the external interface, and register the external interface in the back - end interface management library in the form of the general interface;
[0008] When receiving a call request from the front - end through the general interface, parse the call request to obtain the target external interface information mapped by the call request;
[0009] Call the target interface corresponding to the target external interface information through the back - end interface management library, and obtain the call result returned by the service corresponding to the target interface;
[0010] Transmit the call result to the front - end to complete the call of the target interface.
[0011] Further, the mapping of the external interface to a general interface according to the address, call request parameters, authentication method and authentication information of the external interface includes:
[0012] Obtain the format of the general interface;
[0013] Obtain the item information of the general interface according to the format;
[0014] Identify the item information and match the item information with the characteristic information of the external interface;
[0015] Map the address, call request parameters, authentication method, and authentication information of the external interface to the matching item information.
[0016] Further, the obtaining the format of the general interface includes:
[0017] Obtain the current application scenario;
[0018] Determine the type of the general interface according to the application scenario;
[0019] Determine the format of the general interface according to the type of the general interface.
[0020] Further, after receiving the call request from the front end through the general interface, parsing the call request, and obtaining the target external interface information mapped by the call request, it further includes:
[0021] Obtain the permission of the call request;
[0022] Match the permission interface library of the back-end interface management library according to the permission;
[0023] Obtain the target interface corresponding to the target external interface information in the permission interface library.
[0024] Further, after mapping the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and registering the external interface in the form of the general interface in the back-end interface management library, it further includes:
[0025] Monitor the usage status of the service of the external interface;
[0026] If the usage status of the service is the offline status;
[0027] Block the first external interface corresponding to the service from the back-end interface management library.
[0028] Further, after blocking the first external interface corresponding to the service from the back-end interface management library, it further includes:
[0029] Obtain the second external interface associated with the first external interface;
[0030] Obtain the call hierarchy of the first external interface and the second external interface;
[0031] Screen the third external interface from the second external interface according to the call hierarchy;
[0032] Block the third external interface from the backend interface management library.
[0033] Further, after registering the external interface in the form of the general interface to the backend interface management library, it further includes:
[0034] Receive a modification instruction for the external interface;
[0035] Modify any one or more of the address, call request parameters, authentication method, and authentication information of the corresponding interface in the backend interface management library according to the modification instruction.
[0036] This application also provides a configuration device for interface calls, including:
[0037] An interface access module, configured to obtain an external interface to be accessed and the characteristic information of the external interface;
[0038] An interface parsing module, configured to identify the characteristic information according to the interface writing characteristics, and obtain the address, call request parameters, authentication method, and authentication information of the external interface;
[0039] An interface mapping module, configured to map the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and register the external interface in the form of the general interface to the backend interface management library;
[0040] A request parsing module, configured to parse the call request when receiving a call request from the front end through the general interface, and obtain the target external interface information mapped by the call request;
[0041] A result obtaining module, configured to call the target interface corresponding to the target external interface information through the backend interface management library, and obtain the call result returned by the service corresponding to the target interface;
[0042] A result transmission module, configured to transmit the call result to the front end to complete the call of the target interface.
[0043] This application also provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, it implements the steps of the interface call configuration method described in any one of the above.
[0044] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the configuration method for interface call described in any one of the above are implemented.
[0045] The present application example provides an interface configuration method for cross-domain call in a Web application. By developing a back-end interface registration function module in the system, dynamic management and call of the interface are completed. First, when a new service wants to access the system, the external interface to be accessed by the service and the characteristic information of the external interface are obtained. Then, the characteristic information is identified according to the preset interface writing, and the address, call request parameters, authentication method, and authentication information of the external interface are obtained. The external interface is connected to the back-end interface registration function module in a specified form. Specifically, the external interface is mapped to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and the external interface is registered in the back-end interface management library in the form of a general interface. When a call request from the front-end through the general interface is received, the call request is parsed to obtain the request parameters of the call request, and then the information of the external interface registered in the back-end interface management library is obtained from the request parameters, so as to obtain the target external interface information mapped by the call request. The target interface corresponding to the target external interface information is called through the back-end interface management library, that is, the back-end interface registration function module sends the call request to the target interface, calls the service corresponding to the target interface, and obtains the call result returned by the service corresponding to the target interface, and transmits the call result to the front-end to complete the cross-domain call of the front-end, break through the limitation of the browser same-origin policy, complete the cross-domain interface call in the Web application, not only improve the security of cross-domain interface call, but also improve the convenience of access to different external services and the efficiency of interface dynamic management and call. Brief Description of the Drawings
[0046] Figure 1 It is a schematic flowchart of an embodiment of the configuration method for interface call of the present application;
[0047] Figure 2 It is a schematic structural diagram of an embodiment of the configuration device for interface call of the present application;
[0048] Figure 3 It is a schematic block diagram of the structure of an embodiment of the computer device of the present application.
[0049] The realization, functional characteristics, and advantages of the purpose of the present application will be further described in conjunction with the embodiments with reference to the drawings. Detailed Embodiment
[0050] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] Referring to Figure 1 , an embodiment of the present application provides a configuration method for interface call, including steps S10 - S60, and the detailed description of each step of the configuration method for interface call is as follows.
[0052] S10. Obtain an external interface to be accessed and the characteristic information of the external interface.
[0053] This embodiment is applied to the scenario of cross - domain interface call, especially in the operation and maintenance management system. The SWIM automated process platform in the operation and maintenance management system is a system that allows users to create and edit Html forms at the front - end and associate the forms with processes. During the use of the system, for different functions of the process, the interfaces providing the functions come from different services. To complete the specified functions, different interfaces need to be called, and calling different interfaces involves cross - domain problems. The present invention develops a back - end interface registration function module in the system to complete the dynamic management and call of interfaces. Specifically, when a new service wants to access the system, the interface corresponding to the service is obtained and defined as an external interface. At the same time, the characteristic information of the external interface is obtained, and the characteristic information includes the development document information of the interface.
[0054] S20. Identify the characteristic information according to the interface writing, and obtain the address, call request parameters, authentication method and authentication information of the external interface.
[0055] In this embodiment, after obtaining the feature information of the external interface, the feature information of the external interface stores the introduction information of the scope corresponding to the call, access, and use of the interface in a specific format. In one implementation manner, the external interface writes the introduction information of the scope corresponding to the call, access, and use of the interface in the form of a standard application programming interface. In this embodiment, the feature information is identified according to the interface writing feature, and the address, call request parameters, authentication method, and authentication information of the external interface are obtained. In one implementation manner, the interface writing feature is the feature for implementing interface access in JavaScript. The call of cross-domain interfaces is widely used in Web applications. Therefore, the feature information is identified through the interface access writing feature of JavaScript, and the address, call request parameters, authentication method, and authentication information of the external interface are obtained. Among them, the interface writing feature includes implementing the interface by using the method of annotation. Therefore, the address, call request parameters, authentication method, and authentication information of the external interface are obtained by identifying the annotations in the feature information that match the address, call request parameters, authentication method, and authentication information; or the interface writing feature includes implementing the interface by using the attribute verification method. Therefore, the address, call request parameters, authentication method, and authentication information of the external interface are obtained from the declaration information of the class with attributes in the feature information by identifying the declaration information.
[0056] S30. Map the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and register the external interface in the form of the general interface to the backend interface management library.
[0057] In this embodiment, after identifying the feature information according to the preset interface feature and obtaining the address, call request parameters, authentication method, and authentication information of the external interface, it is necessary to access the external interface to the backend interface registration function module in a specified form. Specifically, the external interface is mapped to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface. Specifically, the link address of the general interface is linked to the address of the external interface, and ": call request parameters of the external interface" is added after the call request parameters of the general interface, and the authentication method and authentication information of the external interface are added to the authentication of the general interface, so as to map the external interface to the general interface and register the external interface in the form of the general interface to the backend interface management library. Among them, the general interface has a unified call method, and the general interface is the basic service interface of the operation and maintenance management system, and the services of other access systems can be found and called through the general interface.
[0058] S40. When receiving a call request from the front - end through the general interface, parse the call request to obtain the target external interface information mapped by the call request.
[0059] In this embodiment, after registering the external interfaces corresponding to the services of the access system in the form of a general interface in the back - end interface management library, a request can be initiated to the general interface by the front - end. When the front - end receives a call request through the general interface, parse the call request to obtain the request parameters of the call request, and then obtain the information of the external interfaces registered in the back - end interface management library from the request parameters, which is defined as the target external interface information, so as to obtain the target external interface information mapped by the call request.
[0060] S50. Call the target interface corresponding to the target external interface information through the back - end interface management library, and obtain the call result returned by the service corresponding to the target interface.
[0061] In this embodiment, after obtaining the target external interface information mapped by the call request, call the target interface corresponding to the target external interface information through the back - end interface management library. Specifically, obtain the call information of the target interface from the back - end interface management library, and then convert the call request of the general interface into a call request of the target interface. Specifically, replace the request content, request address, etc. in the call request with a request pointing to the target interface, and then the back - end interface registration function module sends the call request to the target interface, that is, call the service corresponding to the target request, and obtain the call result returned by the service corresponding to the target interface.
[0062] S60. Transmit the call result to the front - end to complete the call of the target interface.
[0063] In this embodiment, after calling the target interface corresponding to the target external interface information through the back - end interface management library and obtaining the call result returned by the service corresponding to the target interface, transmit the call result to the front - end to complete the cross - domain interface call of the front - end, break through the limitation of the browser same - origin policy, complete the cross - domain target interface call in the Web application, not only improve the security of cross - domain calls, but also improve the convenience of accessing different external services, and improve the efficiency of interface dynamic management and calls.
[0064] This embodiment provides an interface configuration method for cross - domain calls in a Web application. By developing a backend interface registration function module in the system, dynamic management and call of the interfaces are completed. First, when a new service wants to access the system, the external interface to be accessed by the service and the characteristic information of the external interface are obtained. Then, the characteristic information is identified according to the interface writing, and the address of the external interface, call request parameters, authentication method, and authentication information are obtained. The external interface is connected to the backend interface registration function module in a specified form. Specifically, according to the address, call request parameters, authentication method, and authentication information of the external interface, the external interface is mapped to a general interface, and the external interface is registered in the backend interface management library in the form of a general interface. When a call request from the front - end through the general interface is received, the call request is parsed to obtain the request parameters of the call request. Then, the information of the external interface registered in the backend interface management library is obtained from the request parameters, so as to obtain the target external interface information mapped by the call request. The target interface corresponding to the target external interface information is called through the backend interface management library, that is, the backend interface registration function module sends the call request to the target interface, calls the service corresponding to the target interface, and obtains the call result returned by the service corresponding to the target interface. The call result is transmitted to the front - end to complete the cross - domain call of the front - end, break through the limitation of the browser same - origin policy, complete the cross - domain interface call in the Web application, not only improve the security of cross - domain interface calls, but also improve the convenience of access to different external services, and improve the efficiency of interface dynamic management and calls.
[0065] In one embodiment, the mapping of the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface includes:
[0066] Obtain the format of the general interface;
[0067] Obtain the project information of the general interface according to the format;
[0068] Identify the project information and match the project information with the characteristic information of the external interface;
[0069] Map the address, call request parameters, authentication method, and authentication information of the external interface to the matching project information.
[0070] In this embodiment, in the process of mapping the external interface to the general interface according to the address of the external interface, the call request parameters, the authentication method, and the authentication information, and registering the external interface in the form of a general interface to the back-end interface management library, first, the format of the general interface is obtained. The formats of general interfaces under different protocols are different; according to the format, the project information of the general interface is obtained, that is, what necessary information is included in the general interface, and then the project information is identified, and the project information is matched with the characteristic information of the external interface, so as to map the address, call request parameters, authentication method, and authentication information of the external interface to the matching project information, and register the external interface in the form of a general interface to the back-end interface management library, improving the efficiency of registering the external interface to the back-end interface management library.
[0071] In one embodiment, the obtaining the format of the general interface includes:
[0072] Obtain the current application scenario;
[0073] Determine the type of the general interface according to the application scenario;
[0074] Determine the format of the general interface according to the type of the general interface.
[0075] In this embodiment, in the process of obtaining the format of the general interface, the current application scenario is obtained; the types of general interfaces used in different application scenarios are different, that is, the type of the general interface is determined according to the application scenario; then the format of the general interface is determined according to the type of the general interface, so as to configure the formats of different interfaces in different scenarios, thereby improving the accuracy of accessing interfaces of different formats to the back-end interface management library.
[0076] In one embodiment, after receiving the call request from the front end through the general interface, parsing the call request, and obtaining the target external interface information mapped by the call request, it further includes:
[0077] Obtain the permission of the call request;
[0078] Match the permission interface library of the back-end interface management library according to the permission;
[0079] Obtain the target interface corresponding to the target external interface information in the permission interface library.
[0080] In this embodiment, when a call request is received from the front end through the general interface, after parsing the call request and obtaining the target external interface information mapped by the call request, due to different permissions, different interfaces can be called, or the same service provides multiple call interfaces with different permissions. Then, the permission of the call request is obtained, and the permission interface library of the back-end interface management library is matched according to the permission. The target interface corresponding to the target external interface information is obtained in the permission interface library, and the target interface corresponding to the target external interface information is obtained in the interface library with specified permissions, so as to complete service calls with different permissions and improve the security of interface calls under different permissions.
[0081] In one embodiment, after mapping the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and registering the external interface in the form of the general interface in the back-end interface management library, it further includes:
[0082] Monitoring the usage status of the service of the external interface;
[0083] If the usage status of the service is the offline status;
[0084] Shielding the first external interface corresponding to the service from the back-end interface management library.
[0085] In this embodiment, after mapping the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and registering the external interface in the form of the general interface in the back-end interface management library, that is, after connecting the service of the external interface to the system, the service of the external interface can be used by calling the external interface. To facilitate service management, the usage status of the service of the external interface is monitored. For example, the usage status of different services is different at different time periods. For example, Service A is enabled and Service B is disabled from 0 to 7 o'clock, and Service A and Service B are enabled and Service C is disabled from 7 to 18 o'clock. When it is monitored that the usage status of the service is the offline status, the interface corresponding to the service is shielded from the back-end interface management library, and the shielded interface is defined as the first external interface, so that the service cannot be called through the general interface externally, reducing the number of information interactions, improving the information transfer efficiency, and also improving the convenience of interface management.
[0086] In one embodiment, after shielding the first external interface corresponding to the service from the back-end interface management library, it further includes:
[0087] Obtaining a second external interface associated with the first external interface;
[0088] Obtaining the call hierarchy between the first external interface and the second external interface;
[0089] Screen the third external interface from the second external interfaces according to the call hierarchy;
[0090] Block the third external interface from the backend interface management library.
[0091] In this embodiment, after blocking the first external interface corresponding to the service from the backend interface management library, due to the mutual call relationships among different interfaces, for example, interface A calls interface B, interface B calls interface C, interface A calls interface D, etc., then obtain the second external interfaces associated with the first external interface, and obtain the call hierarchy between the first external interface and the second external interfaces, that is, whether to call the first external interface first or the second external interface first, screen the third external interface from the second external interfaces according to the call hierarchy, screen the interfaces that call the second external interface after calling the first external interface as the third external interface, and then block the third external interface from the backend interface management library, so as to block the associated interfaces of the first external interface, reduce the number of information interactions, improve the information transfer efficiency, and also improve the convenience of interface management.
[0092] In one embodiment, after registering the external interface in the form of the general interface to the backend interface management library, it further includes:
[0093] Receive a modification instruction for the external interface;
[0094] Modify any one or more of the address, call request parameters, authentication method, and authentication information of the corresponding interface in the backend interface management library according to the modification instruction.
[0095] In this embodiment, after registering the external interface in the form of the general interface to the backend interface management library, the external interfaces registered in the backend interface management library can also be modified. Specifically, receive a modification instruction for the external interface, where the modification instruction includes a modification instruction for any one or more of the address, call request parameters, authentication method, and authentication information of the external interface, and then modify any one or more of the address, call request parameters, authentication method, and authentication information of the corresponding interface in the backend interface management library according to the modification instruction, so as to quickly update and modify the call characteristics of the external interface, thereby improving the maintenance efficiency of the external interface.
[0096] Refer to Figure 2 , this application also provides a configuration device for interface calls, including:
[0097] An interface access module 10, configured to obtain an external interface to be accessed and the characteristic information of the external interface;
[0098] The interface parsing module 20 is used to identify the feature information according to the interface writing features, and obtain the address, call request parameters, authentication method, and authentication information of the external interface;
[0099] The interface mapping module 30 is used to map the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and register the external interface in the form of the general interface to the backend interface management library;
[0100] The request parsing module 40 is used to parse the call request when receiving a call request from the front end through the general interface, and obtain the target external interface information mapped by the call request;
[0101] The result acquisition module 50 is used to call the target interface corresponding to the target external interface information through the backend interface management library, and obtain the call result returned by the service corresponding to the target interface;
[0102] The result transmission module 60 is used to transmit the call result to the front end to complete the call of the target interface.
[0103] As described above, it can be understood that each component of the interface call configuration device proposed in this application can implement the functions of any one of the above-mentioned interface call configuration methods.
[0104] In one embodiment, the mapping of the external interface to the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface includes:
[0105] Obtain the format of the general interface;
[0106] Obtain the project information of the general interface according to the format;
[0107] Identify the project information and match the project information with the feature information of the external interface;
[0108] Map the address, call request parameters, authentication method, and authentication information of the external interface to the matching project information.
[0109] In one embodiment, the obtaining of the format of the general interface includes:
[0110] Obtain the current application scenario;
[0111] Determine the type of the general interface according to the application scenario;
[0112] Determine the format of the general interface according to the type of the general interface.
[0113] In one embodiment, after receiving a call request from the front end through the general interface, parsing the call request, and obtaining the target external interface information mapped by the call request, it further includes:
[0114] Obtain the permission of the call request;
[0115] Match the permission interface library of the back-end interface management library according to the permission;
[0116] Obtain the target interface corresponding to the target external interface information in the permission interface library.
[0117] In one embodiment, after mapping the external interface with the general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and registering the external interface in the form of the general interface in the back-end interface management library, it further includes:
[0118] Monitor the usage status of the service of the external interface;
[0119] If the usage status of the service is the offline status;
[0120] Mask the first external interface corresponding to the service from the back-end interface management library.
[0121] In one embodiment, after masking the first external interface corresponding to the service from the back-end interface management library, it further includes:
[0122] Obtain a second external interface associated with the first external interface;
[0123] Obtain the call hierarchy between the first external interface and the second external interface;
[0124] Screen a third external interface from the second external interfaces according to the call hierarchy;
[0125] Mask the third external interface from the back-end interface management library.
[0126] In one embodiment, after registering the external interface in the form of the general interface in the back-end interface management library, it further includes:
[0127] Receive a modification instruction for the external interface;
[0128] Modify any one or more of the address, call request parameters, authentication method, and authentication information of the corresponding interface in the back-end interface management library according to the modification instruction.
[0129] Refer to Figure 3 , in the embodiments of the present application, a computer device is further provided. The computer device may be a mobile terminal, and its internal structure may be asFigure 3 As shown. The computer device includes a processor, a memory, a network interface, a display device, and an input device connected by a system bus. Among them, the network interface of the computer device is used to communicate with an external terminal through a network connection. The input device of the computer device is used to receive user input. The processor of the computer design is used to provide computing and control capabilities. The memory of the computer device includes a storage medium. The storage medium stores an operating system, a computer program, and a database. The database of the computer device is used to store data. The computer program, when executed by the processor, implements a configuration method for interface calls.
[0130] The above-mentioned processor executes the above-mentioned configuration method for interface calls, including: obtaining an external interface to be accessed and the characteristic information of the external interface; identifying the characteristic information according to the interface writing to obtain the address, call request parameters, authentication method, and authentication information of the external interface; mapping the external interface to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and registering the external interface in the form of the general interface to the backend interface management library; when receiving a call request from the front end through the general interface, parsing the call request to obtain the target external interface information mapped by the call request; calling the target interface corresponding to the target external interface information through the backend interface management library, and obtaining the call result returned by the service corresponding to the target interface; transmitting the call result to the front end to complete the call of the target interface.
[0131] The computer device provides an interface configuration method for cross - domain calls in a Web application. By developing a back - end interface registration function module in the system, dynamic management and invocation of the interface are completed. First, when a new service wants to access the system, the external interface to be accessed by the service and the characteristic information of the external interface are obtained. Then, the characteristic information is identified according to the interface writing, and the address of the external interface, call request parameters, authentication method, and authentication information are obtained. The external interface is connected to the back - end interface registration function module in a specified form. Specifically, the external interface is mapped to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and the external interface is registered in the back - end interface management library in the form of a general interface. When a call request from the front - end through the general interface is received, the call request is parsed to obtain the request parameters of the call request, and then the information of the external interface registered in the back - end interface management library is obtained from the request parameters, so as to obtain the target external interface information mapped by the call request. The target interface corresponding to the target external interface information is called through the back - end interface management library, that is, the back - end interface registration function module sends the call request to the target interface, invokes the service corresponding to the target interface, and obtains the call result returned by the service corresponding to the target interface. The call result is transmitted to the front - end to complete the cross - domain call of the front - end, break through the limitation of the browser same - origin policy, complete the cross - domain interface call in the Web application, not only improve the security of cross - domain interface calls, but also improve the convenience of access to different external services and the efficiency of interface dynamic management and invocation.
[0132] An embodiment of the present application further provides a computer - readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, an interface call configuration method is implemented, including the steps of: obtaining an external interface to be accessed and the characteristic information of the external interface; identifying the characteristic information according to the interface writing to obtain the address of the external interface, call request parameters, authentication method, and authentication information; mapping the external interface to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and registering the external interface in the back - end interface management library in the form of the general interface; when a call request from the front - end through the general interface is received, parsing the call request to obtain the target external interface information mapped by the call request; calling the target interface corresponding to the target external interface information through the back - end interface management library, and obtaining the call result returned by the service corresponding to the target interface; transmitting the call result to the front - end to complete the call of the target interface.
[0133] The computer-readable storage medium provides an interface configuration method for implementing cross-domain calls in a Web application. By developing a backend interface registration function module in the system, dynamic management and invocation of the interfaces are completed. First, when a new service wants to access the system, the external interface to be accessed by the service and the characteristic information of the external interface are obtained. Then, the characteristic information is identified according to the interface writing, and the address of the external interface, the call request parameters, the authentication method, and the authentication information are obtained. The external interface is connected to the backend interface registration function module in a specified form. Specifically, the external interface is mapped to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and the external interface is registered in the backend interface management library in the form of a general interface. When a call request from the frontend through the general interface is received, the call request is parsed to obtain the request parameters of the call request. Then, the information of the external interface registered in the backend interface management library is obtained from the request parameters, so as to obtain the target external interface information mapped by the call request. The target interface corresponding to the target external interface information is called through the backend interface management library, that is, the backend interface registration function module sends the call request to the target interface, invokes the service corresponding to the target interface, and obtains the call result returned by the service corresponding to the target interface. The call result is transmitted to the frontend to complete the cross-domain call of the frontend, break through the limitation of the browser same-origin policy, and complete the cross-domain interface call in the Web application, which not only improves the security of the cross-domain interface call, but also improves the convenience of access to different external services and the efficiency of interface dynamic management and invocation.
[0134] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods.
[0135] Any reference to a memory, storage, database, or other medium provided in this application and used in the embodiments can include non-volatile and / or volatile memories.
[0136] Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), among others.
[0137] It should be noted that, in this context, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, apparatus, article or method comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article or method. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, apparatus, article or method comprising such element.
[0138] The above are only the preferred embodiments of the present application and do not limit the patent scope of the present application.
[0139] Any equivalent structural or equivalent process transformation made by using the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall similarly be included within the patent protection scope of the present application.
Claims
1. A configuration method for interface calls, characterized in that, Including: Obtain an external interface to be accessed and characteristic information of the external interface; Identify the characteristic information according to the interface writing, and obtain the address, call request parameters, authentication method and authentication information of the external interface; Map the external interface to a general interface according to the address, call request parameters, authentication method and authentication information of the external interface, and register the external interface in the form of the general interface to a back-end interface management library; When receiving a call request from the front end through the general interface, parse the call request to obtain target external interface information mapped by the call request; Call a target interface corresponding to the target external interface information through the back-end interface management library, and obtain a call result returned by a service corresponding to the target interface; Transmit the call result to the front end to complete the call of the target interface; Among them, the mapping of the external interface to the general interface according to the address, call request parameters, authentication method and authentication information of the external interface includes: Obtain the format of the general interface; Obtain project information of the general interface according to the format; Identify the project information and match the project information with the characteristic information of the external interface; Map the address, call request parameters, authentication method and authentication information of the external interface into the matched project information; Among them, after the mapping of the external interface to the general interface according to the address, call request parameters, authentication method and authentication information of the external interface, and registering the external interface in the form of the general interface to the back-end interface management library, it further includes: Monitor the usage status of the service of the external interface; If the usage status of the service is an offline status; Block a first external interface corresponding to the service from the back-end interface management library; Among them, after blocking the first external interface corresponding to the service from the back-end interface management library, it further includes: Obtain a second external interface associated with the first external interface; Obtain a call hierarchy between the first external interface and the second external interface; Screen a third external interface from the second external interfaces according to the call hierarchy; Block the third external interface from the back-end interface management library.
2. The configuration method for interface calls according to claim 1, characterized in that, The obtaining the format of the general interface includes: Obtain the current application scenario; Determine the type of the general interface according to the application scenario; Determine the format of the general interface according to the type of the general interface.
3. The configuration method for interface calls according to claim 1, characterized in that, After the step of, when receiving a call request from the front end through the general interface, parsing the call request to obtain target external interface information mapped by the call request, it further includes: Obtain the permission of the call request; Match the permission interface library of the back-end interface management library according to the permission; Obtain a target interface corresponding to the target external interface information in the permission interface library.
4. The configuration method for interface calls according to claim 1, characterized in that, After registering the external interface in the form of the general interface to the back-end interface management library, it further includes: Receive a modification instruction for the external interface; Modify any one or more of the address, call request parameters, authentication method, and authentication information of the corresponding interface in the backend interface management library according to the modification instruction.
5. A configuration device for interface calls, characterized in that, Including: An interface access module, configured to obtain an external interface to be accessed and feature information of the external interface; An interface parsing module, configured to identify the feature information according to the interface writing features, and obtain the address, call request parameters, authentication method, and authentication information of the external interface; An interface mapping module, configured to map the external interface to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface, and register the external interface in the backend interface management library in the form of the general interface; A request parsing module, configured to parse the call request when receiving a call request from the front end through the general interface, and obtain target external interface information mapped by the call request; A result obtaining module, configured to call the target interface corresponding to the target external interface information through the backend interface management library, and obtain a call result returned by the service corresponding to the target interface; A result transmission module, configured to transmit the call result to the front end to complete the call of the target interface; Wherein, mapping the external interface to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface includes: Obtaining the format of the general interface; Obtaining project information of the general interface according to the format; Identifying the project information and matching the project information with the feature information of the external interface; Mapping the address, call request parameters, authentication method, and authentication information of the external interface to the matched project information; Wherein, after mapping the external interface to a general interface according to the address, call request parameters, authentication method, and authentication information of the external interface and registering the external interface in the backend interface management library in the form of the general interface, further including: Monitoring the usage status of the service of the external interface; If the usage status of the service is an offline status; Shielding the first external interface corresponding to the service from the backend interface management library; Wherein, after shielding the first external interface corresponding to the service from the backend interface management library, further including: Obtaining a second external interface associated with the first external interface; Obtaining the call hierarchy between the first external interface and the second external interface; Filtering a third external interface from the second external interfaces according to the call hierarchy; Shielding the third external interface from the backend interface management library.
6. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the interface call configuration method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the interface call configuration method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Method and device for converting calling interfaces
CN110704200A