Interface implementation method, electronic device, storage medium and program product

By automatically determining the server-side function and parameter object through the interface implementation method, the problem of low development efficiency of web-side and server-side interfaces is solved, and high efficiency and consistency of cross-language interface calls are achieved.

CN120909575BActive Publication Date: 2026-01-23INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511446101.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2026-01-23
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

In existing technologies, the development efficiency of interfaces between web pages and servers is low, and code needs to be written manually to handle type compatibility issues in cross-language calls.

Method used

This provides an interface implementation method that receives a target request object, determines the target server function based on the classpath identifier and function identifier, obtains the parameter object, executes the function and encapsulates the response object, and automatically completes the request parsing and result return using standardized specifications.

Benefits of technology

It eliminates the need for manual rewriting of interface code between the web page and the server, improving interface development efficiency, reducing repetitive development work, and ensuring the reliability and consistency of cross-language interface calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909575B_ABST
    Figure CN120909575B_ABST
Patent Text Reader

Abstract

The application discloses an interface implementation method, an electronic device, a storage medium and a program product, relates to the technical field of computers, and receives a target request object sent by a target webpage end, wherein the target request object comprises a target class path identifier, a target function identifier and target parameter information; a target function corresponding to a target service end is determined according to the target class path identifier and the target function identifier, and the target function is used for implementing business logic corresponding to the target service end; a target parameter object is acquired according to the target parameter information; an execution result corresponding to the target function is determined based on the target parameter object and the target function; the execution result is encapsulated into a response object, and the response object is returned to the target webpage end. The interface development efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to an interface implementation method, an electronic device, a storage medium and a program product. BACKGROUND

[0002] The communication interface between the webpage end and the server end is interacted to complete storage resource allocation, fault diagnosis, performance optimization and the like.

[0003] In the related art, the developer needs to manually write the interface code of the webpage end corresponding to the Java interface of each server end, pass the parameters through the request and parse the response result. And the data format of the webpage end and the server end needs to be strictly matched, and the type compatibility problem in cross-language calling needs to be handled. Therefore, the efficiency of interface development is low. SUMMARY

[0004] The present application provides an interface implementation method, an electronic device, a storage medium and a program product to at least solve the problem of low efficiency of interface development in the related art.

[0005] In a first aspect, the present application provides an interface implementation method, comprising:

[0006] receiving a target request object sent by a target webpage end, the target request object comprising a target class path identifier, a target function identifier and target parameter information;

[0007] determining a target function corresponding to a target server end according to the target class path identifier and the target function identifier, the target function being used to implement the business logic corresponding to the target server end;

[0008] obtaining a target parameter object according to the target parameter information;

[0009] obtaining an execution result corresponding to the target function based on the target parameter object and the target function;

[0010] encapsulating the execution result into a response object, and returning the response object to the target webpage end.

[0011] In a second aspect, the present application further provides an interface implementation device, comprising a receiving module, a first determining module, an obtaining module, a second determining module, an encapsulating module and a sending module, wherein,

[0012] The receiving module is configured to receive a target request object sent by a target webpage end, the target request object comprising a target class path identifier, a target function identifier and target parameter information;

[0013] The first determining module is configured to determine a target function corresponding to a target service end according to the target class path identifier and the target function identifier, the target function being used to implement business logic corresponding to the target service end.

[0014] The obtaining module is configured to obtain a target parameter object according to the target parameter information.

[0015] The second determining module is configured to determine an execution result corresponding to the target function based on the target parameter object and the target function.

[0016] The packaging module is configured to package the execution result into a response object.

[0017] The sending module is configured to return the response object to the target web end.

[0018] In a third aspect, the present application further provides an electronic device, including a memory configured to store a computer program, and a processor configured to execute the computer program to implement the steps of the interface implementation method.

[0019] In a fourth aspect, the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the steps of the interface implementation method.

[0020] In a fifth aspect, the present application further provides a computer program product, including a computer program, and the computer program is executed by a processor to implement the steps of the interface implementation method.

[0021] By the interface implementation method, the electronic device, the storage medium and the program product provided in the present application, the request object sent by the target web end can be received, the request object including the target class path identifier, the target function identifier and the target parameter information; the target function corresponding to the target service end is determined according to the request object; the target parameter object is obtained according to the target parameter information; the target function is executed based on the target parameter object to obtain an execution result; the execution result is packaged into a response object, and the response object is returned to the target web end. Without manually repeatedly writing the docking code between the web end and the service end for each interface, the request analysis to the result return can be automatically completed only by relying on the standardized specification defined in advance, the repeated development workload is reduced, and the interface development efficiency is effectively improved. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0023] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application is shown in

[0024] Figure 2 A flowchart of an interface implementation method provided for an embodiment of the present application is shown in

[0025] Figure 3 A flowchart of another interface implementation method provided for an embodiment of the present application is shown in

[0026] Figure 4 A flowchart of a target request function generation method provided for an embodiment of the present application is shown in

[0027] Figure 5 A structural diagram of an interface implementation apparatus provided for an embodiment of the present application is shown in

[0028] Figure 6 A structural diagram of an electronic device provided for an embodiment of the present application is shown in DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, any other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.

[0030] It should be noted that, in the description of the present application, the terms “include”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. The terms “first”, “second” and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0031] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application is shown in Figure 1 , including a webpage end 101 and a server end 102. The webpage end 101 can run in a user browser. The server end 102 is deployed on an application server node, and is used to run interface processing logic and connect to a storage array system through an internal interface to call underlying storage resources. The interface processing logic can include receiving a webpage end request, executing a Java function, etc.

[0032] The development languages between the webpage end 101 and the server end 102 are different, and the running environments are different. For example, the development language of the webpage end 101 can be JavaScript, and the development language of the server end 102 can be Java. The webpage end 101 and the server end 102 need to interact through a communication interface to complete operations such as storage resource allocation, fault diagnosis, and performance optimization. The communication interface can be a WEB interface.

[0033] In the related art, the developer needs to manually write the interface code of the webpage end corresponding to the Java interface of each server end, pass parameters through an HTTP request, and parse the response result. The data formats of the webpage end and the server end (for example, the conversion between JSON and Java objects) need to be strictly matched, and the type compatibility problem in cross-language calling needs to be handled, which leads to low efficiency of interface development.

[0034] The interface implementation method provided by the embodiment of the application can receive a request object sent by a target webpage end, the request object including a target class path identifier, a target function identifier, and target parameter information; determine a target function corresponding to a target server end according to the request object; obtain a target parameter object according to the target parameter information; execute the target function based on the target parameter object to obtain an execution result; encapsulate the execution result into a response object, and return the response object to the target webpage end.

[0035] The above execution process does not need to manually write the docking code between the webpage end and the server end for each interface repeatedly, but can automatically complete the request analysis to the result return only by relying on the standardized specification defined in advance, reduces the repeated development workload, and effectively improves the interface development efficiency.

[0036] Figure 2 A flowchart of an interface implementation method provided by the embodiment of the application is shown. Please refer to Figure 2 The method can include the following steps.

[0037] S201, receiving a target request object sent by a target webpage end.

[0038] The target webpage end and the target server end can communicate through a unified public interaction specification (that is, a public interface). The public interaction specification can define the request format, field meaning, and communication protocol. The target webpage end and the target server end can implement the specification through specific functions respectively.

[0039] The target webpage end can encapsulate and send the target request object through a jsCommonWebAPI function, and the target server end can receive and parse the request through a javaCommonWebAPI function.

[0040] The target webpage end can call a jsCommonWebAPI function to send a target request object. The target request object can include three key fields: a target class path identifier, a target function identifier, and target parameter information.

[0041] The target class path identifier can be denoted as javaClass and is of a string type, used to indicate the complete path of a target Java class. The target Java class can include a business processing class of a target function, and the target class path identifier locates the target Java class through the complete path, providing a basis for subsequent matching of the target function.

[0042] The target function identifier can be denoted as apiName and is of a string type, used to indicate the function name of the target function to be called in the target Java class.

[0043] The target parameter information can be denoted as apiParams and is of a JSON array type, and can include a parameter list of all parameter values required for calling the target function, wherein the number and order of the parameters need to be consistent with the parameter definition of the target function to be called in the target Java class.

[0044] S202, determine a target function corresponding to the target service end according to the target class path identifier and the target function identifier.

[0045] The target function can be used to implement the business logic of the target service end, for example, the business logic can be storage resource allocation, fault diagnosis, etc.

[0046] In some possible embodiments, the target function can be determined in the following manner: at least one execution function can be determined according to the target class path identifier and the target function identifier; if the at least one execution function is one, the execution function is determined as the target function; if the at least one execution function is multiple, the target function is determined from the multiple execution functions according to the target parameter information.

[0047] The target class path identifier is the complete path of a Java class, including the package name and the class name, and has uniqueness; the target function identifier is a specific function name.

[0048] Specifically, the target class corresponding to the target class path identifier can be determined, and the target class includes multiple functions; the target function identifier is used to perform matching processing on the multiple functions, to obtain at least one execution function.

[0049] The target class path identifier can be used to accurately find the corresponding target class. All functions consistent with the target function identifier can be scanned out in the target class, that is, at least one execution function.

[0050] When there are overloaded functions in the Java function, the overloaded functions can be selected according to the target class path identifier and the target function identifier, to form multiple execution functions. The overloaded functions refer to multiple functions with the same name in the same class, but with different numbers or types of parameters.

[0051] In the present application, when the target function cannot be uniquely determined according to the target class path identifier and the target function identifier, the target function can be further accurately matched in the multiple execution functions through the target parameter information, which can improve the uniqueness and accuracy of function matching, and can also avoid the ambiguity of function call caused by function overloading.

[0052] The target parameter information can include parameter values of multiple parameters.

[0053] In some possible embodiments, the target function can also be determined by the following method: according to the target class path identifier, the target function identifier and the target parameter information, the target function is obtained from the multiple historical functions in the cache; wherein the cache further includes the heat value corresponding to each historical function, and the heat value corresponding to each historical function is greater than or equal to a preset threshold.

[0054] Specifically, the cache further includes the historical class path identifier, the historical function identifier and the historical parameter information corresponding to each historical function, the target class path identifier, the target function identifier and the target parameter information can be matched with the historical class path identifier, the historical function identifier and the historical parameter information corresponding to each historical function, and the matched historical function is determined as the target function.

[0055] If there is no target function corresponding to the target class path identifier, the target function identifier and the target parameter information in the multiple historical functions, another method for determining the target function mentioned above can be used.

[0056] When the heat value is less than the preset threshold, the historical function can be deleted from the cache.

[0057] When the target function not stored in the cache appears, after the target function is determined, the target function and the target class path identifier, the target function identifier and the target parameter information corresponding to the target function can be directly stored in the cache, and the heat value thereof can be set to an initial threshold value greater than the preset threshold value.

[0058] After the target function is determined each time, the heat values of the historical functions can be updated: if there is a historical function determined as the target function, the heat value of the historical function can be increased; for other historical functions not selected, the heat value thereof can be reduced if the historical function has not been selected for a preset period.

[0059] The setting of the initial threshold value needs to be combined with the preset threshold value and the service scenario (for example, the initial threshold value of the high-frequency service scenario can be 1.5 times the preset threshold value, and the initial threshold value of the low-frequency scenario can be 1.1 times the preset threshold value), which can balance the cache utilization rate and the high-frequency function retention rate.

[0060] In the present application, the historical function can be stored in the cache, and the target function does not need to be determined according to the target class path identifier and the target function identifier, which can improve the efficiency of obtaining the target function, and further improve the efficiency of obtaining the response object.

[0061] S203, obtaining a target parameter object according to the target parameter information.

[0062] The target parameter object is a Java object collection that can be directly used when the target function is executed on the target server, and the target parameter object includes at least one parameter required by the target function, wherein the type and value of each parameter need to meet the parameter definition of the target function.

[0063] In some possible embodiments, the target parameter format and the parameter type corresponding to the target function can be obtained; the parameters in the target parameter information are converted and processed according to the target parameter format and the parameter type, to obtain the target parameter object.

[0064] The target parameter format can indicate the parameter structure requirement of the target function, including the number and order of parameters. For example, the parameter format of the target function createVolume(String name, int capacity) is "2 parameters, in order, string type and integer type.

[0065] The parameter type can be used to indicate the specific Java type of each parameter of the target function, which is usually obtained by reflecting the getType() method of the target function Parameter array. For example, the Java type can be java.lang.String, int, and a custom class com.web.api.CreateVolumeParam.

[0066] The target parameter information is the original parameter data (usually in JSON format, which can include strings, numbers, object references, etc.) transmitted by the target web page, which needs to be converted according to the target parameter format and the parameter type.

[0067] If the target parameter information is basic type data, type conversion is performed. For example, if the string 100 transmitted by the target web page corresponds to the int type parameter of the target function, the JSON string 100 is converted to the Java int type 100.

[0068] If the target parameter information is object type data, object mapping is performed. For example, if a JSON object containing name and capacity fields is passed by the target web page, and the object corresponds to the custom CreateVolumeParam type parameter of the target function, an instance of the class specified by the parameter type is created according to the Java class path, and the field values of the JSON object are assigned to the corresponding properties of the instance.

[0069] If the target parameter information does not match the format, a parameter verification exception is triggered, the conversion process is interrupted, and an error prompt is returned. The format mismatch can be missing parameter number or incorrect field name.

[0070] All converted parameters can be assembled according to the parameter order of the target function to form a target parameter object that can be directly passed into the target function for execution. The target parameter object can usually be an Object[] array, and the array element type corresponds to the target function parameter type one by one.

[0071] In this application, the target parameter information can be converted and processed according to the parameter format and parameter type of the target function, which can ensure that the converted target parameter object fully meets the execution requirements of the target function, avoid parameter incompatibility problems caused by cross-language data format differences, and improve the accuracy of parameter transmission and the stability of target function execution.

[0072] S204, based on the target parameter object and the target function, the execution result corresponding to the target function is obtained.

[0073] The target function can be executed based on the target parameter object by the target service side to obtain the execution result.

[0074] Before executing the target function, the target service side can perform secondary verification on the target parameter object through the reflection mechanism: check whether the parameter array length is consistent with the parameter number of the target function; check whether the actual type of each parameter is compatible with the parameter type declared by the target function; if the verification fails, directly throw an IllegalArgumentException (parameter mismatch exception) to terminate the execution.

[0075] The target service side can call the target function through reflection: if the target function is a static method (static), the target service side calls Method.invoke (null, target parameter object) through reflection, where null indicates that no instance object is needed; if the target function is an instance method, the target service side uses an instance object of the class as a calling carrier to execute Method.invoke (instance object, target parameter object); if a business exception (such as insufficient resources) is thrown during function execution, the target service side captures and retains the exception information as part of the execution result.

[0076] After the target function is executed, the target server obtains the return value as the final execution result.

[0077] S205, encapsulate the execution result as a response object, and return the response object to the target web page.

[0078] In some possible embodiments, error codes, error descriptions, and return data in the execution result are extracted; the error codes, error descriptions, and return data are encapsulated to obtain a response object.

[0079] If the target function is executed normally, the return value is extracted, the error code is set to a success identifier by default, and the error description is empty; if there is an exception in the execution process, the error description is extracted from the exception object, and a corresponding error code is matched according to the exception type, and the return data is empty.

[0080] The response object can be in a preset format, for example, the response object is in a preset format of a JSON format, and includes three fixed fields: errorCode (a numerical type): 0 indicates that the execution is successful, and a non-0 value indicates an exception (different numerical values correspond to different exception types, for example, 1001 indicates a parameter error, and 2001 indicates a business logic error); message (a string type): null or an empty string when successful, and a specific error description (for example, “parameter number mismatch” or “insufficient storage space”) when an exception occurs; and data (an arbitrary type): the return value of the target function (for example, a string or a JSON object converted from a Java object) when successful, and null when an exception occurs.

[0081] The error code and the error description are related to specific applications, and therefore, the embodiments of the present application only provide an example, without limiting the specific error code and the error description.

[0082] After the target web page obtains the response object, the target web page can parse the object through a jsCommonWebAPI function, and determine the execution result according to the errorCode. For example, if the execution is successful, the data is processed, and if the execution fails, the message is displayed.

[0083] In the present application, the standardized response object format enables the web page to uniformly parse the server return result, without separately processing the success / exception scenarios for different interfaces, reduces the analysis logic development of the web page, and further improves the efficiency and consistency of interface interaction.

[0084] The interface implementation method provided by the embodiments of the present application can determine the target function corresponding to the target server according to the target class path identifier, the target function identifier and the target parameter information in the target request object, obtain a target parameter object according to the target parameter information, execute the target function based on the target parameter object, obtain an execution result, encapsulate the execution result into a response object, and return the response object to the target web page end. The interface development efficiency is improved, and the repeated development workload is reduced, without manually repeatedly writing the docking code between the web page end and the server for each interface.

[0085] Figure 3 The flowchart of another interface implementation method provided by the embodiments of the present application is shown in FIG. 3. Figure 3 The method can include the following steps.

[0086] S301, receiving a target request object sent by a target web page end.

[0087] The execution process of S301 can refer to the execution process of S201, which is not described here again.

[0088] S302, determining at least one execution function according to the target class path identifier and the target function identifier.

[0089] The execution process of S302 can refer to the execution process of S202, which is not described here again.

[0090] S303, if the at least one execution function is one, determining the execution function as the target function.

[0091] For example, it is assumed that there are three execution functions, which are execution function A, execution function B and execution function C, the number of parameters of the execution function A and the execution function B is 2, and the number of parameters of the execution function C is 3; it is assumed that the target parameter information includes three parameters, so that the execution function C can be determined as an intermediate function and can be directly used as the target function through parameter quantity screening.

[0092] S304, if the at least one execution function is multiple, determining the target function in the multiple execution functions according to the target parameter information.

[0093] Specifically, the number of parameter values of the multiple parameters in the target parameter information and the parameter types corresponding to the parameters can be determined; at least one intermediate function can be determined in the multiple execution functions according to the number of parameter values; if the at least one intermediate function is one, the intermediate function is determined as the target function; if the at least one intermediate function is multiple, the multiple parameter types corresponding to the intermediate functions are matched according to the parameter types corresponding to the parameters, a matching result is obtained, and the target function is determined based on the matching result.

[0094] For example, the parameter type can be int or String.

[0095] When the number of parameters is the same, the parameter types of each parameter will also be different. Therefore, by determining the number of parameters and the parameter types of each parameter, the corresponding objective function can be uniquely matched.

[0096] Specifically, based on the parameter types corresponding to each parameter, the first type sequence corresponding to each parameter can be determined; the second type sequence corresponding to multiple parameter types of each intermediate function can be determined; and the first type sequence can be matched with the second type sequence corresponding to each intermediate function to obtain the matching result.

[0097] The second type sequence of each intermediate function is matched with the first type sequence of the target parameter information, and the intermediate function that matches completely (i.e., the matching result) is determined as the target function.

[0098] For example, suppose there are three execution functions: function A, function B, and function C. Functions A and B have two parameters each, while function C has three parameters. If the target parameter information includes two parameters, then by filtering based on the number of parameters, functions A and B are determined to be intermediate functions. Further, suppose the first type sequence corresponding to each parameter in the target parameter information is {int, String}, and the second type sequence of function A is {int, String}, while the second type sequence of function B is {String, int}. Then, function A is matched as the target function.

[0099] In this application, when there are multiple intermediate functions, the target function can be further determined by the parameter type, which can achieve precise matching of overloaded functions, avoid call failures caused by parameter type mismatch, and improve the reliability of cross-language interface calls.

[0100] S305. Obtain the target parameter format and parameter type corresponding to the target function.

[0101] S306. Based on the target parameter format and parameter type, perform conversion processing on the parameters in the target parameter information to obtain the target parameter object.

[0102] The execution process of S305-S306 can be found in the execution process of S203, and will not be repeated here.

[0103] S307. Based on the target parameter object and the target function, obtain the execution result corresponding to the target function.

[0104] The execution process of S307 can be found in the execution process of S204, and will not be repeated here.

[0105] S308. Extract the error codes, error descriptions, and returned data from the execution results.

[0106] S309. Encapsulate the error code, error description, and return data to obtain a response object, which is in a preset format.

[0107] S310. Return the response object to the target webpage.

[0108] The execution process of S308-S310 can be found in the execution process of S205, and will not be repeated here.

[0109] The interface implementation method provided in this application addresses potential function overloading scenarios on the server side. Through preliminary parameter quantity screening and precise parameter type sequence matching, it ensures the unique identification of the target function, effectively avoiding call failures due to parameter mismatches and significantly improving the reliability of cross-language interface calls. Furthermore, by implementing standardized rules, it eliminates the need to repeatedly develop interface code for each interface, greatly reducing the workload for developers and mitigating the risks of spelling errors and format incompatibility introduced by manual coding.

[0110] On the server side, multiple interfaces can be provided to the web page, each with its corresponding function to be invoked for business logic. For any given interface, a corresponding request function can be generated. When making a request on the web page, the request object can be encapsulated in the request function and sent to the target server. The request function can then trigger the corresponding business logic. Based on the above embodiment, the following will combine... Figure 4 The execution process of the target request function provided in the embodiments of this application will be described.

[0111] Figure 4 This is a flowchart illustrating a method for generating a target request function, as provided in an embodiment of this application. Please refer to [link / reference]. Figure 4 The method may include:

[0112] S401. Obtain the interface information corresponding to the target server.

[0113] Interface information is the interface metadata provided by the server to the web page, which is used by the web page to automatically generate calling code. It includes: the target class path identifier of the class where the interface is located, the target function identifier (function name) of the interface function, and the target parameter information of the function (definition information such as the number and type of parameters).

[0114] Determining the target class path identifier can be divided into the following three cases:

[0115] Scenario 1: The interface classes are concentrated in a single package (e.g., the web.api package).

[0116] By leveraging the mapping relationship between Java package names and directory structures (converting the "." in the package name to a directory separator, such as web.api corresponding to the web / api directory), all Java classes under that directory are located; the class name is extracted by combining the characteristic that "the class name and the file name are the same", and then the package name and the class name are connected with "." (such as web.api.VolumeService), which is the target classpath identifier.

[0117] Scenario 2: The interface classes are scattered across multiple known packages.

[0118] For each package, execute the process in Case 1 to extract the target class path identifier one by one.

[0119] Scenario 3: Interface classes are stored irregularly (unknown package path).

[0120] The target classpath identifier can be directly obtained by reading the server's preset configuration file (which records the complete class paths of all interface classes).

[0121] Furthermore, the target function identifier and target parameter information can be obtained from the instance object corresponding to the target function.

[0122] For each Java class corresponding to the target classpath identifier, an instance of the class is created through reflection (or the class metadata is parsed directly; since most interface functions are public static, instantiation is not required). All public static functions (presumably external interface functions) are filtered out, and the target function identifier and target parameter information are extracted.

[0123] The target function is identified by its name (e.g., createVolume); the target parameter information is the number of parameters for each function, the parameter types (e.g., [String, int]), and the class path of the object type parameter (e.g., the class path of the custom parameter CreateVolumeParam).

[0124] In this application, interface information can be obtained by automatically parsing package paths and using configuration files as fallback, eliminating the need for manual organization of class paths and function definitions. This approach adapts to interface classes with different storage methods, ensures the completeness and accuracy of information extraction, improves the automation and efficiency of interface information acquisition, and provides a reliable data source for the subsequent automatic generation of web page code.

[0125] S402. Based on the interface information, generate the target request function corresponding to the target request object.

[0126] The target request function is a JavaScript function on the web page. It is used to encapsulate the target request object (including classpath, function name, and parameters) and send a request to the server, thereby triggering the business logic (such as storage resource allocation) corresponding to the target function on the server.

[0127] In some possible embodiments, the interface information can be standardized to obtain preset structure data, which includes interface data and object data; and a target request function can be generated based on the interface data and object data.

[0128] It can format the interface information extracted from the server to generate preset structured data containing interface data and object data.

[0129] The object data can be an `objs` array, recording the class name and classpath of all object type parameters. For example, `{"objName":"CreateVolumeParam","javaClass":"com.web.api.CreateVolume Param"}`;

[0130] The interface data can be an array of APIs, recording class names, class paths, and included function names by Java class dimension. For example, {"className":"VolumeService","classPath":"com.web.api.Volume Service","funs":["createVolume","deleteVolume"]}.

[0131] Furthermore, a preset object template and a preset interface template can be obtained; based on the preset object template, the object data is processed by format conversion to generate the web-side object corresponding to the target function; based on the preset interface template, the interface data is processed by format conversion to generate the web-side interface corresponding to the target function; the web-side object and the web-side interface are concatenated to obtain the target request function.

[0132] Generate web-side objects: Based on a preset object template (defining the basic structure of JavaScript classes), parse the object data and generate a corresponding JavaScript class for each object type parameter. The class name is the same as objName and includes a javaClass attribute (the value of which is the corresponding Java class path) to ensure that the server can correctly convert the parameter types.

[0133] Generate web interface: Based on the preset interface template (defining a unified format for function encapsulation), parse the APIs array and generate a corresponding JavaScript object for each Java class (mounted under the global variable javaAPI). The object contains a method with the same name as the Java function, and the request information (class path, function name, parameters) is uniformly encapsulated inside the method through the jsCommonWebAPI function.

[0134] Assemble the target request function: Integrate the generated web-side object (such as the CreateVolumeParam class) and the web-side interface (such as the javaAPI.VolumeService.createVolume method) to form a complete target request function. The web-side can directly create a parameter object using new CreateVolumeParam() and call javaAPI.VolumeService.createVolume(param) to send the request.

[0135] In this application, the target request function can be automatically generated through standardized data format, preset object template and preset interface template, without the need for developers to manually write the interface code between the web page and the server. This avoids problems such as misspelling of function names and mismatch of parameter formats that may occur with manual coding, and can quickly generate new web page code when the server interface is updated, which significantly improves the efficiency and consistency of interface development.

[0136] The interface implementation method provided in this application can automatically generate the request function of the web page according to the corresponding interface information of the server. This not only reduces the repetitive workload of cross-language interface development, but also reduces the risk of interface incompatibility caused by manual intervention through standardized processes. Ultimately, it improves the development efficiency and ensures the stability of the storage resource management system (or similar cross-language interactive system).

[0137] Figure 5 This is a schematic diagram of an interface implementation device provided in an embodiment of this application. Please refer to... Figure 5 The interface implementation device 500 may include a receiving module 501, a first determining module 502, a first acquiring module 503, a second determining module 504, an encapsulation module 505, and a sending module 506, wherein...

[0138] The receiving module 501 is used to receive the target request object sent by the target web page. The target request object includes the target class path identifier, the target function identifier, and the target parameter information.

[0139] The first determining module 502 is used to determine the target function corresponding to the target server based on the target class path identifier and the target function identifier. The target function is used to implement the business logic corresponding to the target server.

[0140] The first acquisition module 503 is used to acquire the target parameter object based on the target parameter information;

[0141] The second determining module 504 is used to determine the execution result corresponding to the target function based on the target parameter object and the target function;

[0142] Encapsulation module 505 is used to encapsulate the execution result into a response object;

[0143] The sending module 506 is used to return the response object to the target webpage.

[0144] In some possible embodiments, the first determining module 502 is specifically used for:

[0145] Based on the target class path identifier and the target function identifier, at least one execution function is determined;

[0146] If at least one function is executed, then the function executed is determined as the target function;

[0147] If there are multiple execution functions, the target function is determined from among the multiple execution functions based on the target parameter information.

[0148] In some possible embodiments, the first determining module 502 is specifically used for:

[0149] Determine the number of parameters with multiple parameter values ​​in the target parameter information, and the parameter type corresponding to each parameter;

[0150] Based on the number of parameters, at least one intermediate function is determined among multiple execution functions;

[0151] If at least one intermediate function exists, then the intermediate function is determined as the objective function;

[0152] If there are multiple intermediate functions, then the parameter types corresponding to each parameter are matched with the multiple parameter types corresponding to each intermediate function to obtain the matching results, and the target function is determined based on the matching results.

[0153] In some possible embodiments, the first determining module 502 is specifically used for:

[0154] Based on the parameter type corresponding to each parameter, determine the first type sequence corresponding to each parameter;

[0155] Determine the second-type sequence of multiple parameter types corresponding to each intermediate function;

[0156] The first type sequence is matched with the second type sequence corresponding to each intermediate function to obtain the matching result.

[0157] In some possible embodiments, the first determining module 502 is specifically used for:

[0158] Determine the target class corresponding to the target class path identifier, where the target class includes multiple functions;

[0159] By identifying the target function, matching is performed on multiple functions to obtain at least one executable function.

[0160] In some possible embodiments, the first acquisition module 503 is specifically used for:

[0161] Obtain the target parameter format and parameter type corresponding to the target function;

[0162] Based on the target parameter format and parameter type, the parameters in the target parameter information are converted to obtain the target parameter object.

[0163] In some possible embodiments, the encapsulation module 505 is specifically used for:

[0164] Extract the error codes, error descriptions, and returned data from the execution results;

[0165] The error code, error description, and returned data are encapsulated to obtain a response object, which is in a preset format.

[0166] In some possible embodiments, the apparatus further includes a second acquisition module and a generation module:

[0167] The second acquisition module is used to acquire the interface information corresponding to the target server.

[0168] The generation module is used to generate the target request function corresponding to the target request object based on the interface information. The target request function is used to encapsulate the target request object and send it to the target server to trigger the business logic corresponding to the target function.

[0169] In some possible embodiments, the generation module is specifically used for:

[0170] The interface information is standardized to obtain preset structure data, which includes interface data and object data.

[0171] Generate the target request function based on the interface data and object data.

[0172] In some possible embodiments, the generation module is specifically used for:

[0173] Retrieve preset object templates and preset interface templates;

[0174] Based on the preset object template, the object data is format-converted to generate the web-side object corresponding to the target function;

[0175] Based on the preset interface template, the interface data is processed for format conversion to generate the web interface corresponding to the target function;

[0176] By concatenating the webpage object and the webpage interface, the target request function is obtained.

[0177] In some possible embodiments, the second acquisition module is specifically used for:

[0178] Based on the storage data packet corresponding to the target server, determine the target class path identifier;

[0179] In the instance object corresponding to the target function, obtain the target function identifier and target parameter information.

[0180] In some possible embodiments, the second acquisition module is specifically used for:

[0181] If there is one or more stored data packets, then extract the target class path identifier from the stored data packets;

[0182] If the stored data packet is an unknown packet path, then obtain the configuration file corresponding to the target server, and obtain the target classpath identifier from the configuration file.

[0183] For a description of the features in the embodiment corresponding to the interface implementation device, please refer to the relevant description of the embodiment corresponding to the interface implementation method, which will not be repeated here.

[0184] Figure 6 This is a schematic diagram of the structure of an electronic device provided in this application. Figure 6 As shown, the electronic device 600 provided in this embodiment includes at least one processor 601 and a memory 602. Optionally, the electronic device 600 further includes a communication component 603. The processor 601, memory 602, and communication component 603 are connected via a bus.

[0185] In a specific implementation process, at least one processor 601 executes computer execution instructions stored in memory 602, causing at least one processor 601 to execute the above-described interface implementation method embodiment.

[0186] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0187] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0188] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0189] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0190] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described interface implementation method embodiments at runtime.

[0191] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0192] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described interface implementation method embodiments.

[0193] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described interface implementation method embodiments.

[0194] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0195] The foregoing has provided a detailed description of an interface implementation method provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. An interface implementation method, characterized in that, include: Receive a target request object sent by the target webpage, wherein the target request object includes a target class path identifier, a target function identifier, and target parameter information; Based on the target class path identifier and the target function identifier, the target function corresponding to the target server is determined, and the target function is used to implement the business logic corresponding to the target server. Based on the target parameter information, obtain the target parameter object; Based on the target parameter object and the target function, determine the execution result corresponding to the target function; The execution result is encapsulated into a response object, and the response object is returned to the target webpage. Based on the target class path identifier and the target function identifier, the target function corresponding to the target server is determined, including: Based on the target class path identifier and the target function identifier, at least one execution function is determined; If there is only one execution function, then the execution function is determined as the target function; If there are multiple execution functions, then the target function is determined from among the multiple execution functions based on the target parameter information; Based on the target parameter information, the target function is determined from multiple execution functions, including: Determine the number of parameters and the parameter type corresponding to each parameter in the target parameter information. Based on the number of parameters, at least one intermediate function is determined among the plurality of execution functions; If there is only one intermediate function, then the intermediate function is determined as the target function; If there are multiple intermediate functions, then according to the parameter types corresponding to each parameter, a matching process is performed with the multiple parameter types corresponding to each intermediate function to obtain a matching result, and the target function is determined based on the matching result.

2. The method according to claim 1, characterized in that, Based on the parameter types corresponding to each parameter, a matching process is performed with multiple parameter types corresponding to each intermediate function to obtain the matching results, including: Based on the parameter type corresponding to each parameter, determine the first type sequence corresponding to each parameter; Determine the second type sequence of multiple parameter types corresponding to each intermediate function; The first type sequence is matched with the second type sequence corresponding to each intermediate function to obtain the matching result.

3. The method according to claim 1, characterized in that, Based on the target class path identifier and the target function identifier, at least one execution function is determined, including: Determine the target class corresponding to the target class path identifier, wherein the target class includes multiple functions; By using the target function identifier, matching processing is performed on the plurality of functions to obtain the at least one execution function.

4. The method according to claim 1, characterized in that, Based on the target parameter information, obtain the target parameter object, including: Obtain the target parameter format and parameter type corresponding to the target function; Based on the target parameter format and parameter type, the parameters in the target parameter information are converted to obtain the target parameter object; The step of encapsulating the execution result into a response object includes: Extract the error codes, error descriptions, and return data from the execution results; The error code, the error description, and the returned data are encapsulated to obtain the response object, which is in a preset format.

5. The method according to claim 1, characterized in that, Also includes: Obtain the interface information corresponding to the target server; Based on the interface information, a target request function corresponding to the target request object is generated. The target request function is used to encapsulate the target request object and send it to the target server to trigger the business logic corresponding to the target function.

6. The method according to claim 5, characterized in that, Based on the interface information, generate the target request function corresponding to the target request object, including: The interface information is standardized to obtain preset structure data, which includes interface data and object data. The target request function is generated based on the interface data and the object data.

7. The method according to claim 6, characterized in that, Based on the interface data and the object data, the target request function is generated, including: Retrieve preset object templates and preset interface templates; Based on the preset object template, the object data is format-converted to generate the web page object corresponding to the target function; Based on the preset interface template, the interface data is processed for format conversion to generate the web interface corresponding to the target function; The target request function is obtained by concatenating the web page object and the web page interface.

8. The method according to claim 5, characterized in that, The interface information includes the target class path identifier, the target function identifier, and the target parameter information; obtaining the interface information corresponding to the target server includes: The target class path identifier is determined based on the storage data packet corresponding to the target server; In the instance object corresponding to the objective function, obtain the objective function identifier and the objective parameter information.

9. The method according to claim 8, characterized in that, Based on the stored data packet corresponding to the target server, the target class path identifier is determined, including: If there are one or more stored data packets, then the target class path identifier is extracted from the stored data packets; If the stored data packet is an unknown packet path, then obtain the configuration file corresponding to the target server, and obtain the target class path identifier in the configuration file.

10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the steps of the interface implementation method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method, apparatus and device for responding to webpage access request, and storage medium

    CN110674427A

  • Service calling method and device, electronic equipment, system and readable storage medium

    CN117931323A