CN113742008B - Interface calling method and device, electronic equipment and storage medium - Google Patents
Interface calling method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN113742008B CN113742008B CN202111068121.6A CN202111068121A CN113742008B CN 113742008 B CN113742008 B CN 113742008B CN 202111068121 A CN202111068121 A CN 202111068121A CN 113742008 B CN113742008 B CN 113742008B
- Authority
- CN
- China
- Prior art keywords
- interface
- target
- character string
- attribute information
- file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 115
- 238000012545 processing Methods 0.000 claims abstract description 31
- 238000004458 analytical method Methods 0.000 claims abstract description 7
- 238000007781 pre-processing Methods 0.000 claims description 22
- 238000005215 recombination Methods 0.000 claims 2
- 230000006798 recombination Effects 0.000 claims 2
- 230000006870 function Effects 0.000 description 14
- 235000006719 Cassia obtusifolia Nutrition 0.000 description 9
- 244000201986 Cassia tora Species 0.000 description 9
- 235000014552 Cassia tora Nutrition 0.000 description 9
- 238000011161 development Methods 0.000 description 7
- 230000003287 optical effect Effects 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 241000208340 Araliaceae Species 0.000 description 2
- 235000005035 Panax pseudoginseng ssp. pseudoginseng Nutrition 0.000 description 2
- 235000003140 Panax quinquefolius Nutrition 0.000 description 2
- 235000008434 ginseng Nutrition 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 238000010998 test method Methods 0.000 description 2
- 239000008186 active pharmaceutical agent Substances 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000004883 computer application Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses an interface calling method, an interface calling device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a target interface to be called, and analyzing the target interface to be called to obtain interface attribute information; determining reusable components corresponding to the interface attribute information; the character string to be used is obtained through the template analysis processing of the calling method; and determining a target binary file based on the reusable component and the character string to be used so as to call the target interface to be called based on the target binary file. The technical scheme of the embodiment of the invention solves the problems of higher interface calling difficulty and higher error rate in the prior art, realizes convenient calling of the interface and improves the calling performance of the interface.
Description
Technical Field
The embodiment of the invention relates to a computer application technology, in particular to an interface calling method, an interface calling device, electronic equipment and a storage medium.
Background
In the development process, in order to implement a certain function, a developer needs to call a related interface from the server. In general, after inputting parameters of an interface to be invoked, a developer needs to manually perform subsequent operations to invoke the interface, which brings great inconvenience to the developer.
At present, an API is one of interfaces frequently called by a developer in a software development stage, and in the prior art, the calling method of the interfaces needs to be known by the developer, so that the development workload is increased, and the difficulty of a beginner is higher; problems such as system performance are also easily affected if various parameters in the interface are not known.
Disclosure of Invention
The invention provides an interface calling method, an interface calling device, electronic equipment and a storage medium, so as to realize convenience calling of an interface.
In a first aspect, an embodiment of the present invention provides an interface calling method, where the method includes:
acquiring a target interface to be called, and analyzing the target interface to be called to obtain interface attribute information;
determining reusable components corresponding to the interface attribute information;
the character string to be used is obtained through the template analysis processing of the calling method;
and determining a target binary file based on the reusable component and the character string to be used so as to call the target interface to be called based on the target binary file.
In a second aspect, an embodiment of the present invention further provides an interface calling device, where the device includes:
the interface processing module to be called is used for obtaining a target interface to be called and analyzing the target interface to be called to obtain interface attribute information;
a reusable component determining module for determining a reusable component corresponding to the interface attribute information;
the calling method template processing module is used for obtaining character strings to be used through parsing the calling method template;
and the binary file determining module is used for determining a target binary file based on the reusable component and the character string to be used so as to call the target interface to be called based on the target binary file.
In a third aspect, an embodiment of the present invention further provides an electronic device, including:
one or more processors;
storage means for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the interface invoking method according to any of the embodiments of the invention.
In a fourth aspect, embodiments of the present invention also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform an interface calling method according to any of the embodiments of the present invention.
According to the invention, the interface attribute information is obtained by analyzing the target interface to be called, the interface attribute information is recombined to form the reusable component, the calling method template is analyzed to obtain the character string to be used with the replaceable parameter information, the parameter information in the character string to be used is replaced by the parameter information in the reusable component to obtain the target binary file, so that a user can call the target interface according to the binary file, the problems that a beginner has higher difficulty in calling the interface, higher error rate and the like in the prior art are solved, the convenience of calling the interface is realized, the code development amount of the calling interface is reduced, and the calling performance of the interface is improved.
Drawings
In order to more clearly illustrate the technical solution of the exemplary embodiments of the present invention, a brief description is given below of the drawings required for describing the embodiments. It is obvious that the drawings presented are only drawings of some of the embodiments of the invention to be described, and not all the drawings, and that other drawings can be made according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of an interface calling method according to an embodiment of the present invention;
fig. 2 is a flow chart of an interface calling method according to a second embodiment of the present invention;
fig. 3 is a flow chart of an interface calling method in an application scenario according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an interface calling device according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Example 1
Fig. 1 is a schematic flow chart of an interface calling method according to an embodiment of the present invention, where the method may be applied to a case of calling an interface in a development process, and the method may be performed by an interface calling device according to an embodiment of the present invention, where the device may be implemented in software and/or hardware, and the hardware may be an electronic device, for example, a mobile terminal or a PC.
As shown in fig. 1, the method in the embodiment of the invention specifically includes the following steps:
step 110, a target interface to be called is obtained, and analysis processing is carried out on the target interface to be called, so that interface attribute information is obtained.
The target interface to be called may be understood as an interface waiting to be called at the current moment, or an interface to be called by other developers. In this embodiment, the target interface to be invoked may be an API (Application Programming Interface ). The API may refer to some predefined interfaces, for example, the API may include a function or an HTTP interface, which is not limited in this embodiment. APIs may be used to provide applications and developers the ability to access a set of routines based on certain software or hardware without having to access source code or understand the details of the internal operating mechanisms.
The interface attribute information may be understood to include various information about the nature of the interface and the relationship between the interfaces. Alternatively, the interface attribute information may include an in-parameter, an out-parameter, a method name, and the like, which is not limited in this embodiment. It should be noted that, the parameter information input by the developer when the target interface to be called is called may be used to indicate to the server what interface needs to be called. The parameter outputting can refer to data information fed back to a developer after the target interface to be called is called according to a calling method based on the parameter inputting. Taking JAVA as an example, an in parameter may refer to a request parameter and an out parameter may refer to a return parameter. The method name may refer to a method name obtained by a method for solving something or realizing a function following a naming rule.
Specifically, after the client acquires the target interface to be invoked, before implementing subsequent operations on the target interface to be invoked, the client needs to analyze the target interface to obtain interface attribute information corresponding to the target interface to be invoked. The interface attribute information is generally in the form of Key-Value Key pairs. However, the interface attribute information obtained by parsing at this time only includes the Key in the Key-Value Key pair, and does not include the Value, which may be determined according to the parameters input when a certain interface is required to be called later.
Step 120, determining reusable components corresponding to the interface attribute information.
Where reusable components are understood to be new software that can be composed with or without local modifications to the past components. In this embodiment, the reusable component may be a JavaBean. Among them, a JAVA bean is a reusable component written in the JAVA language. The user may use javabeans to package functions, processes, values, database accesses, and any other objects that may be created in JAVA code, and other developers may use these objects through internal JSP pages, servlets, other JavaBean, applet programs, or applications. The user can think that the JavaBean provides a copy and paste function anytime and anywhere without concern for any changes.
Specifically, after the interface attribute information of the target interface to be called is obtained through analysis, the server can recombine according to part of information in the interface attribute information, and a reusable component is automatically generated. Wherein the reusable component contains certain interface attribute information corresponding to the target interface to be invoked.
And 130, obtaining the character string to be used through parsing the calling method template.
A calling method is understood to be a set of statements or code that completes a function of calling a certain interface. The calling method template can refer to a preset template corresponding to attribute information in each calling method, and can also be understood as a test method which replaces specific input parameters with form parameters and is written based on the form parameters. The form parameter may also be referred to as a virtual parameter, which is a parameter used in defining a method name and a method body in a test method, and the function thereof may be a specific parameter for receiving input when the method is called. It should be noted that, the language used to call the method template may be a general-purpose programming language, and the general-purpose programming language may be an Objective-C, java, python or C language.
Wherein a string may refer to a string of characters consisting of numbers, letters, and underlines. In this embodiment, the character string to be used may be understood as a string of characters that is obtained after the parsing process of the calling method template and can be replaced by parameter information. Various parameter information in the character string can be replaced according to different calling interfaces. The character string may be json, or other formats, which is not limited in this embodiment
Specifically, after the server analyzes the predefined calling method template, a string of characters capable of replacing the parameter information therein can be obtained, so that the server can replace the parameter information in the character string according to different target interfaces to be called by the developer.
Step 140, determining a target binary file based on the reusable component and the character string to be used.
The target binary file may be understood as a code file which is obtained during the running process of the current project and can realize a specific function. Binary files may refer to files containing data or instructions written in ASCII and extended ASCII characters. Binary files are files that encode values, and their functions may include saving storage space, ease of storage, and for some relatively accurate data, the use of binary files to store does not result in loss of significant bits, etc.
Specifically, after obtaining a reusable component containing interface attribute information and a character string to be used obtained by parsing according to a calling method template, parameter information in the character string to be used is replaced by interface attribute information such as an input parameter, an output parameter, a method name and the like in the reusable component to form new file information, and the new file information is stored in a corresponding position in a form of a machine-recognizable binary file, so that a developer can call a target interface to be called based on the binary file.
According to the embodiment of the invention, the interface attribute information is obtained by analyzing the target interface to be called, the interface attribute information is recombined to form the reusable component, the calling method template is analyzed to obtain the character string to be used with the replaceable parameter information, the parameter information in the character string to be used is replaced by the parameter information in the reusable component to obtain the target binary file, so that a user can call the target interface according to the binary file, the problems that a beginner has higher difficulty in calling the interface, higher error rate and the like in the prior art are solved, the convenience of calling the interface is realized, the code development amount of the calling interface is reduced, and the calling performance of the interface is improved.
Example two
Fig. 2 is a flow chart of an interface calling method according to a second embodiment of the present invention. Based on the technical scheme, the technical scheme is further refined in the embodiment. The embodiment, on the basis of any optional technical solution of the embodiments of the present invention, optionally after determining a reusable component corresponding to the interface attribute information, further includes: and calling an encryption key corresponding to the target interface to be called from a database, and carrying out encryption processing on the interface attribute information based on a preset encryption tool and the encryption key to obtain an encrypted file.
On the basis of any optional technical scheme in the embodiment of the present invention, optionally, after the obtaining the target interface to be invoked, and analyzing the target interface to be invoked, the method further includes: and generating a preprocessing type file based on the interface attribute information so as to write information corresponding to the reusable component and character strings to be used in the preprocessing type file to obtain the target binary file.
Wherein, the technical terms identical to or corresponding to the above embodiments are not repeated herein. As shown in fig. 2, the method of this embodiment specifically includes the following steps:
step 210, obtaining the target interface to be called, and analyzing to obtain interface information corresponding to the target interface to be called, and obtaining the input parameter, the output parameter and the method name in the interface attribute information.
And 220, generating a preprocessing type file based on the interface attribute information.
The preprocessing class file may be understood as a class file containing preprocessing commands. A preprocessing command may refer to a set of programs or code in a programming language for processing prior to compilation. Specifically, the parsed interface attribute information is combined with the source code of the operation interface attribute to form a class. It should be noted that, the class may include a member attribute and a member method, for example, the member attribute may correspond to interface attribute information, and the member method may be used to operate each attribute of the class.
It should be noted that, the preprocessed class file generated according to the interface attribute information may correspond to the target interface to be called, and the preprocessed class file obtained at this time is free of content, and may write content in the file in a subsequent operation, so as to obtain a data file required by a developer.
In this embodiment, according to the interface attribute information such as the input parameter, the output parameter, the method name and the like obtained after the analysis, a preprocessing type file containing a preprocessing command is generated in advance, so that information corresponding to the reusable component and the character string to be used is written in the preprocessing type file, and a target binary file is obtained.
Step 230, determining reusable components corresponding to the interface attribute information.
Step 240, the encryption key corresponding to the target interface to be called is called from the database, and the interface attribute information is encrypted based on the preset encryption tool and the encryption key, so as to obtain an encrypted file.
An encryption key is understood to be a set of codes that are used by both the sender and receiver of data to encrypt and decrypt plaintext using the same or a symmetric key. The encryption key may typically be a string of characters and may be replaced as often as necessary.
It should be noted that, the encryption keys corresponding to each interface to be invoked are different, and before the application of the encryption keys to encrypt the interface attribute information, the encryption keys corresponding to the target interface to be invoked need to be invoked from the database, so that the encryption processing on the interface attribute information can be realized.
The encryption tool may be some codes for protecting programs or data. The function of the encryption tool may be that the developer protects the developed software or the acquired data information from piracy or that the developer only expects a part of the use in order to protect his own interests. In this embodiment, the encryption tool may be an MD5 algorithm. The MD5 algorithm is a widely used cryptographic hash function that can generate a 128 bit (16 byte) hash value that can be used to ensure that the information transfer is complete and consistent.
The encrypted file may refer to a data file obtained after the interface attribute information is encrypted.
Specifically, after the parsed interface attribute information such as the input parameter, the output parameter, the method name and the like is obtained, in order to prevent the obtained information from being stolen or leaked by other developers, encryption processing is needed. Each interface has a corresponding encryption key, encryption processing is carried out on some or all of interface attribute information corresponding to the interface to be called of the target, the encryption key corresponding to the interface to be called of the target is required to be called from a database, then the MD5 algorithm is applied to combine the encryption key with the interface attribute information to obtain the encrypted interface attribute information, the encrypted interface attribute information is stored in a corresponding position, and an encryption file is generated, so that a developer can call the encrypted interface attribute information at any time, and the encrypted interface attribute information can be prevented from being stolen or revealed by other developers.
Step 250, obtaining the character string to be used through parsing the calling method template.
The calling method template can be understood as a normative template of the interface calling method. Each interface calling method can find corresponding data information in the calling method template.
Step 260, generating a target character string based on the reusable component, the character string to be used and the encrypted file; and determining the target binary file based on the target character string and the preprocessing class file.
The target character string can be understood as a character string generated in the processing process of the target interface to be called at the current moment, so that a developer can use the character string in a subsequent operation.
In the embodiment, variable information in the character string to be used is replaced based on variable information in the reusable component, so that the character string to be processed is obtained; generating a target character string based on the character string to be processed and the encrypted file;
further, adding the target character string into the pretreatment class file to obtain a class file to be treated; and compiling the class file to be processed to obtain a target binary file corresponding to the target interface to be called, so as to determine interface feedback information corresponding to the interface request based on the target binary file when receiving the interface request corresponding to the target interface to be called.
Specifically, after the interface attribute information such as the parsed input parameter, the parsed output parameter, the parsed method name and the like is obtained, and a preprocessing type file containing a preprocessing command is generated, various information in the interface attribute information is combined to generate a reusable component. Then, in order to prevent the obtained interface attribute information from being stolen or revealed by other developers, encryption processing is required to be performed on some attribute information in the interface attribute information, and an encryption tool is used for combining an encryption key with the interface attribute information to generate an encryption file so that the developers can call the encryption file at any time. It should be noted that, variable information in the character string to be used obtained after the calling method template is parsed is form parameter information, and replacement processing needs to be performed according to different calling methods. And replacing variable information in the character string analyzed by the calling method template with variable information in a reusable component corresponding to the interface attribute information to generate a character string corresponding to the target interface to be called, so that a developer can perform subsequent processing on the generated character string information. And recombining the obtained character string to be processed and the encrypted file to obtain the target character string. Further, writing the obtained target character string into the preprocessing class file to obtain a class file which can be compiled and processed by a developer. And compiling the class file to be processed to obtain the binary file corresponding to the target interface to be called. After receiving the call request corresponding to the target interface to be called, the server can feed back the target interface corresponding to the call request to the developer according to the binary file corresponding to the target interface to be called.
In this embodiment, the API is subjected to parsing to obtain interface attribute information such as an input parameter, an output parameter, a method name, and the like, and a predefined class file is generated; then, interface attribute information such as an input parameter and an output parameter is combined to generate a reusable component in a JavaBean form; encrypting the parameter entering information in the interface attribute information, and combining an encryption key with the parameter entering information by using a pre-constructed encryption tool to generate an encryption file; analyzing the method template for calling the API to obtain a character string capable of replacing variable information, so that the variable information in the character string can be replaced by the variable information in the JavaBean to generate a method character string capable of calling the API; recombining the obtained method character string with interface attribute information in the encrypted file to generate a new method character string; writing the method character string into a predefined class file to generate a method in the class; and compiling the generated class file to obtain a binary file corresponding to the calling API interface for a developer.
According to the embodiment of the invention, the interface attribute information is obtained by analyzing the target interface to be called, the interface attribute information is recombined to generate the reusable component, encryption processing is carried out on certain information in the interface attribute information, parameter information in the reusable component is used for replacing parameter information in the character string analyzed by the calling method template, the character string capable of realizing the calling of the target interface to be called is formed, the character string is written into the pre-processing type file which is generated in advance, and a binary file which can be identified by a server is formed through compiling processing, so that a developer can call the target interface based on the binary file, the problems of high interface calling difficulty and high error rate in the prior art are solved, and the technical effects of enabling the developer to easily and conveniently call the target interface, shortening the calling time and improving the interface calling performance are achieved.
Example III
In order to make the technical solution of the embodiment of the present invention further clear for those skilled in the art, a specific application scenario example is given below by taking the target interface to be called as an API.
Fig. 3 is a schematic flow chart of an interface calling method under an application scenario according to an embodiment of the present invention; as shown in fig. 3, the target to-be-called interface is an API.
The method of the embodiment of the invention can comprise the following steps:
the first step: acquiring an API;
and a second step of: analyzing the input parameter, the output parameter and the method name of the API, and generating a predefined class file;
and a third step of: recombining the parsed input ginseng and output ginseng to generate a JavaBean file;
fourth step: obtaining an encryption key from a database, and combining the parameter entering information with the encryption key by applying an MD5 algorithm to generate an encryption file;
fifth step: analyzing a method template for calling the API to generate a character string; replacing variables in the variable information in the JavaBean file to form a method character string capable of calling the API;
sixth step: and recombining the encrypted file containing the parameter entering information with a method character string capable of calling the API to generate the method character string.
Seventh step: writing the method character string into a predefined class file to form a method in a class;
eighth step: compiling the formed class file into a binary file through Javascists, and generating a jar package through JarOutputStream so that a user can realize the convenience call of the API based on the SDK.
According to the embodiment of the invention, the interface attribute information is obtained by analyzing the target interface to be called, the interface attribute information is recombined to form the reusable component, the calling method template is analyzed to obtain the character string to be used with the replaceable parameter information, the parameter information in the character string to be used is replaced by the parameter information in the reusable component to obtain the target binary file, so that a user can call the target interface according to the binary file, the problems that a beginner has higher difficulty in calling the interface, higher error rate and the like in the prior art are solved, the convenience of calling the interface is realized, the code development amount of the calling interface is reduced, and the calling performance of the interface is improved.
Example IV
Fig. 4 is a schematic structural diagram of an interface calling device according to a fourth embodiment of the present invention, where the device includes: the interface to be invoked processing module 410, the reusable component determination module 420, the invoke method template processing module 430, and the binary determination module 440.
The interface processing module to be called 410 is configured to obtain a target interface to be called, and analyze the target interface to be called to obtain interface attribute information;
a reusable component determination module 420 for determining reusable components corresponding to the interface attribute information;
the calling method template processing module 430 is configured to obtain a character string to be used by parsing the calling method template;
a binary determining module 440, configured to determine a target binary file based on the reusable component and the character string to be used, so as to invoke the target interface to be invoked based on the target binary file.
According to the embodiment of the invention, the interface attribute information is obtained by analyzing the target interface to be called, the interface attribute information is recombined to form the reusable component, the calling method template is analyzed to obtain the character string to be used with the replaceable parameter information, the parameter information in the character string to be used is replaced by the parameter information in the reusable component to obtain the target binary file, so that a user can call the target interface according to the binary file, the problems that a beginner has higher difficulty in calling the interface, higher error rate and the like in the prior art are solved, the convenience of calling the interface is realized, the code development amount of the calling interface is reduced, and the calling performance of the interface is improved.
Optionally, the interface processing module to be invoked 410 is configured to obtain the target interface to be invoked, and parse to obtain interface information corresponding to the target interface to be invoked, so as to obtain the parameter entry, parameter exit and method name in the interface attribute information.
Optionally, after determining the reusable component corresponding to the interface attribute information, the apparatus further comprises: and the interface attribute information processing module is used for calling an encryption key corresponding to the target interface to be called from a database, and encrypting the interface attribute information based on a preset encryption tool and the encryption key to obtain an encrypted file.
Optionally, after the obtaining the target interface to be invoked and analyzing the target interface to be invoked, the device further includes: and the preprocessing type file generating module is used for generating a preprocessing type file based on the interface attribute information so as to write information corresponding to the reusable component and the character string to be used in the preprocessing type file and obtain the target binary file.
Optionally, the binary file determining module 440 further includes a character string generating unit and a binary file determining unit.
The character string generating unit is used for generating a target character string based on the reusable component, the character string to be used and the encrypted file; and the binary file determining unit is used for determining the target binary file based on the target character string and the preprocessing class file.
Optionally, the character string generating unit is further configured to replace variable information in the character string to be used based on variable information in the reusable component, so as to obtain a character string to be processed; generating the target character string based on the character string to be processed and the encrypted file
Optionally, the binary file determining unit is further configured to add the target character string to the preprocessed class file to obtain a class file to be processed; and compiling the class file to be processed to obtain a target binary file corresponding to the target interface to be called, so that when an interface request corresponding to the target interface to be called is received, interface feedback information corresponding to the interface request is determined based on the target binary file.
The interface calling device provided by the embodiment of the invention can execute the interface calling method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
It should be noted that, the units and modules included in the above system are only divided according to the functional logic, but not limited to the above division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the embodiments of the present invention.
Example five
Fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention. Fig. 5 shows a block diagram of an exemplary electronic device 50 suitable for use in implementing the embodiments of the present invention. The electronic device 50 shown in fig. 5 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 5, the electronic device 50 is embodied in the form of a general purpose computing device. Components of electronic device 50 may include, but are not limited to: one or more processors or processing units 501, a system memory 502, and a bus 503 that connects the various system components (including the system memory 502 and processing units 501).
Bus 503 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 50 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device 50 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 502 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 504 and/or cache memory 505. Electronic device 50 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 506 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard disk drive"). Although not shown in fig. 5, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 503 through one or more data medium interfaces. Memory 502 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of embodiments of the invention.
A program/utility 508 having a set (at least one) of program modules 507 may be stored, for example, in memory 502, such program modules 507 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 507 typically perform the functions and/or methods of the described embodiments of the invention.
The electronic device 50 may also communicate with one or more external devices 509 (e.g., keyboard, pointing device, display 510, etc.), one or more devices that enable a user to interact with the electronic device 50, and/or any device (e.g., network card, modem, etc.) that enables the electronic device 50 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 511. Also, the electronic device 50 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through a network adapter 512. As shown, the network adapter 512 communicates with other modules of the electronic device 50 over the bus 503. It should be appreciated that although not shown in fig. 5, other hardware and/or software modules may be used in connection with electronic device 50, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 501 executes various functional applications and data processing by running a program stored in the system memory 502, for example, implements an interface calling method provided by an embodiment of the present invention.
Example six
A sixth embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing an interface calling method, the method comprising:
acquiring a target interface to be called, and analyzing the target interface to be called to obtain interface attribute information;
determining reusable components corresponding to the interface attribute information;
the character string to be used is obtained through the template analysis processing of the calling method;
and determining a target binary file based on the reusable component and the character string to be used so as to call the target interface to be called based on the target binary file.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.
Claims (10)
1. An interface calling method, comprising:
acquiring a target interface to be called, and analyzing the target interface to be called to obtain interface attribute information;
determining reusable components corresponding to the interface attribute information, comprising: the server automatically generates the reusable component according to the recombination of partial information in the interface attribute information;
the character string to be used is obtained through the template analysis processing of the calling method; the calling method templates refer to preset templates corresponding to attribute information in each calling method; the character string to be used is a string of characters which can be used for parameter information replacement after the calling method template is analyzed;
determining a target binary file based on the reusable component and the character string to be used to invoke the target interface to be invoked based on the target binary file, comprising: after the reusable component and the character string to be used are obtained, replacing parameter information in the character string to be used with interface attribute information in the reusable component to form new file information, and storing the new file information in a corresponding position in a form of a binary file which can be identified by a machine; wherein the interface attribute information in the reusable component includes an in-parameter, an out-parameter, and a method name.
2. The method of claim 1, wherein the obtaining the target interface to be invoked and analyzing the target interface to be invoked to obtain interface attribute information includes:
and acquiring the target interface to be called, analyzing and obtaining interface attribute information corresponding to the target interface to be called, and obtaining the input parameter, the output parameter and the method name in the interface attribute information.
3. The method of claim 1, further comprising, after determining the reusable component corresponding to the interface attribute information:
and calling an encryption key corresponding to the target interface to be called from a database, and carrying out encryption processing on the interface attribute information based on a preset encryption tool and the encryption key to obtain an encrypted file.
4. The method according to claim 1, further comprising, after the obtaining the target interface to be invoked and analyzing the target interface to be invoked to obtain interface attribute information:
and generating a preprocessing type file based on the interface attribute information so as to write information corresponding to the reusable component and character strings to be used in the preprocessing type file to obtain the target binary file.
5. The method of claim 4, wherein the determining a target binary file based on the reusable component and the character string to be used comprises:
generating a target character string based on the reusable component, the character string to be used and the encrypted file;
and determining the target binary file based on the target character string and the preprocessing class file.
6. The method of claim 5, wherein generating the target string based on the reusable component, the string to be used, and the encrypted file comprises:
replacing variable information in the character string to be used based on variable information in the reusable component to obtain a character string to be processed;
and generating the target character string based on the character string to be processed and the encrypted file.
7. The method of claim 5, wherein the determining the target binary file based on the target string and the pre-processing class file comprises:
adding the target character string into the pretreatment class file to obtain a class file to be treated;
and compiling the class file to be processed to obtain a target binary file corresponding to the target interface to be called, so that when an interface request corresponding to the target interface to be called is received, interface feedback information corresponding to the interface request is determined based on the target binary file.
8. An interface calling device, comprising:
the target interface processing module to be called is used for obtaining a target interface to be called and analyzing the target interface to be called to obtain interface attribute information;
a reusable component determining module for determining a reusable component corresponding to the interface attribute information;
the reusable component determining module is specifically used for the server to automatically generate the reusable component according to the recombination of partial information in the interface attribute information;
the calling method template processing module is used for obtaining character strings to be used through parsing the calling method template; the calling method templates refer to preset templates corresponding to attribute information in each calling method; the character string to be used is a string of characters which can be used for parameter information replacement after the calling method template is analyzed;
the binary file determining module is used for determining a target binary file based on the reusable component and the character string to be used so as to call the target interface to be called based on the target binary file;
the binary file determining module is specifically configured to replace parameter information in a character string to be used with interface attribute information in the reusable component after the reusable component and the character string to be used are obtained, form new file information, and store the new file information in a corresponding position in a form of a binary file identifiable by a machine; wherein the interface attribute information in the reusable component includes an in-parameter, an out-parameter, and a method name.
9. An electronic device, the electronic device comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the interface invocation method of any of claims 1-7.
10. A storage medium containing computer executable instructions which, when executed by a computer processor, are for performing the interface call method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111068121.6A CN113742008B (en) | 2021-09-13 | 2021-09-13 | Interface calling method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111068121.6A CN113742008B (en) | 2021-09-13 | 2021-09-13 | Interface calling method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113742008A CN113742008A (en) | 2021-12-03 |
CN113742008B true CN113742008B (en) | 2024-04-02 |
Family
ID=78738279
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111068121.6A Active CN113742008B (en) | 2021-09-13 | 2021-09-13 | Interface calling method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113742008B (en) |
Citations (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6427228B1 (en) * | 1999-05-12 | 2002-07-30 | International Business Machines Corporation | Combining a meta data file and java source code to dynamically create java classes and javabeans |
CN1513145A (en) * | 2001-06-07 | 2004-07-14 | �Ҵ���˾ | System and method of mapping between software objects and structure languige element-based documents |
KR20110114754A (en) * | 2010-04-14 | 2011-10-20 | (주)앵글스톤테크놀러지 | A computer-readable recording medium that records a program that converts an EMB and WifiJava application to an Android application. |
CN108965486A (en) * | 2018-10-08 | 2018-12-07 | 深圳市创维软件有限公司 | A kind of document down loading method, system, server and storage medium |
CN109032662A (en) * | 2018-06-19 | 2018-12-18 | 上海陆家嘴国际金融资产交易市场股份有限公司 | Code file generation method, device, computer equipment and storage medium |
CN109857480A (en) * | 2018-12-27 | 2019-06-07 | 优估(上海)信息科技有限公司 | A kind of method and system of Administration API interface IP address |
CN109885347A (en) * | 2017-12-01 | 2019-06-14 | 财付通支付科技有限公司 | A kind of acquisition methods of configuration data, device and terminal, system, storage medium |
CN110309071A (en) * | 2019-06-27 | 2019-10-08 | 杭州数梦工场科技有限公司 | Test the generation method and module, test method and system of code |
CN110674625A (en) * | 2019-08-29 | 2020-01-10 | 浙江数链科技有限公司 | Code generation method and device, computer equipment and storage medium |
CN110806863A (en) * | 2019-11-05 | 2020-02-18 | 泰康保险集团股份有限公司 | Interface document generation method and device, electronic equipment and storage medium |
CN110968296A (en) * | 2019-12-03 | 2020-04-07 | 政采云有限公司 | Data acquisition method, device, equipment and readable storage medium |
CN111209005A (en) * | 2020-01-06 | 2020-05-29 | 腾讯科技(深圳)有限公司 | Method and apparatus for compiling program file, and computer-readable storage medium |
CN111338717A (en) * | 2020-03-27 | 2020-06-26 | 广州华多网络科技有限公司 | Interface calling method, application program upgrading method, server and client |
CN111459495A (en) * | 2020-03-30 | 2020-07-28 | 招商局金融科技有限公司 | Unit test code file generation method, electronic device and storage medium |
CN112181542A (en) * | 2020-09-30 | 2021-01-05 | 微医云(杭州)控股有限公司 | Function calling method and device, electronic equipment and storage medium |
CN113076153A (en) * | 2021-03-29 | 2021-07-06 | 北京京东振世信息技术有限公司 | Interface calling method and device |
CN113238740A (en) * | 2021-06-11 | 2021-08-10 | 腾讯科技(深圳)有限公司 | Code generation method, code generation device, storage medium, and electronic apparatus |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7975232B2 (en) * | 2005-10-31 | 2011-07-05 | Sap Ag | Systems and methods for extensible document generation |
US8135757B2 (en) * | 2009-06-10 | 2012-03-13 | International Business Machines Corporation | Generating references to reusable code in a schema |
US10579347B2 (en) * | 2017-11-03 | 2020-03-03 | International Business Machines Corporation | Self re-encoding interpreted application |
-
2021
- 2021-09-13 CN CN202111068121.6A patent/CN113742008B/en active Active
Patent Citations (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6427228B1 (en) * | 1999-05-12 | 2002-07-30 | International Business Machines Corporation | Combining a meta data file and java source code to dynamically create java classes and javabeans |
CN1513145A (en) * | 2001-06-07 | 2004-07-14 | �Ҵ���˾ | System and method of mapping between software objects and structure languige element-based documents |
KR20110114754A (en) * | 2010-04-14 | 2011-10-20 | (주)앵글스톤테크놀러지 | A computer-readable recording medium that records a program that converts an EMB and WifiJava application to an Android application. |
CN109885347A (en) * | 2017-12-01 | 2019-06-14 | 财付通支付科技有限公司 | A kind of acquisition methods of configuration data, device and terminal, system, storage medium |
CN109032662A (en) * | 2018-06-19 | 2018-12-18 | 上海陆家嘴国际金融资产交易市场股份有限公司 | Code file generation method, device, computer equipment and storage medium |
CN108965486A (en) * | 2018-10-08 | 2018-12-07 | 深圳市创维软件有限公司 | A kind of document down loading method, system, server and storage medium |
CN109857480A (en) * | 2018-12-27 | 2019-06-07 | 优估(上海)信息科技有限公司 | A kind of method and system of Administration API interface IP address |
CN110309071A (en) * | 2019-06-27 | 2019-10-08 | 杭州数梦工场科技有限公司 | Test the generation method and module, test method and system of code |
CN110674625A (en) * | 2019-08-29 | 2020-01-10 | 浙江数链科技有限公司 | Code generation method and device, computer equipment and storage medium |
CN110806863A (en) * | 2019-11-05 | 2020-02-18 | 泰康保险集团股份有限公司 | Interface document generation method and device, electronic equipment and storage medium |
CN110968296A (en) * | 2019-12-03 | 2020-04-07 | 政采云有限公司 | Data acquisition method, device, equipment and readable storage medium |
CN111209005A (en) * | 2020-01-06 | 2020-05-29 | 腾讯科技(深圳)有限公司 | Method and apparatus for compiling program file, and computer-readable storage medium |
CN111338717A (en) * | 2020-03-27 | 2020-06-26 | 广州华多网络科技有限公司 | Interface calling method, application program upgrading method, server and client |
CN111459495A (en) * | 2020-03-30 | 2020-07-28 | 招商局金融科技有限公司 | Unit test code file generation method, electronic device and storage medium |
CN112181542A (en) * | 2020-09-30 | 2021-01-05 | 微医云(杭州)控股有限公司 | Function calling method and device, electronic equipment and storage medium |
CN113076153A (en) * | 2021-03-29 | 2021-07-06 | 北京京东振世信息技术有限公司 | Interface calling method and device |
CN113238740A (en) * | 2021-06-11 | 2021-08-10 | 腾讯科技(深圳)有限公司 | Code generation method, code generation device, storage medium, and electronic apparatus |
Also Published As
Publication number | Publication date |
---|---|
CN113742008A (en) | 2021-12-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11120018B2 (en) | Spark query method and system supporting trusted computing | |
US10878086B2 (en) | Dynamic code extraction-based automatic anti analysis evasion and code logic analysis apparatus | |
KR101328012B1 (en) | Apparatus for tamper protection of application code and method thereof | |
US8387017B2 (en) | Black box testing optimization using information from white box testing | |
US20200349259A1 (en) | Identifying hard-coded secret vulnerability inside application source code | |
US10884838B2 (en) | Maintaining core dump privacy during application fault handling | |
CN102195773B (en) | Method and system for analyzing block cipher algorithm | |
US10380329B2 (en) | Method and apparatus for preventing application from being deciphered | |
CN111316232A (en) | Providing optimization using annotations of programs | |
CN113849781B (en) | Go language source code confusion method, system, terminal and storage medium | |
CN113254889B (en) | A code encryption method and device | |
US8930923B2 (en) | Generating debugging extension source code utilizing debugging information | |
CN111260080A (en) | Process optimization method, device, terminal and storage medium based on machine learning | |
WO2020259417A1 (en) | Data analysis method and device for block chain | |
US20140068552A1 (en) | Infrastructure for automatically generating boilerplate code using annotations and code-generators | |
CN114925338B (en) | A compilation method, device, equipment, medium and product | |
CN110457869B (en) | Program compiling and encrypting method and device, storage medium and electronic equipment | |
CN114626061B (en) | Webpage Trojan horse detection method and device, electronic equipment and medium | |
CN113742008B (en) | Interface calling method and device, electronic equipment and storage medium | |
CN118827163A (en) | Backend interface call protection method, device, electronic device and storage medium | |
CN113032741A (en) | Class file encryption method, class file operation method, device, equipment and medium | |
CN111460464B (en) | Data encryption and decryption method and device, electronic equipment and computer storage medium | |
CN111651781A (en) | Log content protection method and device, computer equipment and storage medium | |
CN117093964A (en) | Encryption method and device of source code, storage medium and electronic equipment | |
US20250036378A1 (en) | Obfuscation on exposed public api from software library |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |