CN109086147B - Service interface calling method and device of application program and storage medium - Google Patents

Service interface calling method and device of application program and storage medium Download PDF

Info

Publication number
CN109086147B
CN109086147B CN201810858538.4A CN201810858538A CN109086147B CN 109086147 B CN109086147 B CN 109086147B CN 201810858538 A CN201810858538 A CN 201810858538A CN 109086147 B CN109086147 B CN 109086147B
Authority
CN
China
Prior art keywords
application program
file
header
source code
header 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
Application number
CN201810858538.4A
Other languages
Chinese (zh)
Other versions
CN109086147A (en
Inventor
刘均
覃定鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Launch Technology Co Ltd
Original Assignee
Shenzhen Launch Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Launch Technology Co Ltd filed Critical Shenzhen Launch Technology Co Ltd
Priority to CN201810858538.4A priority Critical patent/CN109086147B/en
Publication of CN109086147A publication Critical patent/CN109086147A/en
Application granted granted Critical
Publication of CN109086147B publication Critical patent/CN109086147B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a service interface calling method and device of an application program, and the method comprises the following steps: acquiring application program self-defining identifications respectively configured for existing application programs and header file self-defining identifications respectively configured for header files correspondingly generated by the existing application programs; compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier; summarizing all header files through the header file custom identification to obtain a target header file; compiling and generating a source code file according to the target header file; and calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program. In the source code file obtained by compiling, the source code information corresponding to each service interface is configured according to the application program custom identifier, so that the source code information in each application program can be visually seen, and the readability of the source code information is improved.

Description

Service interface calling method and device of application program and storage medium
Technical Field
The present application relates to the field of software development, and in particular, to a method and an apparatus for calling a service interface of an application program, and a storage medium.
Background
In the existing software development, a single application program is difficult to complete all work, so other application programs need to be called to call required data information, and in order to meet the call of the application programs, the existing application programs provide free service interfaces for users to call, such as application programs of express inquiry, weather forecast, train schedules and the like.
In order to realize the call of the service interface in the application program, a compiling tool is generally used for compiling the service interface provided by the application program to generate a source code file, and the source code file comprises source code information of each service interface in the application program, so that a developer can realize the call of the service interface in the application program by calling the source code information corresponding to the service interface obtained by compiling in the development process of the application program. In the file obtained by compiling, the source code information corresponding to each service interface in the multiple application programs is stored in one folder, as shown in fig. 11, although the source code information corresponding to the service interface, that is, the interface function, is displayed, if a certain source code information in one application program is similar to the source code information in another application program, that is, the name of the interface function of two service interfaces is similar, it is easy to cause a programmer to input the source code information incorrectly in software development, so that the wrong calling of the service interfaces is caused, and therefore, the readability of the source code information generated by compiling still needs to be improved.
From the above, the prior art has a problem that the readability of the source code information obtained by compiling the application program is not high.
Disclosure of Invention
In order to solve the problems in the related art, the application provides a service interface calling method, a service interface calling device and a storage medium of an application program.
A service interface calling method of an application program comprises the following steps:
acquiring application program self-defining identifications respectively configured for existing application programs and header file self-defining identifications respectively configured for header files correspondingly generated by the existing application programs;
compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier;
summarizing all header files through the header file custom identifier to obtain a target header file, and declaring a service interface contained in the existing application program according to the application program custom identifier by the target header file;
compiling and generating a source code file according to the target header file, wherein the source code file comprises source code information configured for a service interface in the existing application program according to the application program custom identifier;
and calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program, wherein the source code information corresponding to the service interface in the existing application program carries the application program custom identifier corresponding to the existing application program.
A service interface calling apparatus of an application program, comprising:
an acquisition module configured to perform: acquiring application program self-defining identifications respectively configured for existing application programs and header file self-defining identifications respectively configured for header files correspondingly generated by the existing application programs;
a header file generation module configured to perform: compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier;
a target header file generation module configured to perform: summarizing all header files through the header file custom identifier to obtain a target header file, and declaring a service interface contained in the existing application program according to the application program custom identifier by the target header file;
a source code file generation module configured to perform: compiling and generating a source code file according to the target header file, wherein the source code file comprises source code information configured for a service interface in the existing application program according to the application program custom identifier;
a calling module configured to perform: and calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program, wherein the source code information corresponding to the service interface in the existing application program carries the application program custom identifier corresponding to the existing application program.
In one embodiment, the apparatus further comprises:
a variable configuration module configured to perform: configuring an application program variable and a corresponding generated header file configuration header file variable for each existing application program;
an assignment module configured to perform: and assigning the application program variable as the application program custom identifier, and assigning the header file variable as the header file custom identifier.
In one embodiment, the header file generating module includes:
a header file generation unit configured to perform: and compiling and generating a header file corresponding to each existing application program by using a header file generation command by taking the application program variable, the header file variable and the uniform resource locator of the application program description file corresponding to each existing application program as parameters, wherein the file name of the header file is the header file custom identifier.
In one embodiment, the apparatus further comprises:
a read module configured to perform: reading the application program custom identifier and the header file custom identifier corresponding to each existing application program from a specified configuration file;
a uniform resource locator reading module configured to perform: and reading the uniform resource locator of the application program description file corresponding to each existing application program from the specified configuration file, wherein the specified configuration file is used for providing a set of application program custom identifications corresponding to the existing application programs, a set of header file custom identifications and a set of the uniform resource locator.
In one embodiment, the target header file generation module includes:
a target header file generation unit configured to perform: and copying all header files to the target header file through a copying command by taking the header file custom identifications corresponding to all header files and the file names of the target header file as parameters to obtain the target header file.
In one embodiment, the source code file generation module includes:
a specifying unit configured to perform: designating an output folder for the source code file;
a source code file generation unit configured to perform: and compiling and generating the source code file by using a source code file generation command by taking the file name of the target header file, the file name of the output file folder and the path of the output file folder as parameters, wherein the source code file is positioned in the output file folder under the path.
In one embodiment, the calling module includes:
an encapsulation unit configured to perform: packaging the source code file and the standard function library file to an application program;
a calling unit configured to perform: and calling the service interface in the existing application program according to the source code information corresponding to the service interface in the existing application program, which is input in the packaged application program.
An apparatus for calling a service interface of an application, the apparatus comprising:
a processor; and
a memory having computer readable instructions stored thereon which, when executed by the processor, implement the method described above
A storage medium having stored thereon a computer program which, when executed by a processor, implements the method described above.
The technical scheme provided by the embodiment of the application can have the following beneficial effects: the method and the device have the advantages that the application program self-defining identification and the correspondingly generated header file self-defining identification are configured for the existing application program, so that the source code information corresponding to each service interface is configured according to the application program self-defining identification in the source code file generated by compiling, the source code information in each application program can be visually seen, the application program which the certain source code information belongs to can be visually seen, the readability of the source code information is improved, and a programmer can conveniently call the service interface through the source code information.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a block diagram illustrating an apparatus according to an exemplary embodiment;
FIG. 2 is a flow diagram illustrating a method for service interface invocation of an application in accordance with an illustrative embodiment;
FIG. 3 is a detailed implementation of the embodiment shown in FIG. 2 before step S110;
FIG. 4 is a flow chart illustrating a method for service interface invocation of an application in accordance with another illustrative embodiment;
FIG. 5 is a flow diagram illustrating a method for service interface invocation of an application, according to another illustrative embodiment;
FIG. 6 is a flow diagram illustrating a method for service interface invocation of an application, according to another illustrative embodiment;
FIG. 7 is an exemplary embodiment of step S170 in the embodiment shown in FIG. 2;
FIG. 8 is a flowchart of step S190 in the embodiment of FIG. 2;
FIG. 9 is a block diagram illustrating a service interface invocation mechanism for an application program in accordance with an illustrative embodiment;
FIG. 10 is a block diagram illustrating a service interface invocation mechanism for an application program in accordance with an illustrative embodiment;
FIG. 11 is a diagram illustrating a display of a calling function interface in an application program compiled and generated by the prior art;
FIG. 12 is a schematic illustration of a display of a calling function interface in an application program compiled according to the method of the present application;
FIG. 13 is a schematic diagram of a specified configuration file.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
Referring to fig. 1, fig. 1 is a block diagram illustrating an apparatus according to an example embodiment. The apparatus 100 may be used to execute the service interface calling method of the application program of the present application, and the apparatus 100 may be a desktop computer or a notebook computer, which is not further limited herein. It should be noted that this apparatus is only an example adapted to the present application and should not be considered as providing any limitation to the scope of use of the present invention. The apparatus 100 is also not to be construed as necessarily dependent on or having one or more components of the exemplary apparatus 100 shown in fig. 1.
As shown in fig. 1, the apparatus 100 includes a memory 101, a memory controller 103, one or more processors 105 (only one shown in fig. 1), a peripheral interface 107, a radio frequency module 109, a positioning module 111, a camera module 113, an audio module 115, a touch screen 117, and a key module 119. These components communicate with each other via one or more communication buses/signal lines 121.
The memory 101 may be used to store computer programs and modules, such as computer readable instructions and modules corresponding to the service interface calling method and apparatus of the application program in the exemplary embodiment of the present invention, and the processor 105 executes the computer readable instructions stored in the memory 101 to perform various functions and data processing, that is, the service interface calling method of the application program.
The memory 101, as a carrier of resource storage, may be random access memory, e.g., high speed random access memory, non-volatile memory, such as one or more magnetic storage devices, flash memory, or other solid state memory. The storage means may be a transient storage or a permanent storage.
The peripheral interface 107 may include at least one wired or wireless network interface, at least one serial-to-parallel conversion interface, at least one input/output interface, at least one USB interface, and the like, for coupling various external input/output devices to the memory 101 and the processor 105, so as to realize communication with various external input/output devices.
The rf module 109 is configured to receive and transmit electromagnetic waves, and achieve interconversion between the electromagnetic waves and electrical signals, so as to communicate with other devices through a communication network. Communication networks include cellular telephone networks, wireless local area networks, or metropolitan area networks, which may use various communication standards, protocols, and technologies.
The positioning module 111 is used to obtain the current geographic location of the apparatus 100. Examples of the positioning module 111 include, but are not limited to, a global positioning satellite system (GPS), a wireless local area network-based positioning technology, or a mobile communication network-based positioning technology.
The camera module 113 is attached to a camera and is used for taking pictures or videos. The shot pictures or videos can be stored in the memory 101 and also can be sent to an upper computer through the radio frequency module 109.
Audio module 115 provides an audio interface to a user, which may include one or more microphone interfaces, one or more speaker interfaces, and one or more headphone interfaces. And performing audio data interaction with other equipment through the audio interface. The audio data may be stored in the memory 101 and may also be transmitted through the radio frequency module 109.
The touch screen 117 provides a display interface between the device 100 and the user for displaying input operations of the user and output contents of the device. Specifically, the user may perform an input operation, such as a gesture operation, e.g., a click, a touch, a slide, etc., through the touch screen 117 to cause the apparatus 100 to respond to the input operation. The user may perform an input operation by a keyboard, a mouse, or the like connected to the peripheral interface 107 so that the apparatus 100 responds to the input or a click operation. The device 100 displays and outputs the output content formed by any one or combination of text, pictures or videos to the user through the touch screen 117.
The key module 119 includes at least one key for providing an interface for a user to input to the device 100, and the user can cause the device 100 to perform different functions by pressing different keys. For example, the power on/off button may be used by a user to turn the device 100 on or off.
It will be appreciated that the configuration shown in FIG. 1 is merely illustrative and that the apparatus 100 may include more or fewer components than shown in FIG. 1 or different components than shown in FIG. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
FIG. 2 is a flow diagram illustrating a method for service interface invocation of an application in accordance with an exemplary embodiment. As shown in fig. 2, the method for calling the service interface of the application program, which may be executed by the apparatus 100, may include the following steps:
step S110, obtaining the self-defining identification of the application program configured for the existing application program and the self-defining identification of the header file configured for the header file correspondingly generated by the existing application program.
The existing applications are platform-independent, low-coupling, self-contained, programmable-based web applications, such as applications for express queries, weather forecasts, train schedules, instant foreign exchange rate data, stock market data, and the like.
The application custom identifier is a name that is easy to recognize, memorize, and distinguish and is custom-configured for each existing application, for example, if it is necessary to compile a service interface provided by an application, such as a weather forecast, into callable source code information, the application custom identifier "weather forecast" may be configured for the application, and may be other identifiers that are easy to recognize, distinguish, and memorize.
The header file custom identifier is a header file custom configuration header file name correspondingly generated for each existing application program. As will be seen below, for each existing application, a header file is compiled. And distinguishing the header files correspondingly generated by the existing application programs through the header file custom identification.
In an exemplary embodiment, as shown in fig. 3, before step S110, the method further includes:
and step S010, configuring the application program variables and the corresponding generated header file configuration header file variables for each existing application program.
And S030, assigning the application program variable as an application program custom identifier and assigning the header file variable as a header file custom identifier.
The number of the application variables and the number of the header variables are configured according to the number of the existing applications needing to be called, for example, if two applications, namely weather forecast and express inquiry, need to be called, the two application variables and the two header variables are correspondingly configured. And assigning the application program variable to be the configured application program custom identifier according to the application program custom identifier configured for each existing application program.
The configuration of the application program variable and the header file variable is to facilitate the access of the application program custom identifier through the application program variable in the subsequent program, and the access of the header file custom identifier through the header file variable. The application variables and header variables can be configured as short, easily distinguished names as desired.
In a specific embodiment, if there are 3 existing applications, the respective configured application custom identifiers are: the self-defined identifications of the header files correspondingly and respectively configured by the Service1, the Service2 and the Service3 are as follows: generateHeader1.h, generateHeader2.h, generateHeader3. h. Correspondingly, the application variables configured for the application are: NAME1, NAME2 and NAME3, and the configured Header file variables are Header1, Header2 and Header3. Steps S010 and S030 may be implemented by the following procedure,
set NAME1=Service1
set NAME2=Service2
set NAME3=Service3
set Header1=generateHeader1.h
set Header2=generateHeader2.h
set Header3=generateHeader3.h
where set NAME1 is Service1, it indicates that a variable NAME1 is assigned, which may be used to indicate the application-specific identifier Service1 configured for the existing application I. The other NAME2, NAME3 are similar to NAME 1.
Wherein, set Header1 is generateHeader1, which indicates that a variable Header1 is assigned, and the variable is a Header custom identifier configured by a Header file correspondingly generated by an existing application I, that is, a file name of the Header file. The other headers 2, 3 are similar to Header1.
Step S130, compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier.
Wherein the header file is a carrier file containing function and data interface declaration. And the header file corresponding to each existing application program comprises the attribute of the existing application program and the service interface for calling.
In order to compile and generate a source code file of an existing application, a compilation tool is required to generate a source code file of a target data type. The compiling tool comprises a gSoap tool, a sounddk tool or a winmport tool and the like, wherein the gSoap tool and the sounddk tool automatically generate a source code file of a C/C + + data type according to the WSDL file, and the winmport tool automatically generates a source code file of a java data type according to the WSDL file.
Specifically, a header file corresponding to each existing application program is compiled and generated by using a compiling tool, and an application program description file of the existing application program is required to be used in the process of compiling and generating the header file. The application description file is a description language based on the web service, and is used for describing the web service and functions, parameters, return values and how to access the web service. The process of generating the header file is to compile an application description file of an existing application to generate a header file of a target data type.
The application description file may be a WSDL file, which is an XML-based format for application description including service interfaces available in the application for invocation and how to access the application. The WSDL file is an open source file and can be acquired according to a corresponding application program, and many common application programs have public WSDL files, for example, the WSDL file of a weather forecast application program can be acquired from a central meteorological office website, and the WSDL files corresponding to application programs such as express inquiry, a train schedule, instant foreign exchange rate data and the like can be acquired from corresponding channels. Of course, the application description file may also be accessed through the uniform resource locator of the application description file, for example, for a WSDL file of an existing application, the WSDL file may be accessed through the uniform resource locator of the WSDL file.
The compilation tools used will be different for different types of data in the source code files required and different types of application description files.
In an exemplary embodiment, a gsoap compiling tool may be used to generate a header file of an existing application, as shown in fig. 4, step S130 includes:
step S131, using the application program variable, the header file variable and the Uniform Resource Locator (URL) of the application program description file corresponding to each existing application program as parameters, and using the header file generation command to compile and generate the header file corresponding to each existing application program, wherein the file name of the header file is the header file custom identifier.
Wherein the header file generation command is a header file generation command of gsoap: wsdl2h.exe is an executable program carried by the gsoap tool and is used for generating a header file of a C/C + + data type containing the attributes and operations of an existing application program by using a WSDL file. The use rule of the header file generation command is as follows:
"wsdl2h.exe-N-o WSDL filename or URL"
Where the parameter "-N", indicates that the default "ns" is replaced with a namespace prefix;
the parameter "-o", indicates the file name of the header file to be exported, i.e. specified for export.
For the three existing applications mentioned above, the header files corresponding to the three existing applications can be generated by the following procedures:
Figure BDA0001749138920000091
after the segment program is executed, the file NAME of a Header file of the existing application program is generateHeader1.h represented by a Header1 variable, wherein 'ns' defaulted to the existing application program in the generateHeader1.h is replaced by an application program self-definition identification Service1, and correspondingly, 'ns' defaulted to other two existing application programs are also replaced by application program self-definition identifications Service2 and Service3 correspondingly.
And S150, summarizing all header files through the header file custom identifier to obtain a target header file, and declaring a service interface contained in the existing application program according to the application program custom identifier by the target header file.
As can be seen from the above, in the header file correspondingly generated by each existing application, the default "ns" identifier for the application is replaced by the corresponding application custom identifier, so after the header files are collected into the target header file, each service interface in the application includes the application custom identifier, that is, the target header file declares the service interface included in the existing application according to the application custom identifier.
In one embodiment, as shown in fig. 6, step S150 includes:
and step S151, copying all header files to the target header file through the copy command by taking the header file custom identifications corresponding to all header files and the file name of the target header file as parameters to obtain the target header file.
Wherein step S151 may be accomplished by the following procedure:
copy generateHeader1.h+generateHeader2.h+generateHeader3.h all.h
wherein copy is a self-contained DOS command of Windows, and is used for copying one or more files to another position, and after the program is executed, three header files of generateHeader1.h, generateHeader2.h and generateHeader3.h are gathered into a header file with a file name of all.h. The header file of all.h is the target header file.
Step S170, compiling and generating a source code file according to the target header file, wherein the source code file comprises source code information configured for the service interface in the existing application program according to the self-defined identification of the application program.
In an exemplary embodiment, a gsoap tool may be used to generate the header file, and accordingly, a gsoap tool may be used to generate the source code file compiled from the target header file. As shown in fig. 7, step S170 includes:
step S171, appointing an output folder for the source code file;
step S172, taking the file name of the target header file, the file name of the output folder and the path of the output folder as parameters, and compiling by using a source code file generation command to generate a source code file, wherein the source code file is positioned in the output folder under the path.
In an exemplary embodiment, the process of generating the source code file by the source code file generation command carried by the gsoap tool is as follows:
“set outputdir=output
mkdir%outputdir%
soapcpp2.exe-C-L-x-n-I D:\gsoap2.8.19\import-d%outputdir%all.h”
where set outputdir is output, it means that an assignment is given to a variable outputdir, which is used to indicate the name of the output folder.
Soapcpp2.exe is an executable program carried in the gSoap tool, namely a command for generating a source code file, and is used for generating the source code file from the obtained header file (example all.h), and the following steps are used:
soapcpp2.exe command parameter header file
In an example of this, the first and second,
command parameter option "-C", meaning that only client code is generated;
command parameter "-L", indicating that no soap clientlib.c and soap serverlib.c files are to be generated;
a command parameter "-x" indicating that an XML instance file is not to be generated;
command parameter "-n", representing the function, namespace, to rename the service using the service name;
the command parameter "-I", specifies the path of import, an example being "D: \ gsoapp 2.8.19\ import";
the command parameter "-d", specifies the path that the code generates, in the example the output folder under the current path.
After the execution is completed, in an output folder under the path "D: \ gsoap2.8.19\ import", a source code file in a C/C + + format generated according to a target header file will be included, wherein the obtained source code file includes:
soap.nsmap、soapC.cpp、soapClient.cpp、soapH.h、soapStub.h;
nsmap is a namespace definition code file; cpp is sequence and anti-sequence code files of the soap; the sopClient. cpp is a client code file; the soap H.h is a server code file; soap stub.h is the stub file for soap.
Specifically, in the soap stub.h file, that is, the stub file of the soap, the source code information of the service interface in each existing application is displayed according to the set application custom identifier, as shown in fig. 12, the application custom identifier is configured in the source code information of each service interface, so that it can be visually seen which existing application the source code information corresponding to a certain service interface belongs to, and for a specific existing application, which source code information is included for calling can be visually seen.
Step S190, calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program, wherein the source code information corresponding to the service interface in the existing application program carries the application program custom identifier corresponding to the existing application program.
One of the service interfaces corresponds to an application self-defined identifier carrying an existing application to which the service interface belongs, and source code information corresponding to the service interface to be called is added to the application in the application, so that the application can call the service interface in the application corresponding to the source code information when executing, wherein the source code information added to the application can be source code information corresponding to a plurality of service interfaces respectively (for example, a plurality of service interfaces in one application, or a plurality of service interfaces in a plurality of applications).
By the aid of the application program self-defined identification corresponding to the existing application program carried in the source code information, the service interface corresponding to the source code information can be directly and clearly known as the service interface of the application program according to the source code information, and readability of the program is improved.
In an exemplary embodiment, as shown in fig. 8, step S190 includes:
step S191, the source code file and the standard function library file are packaged to the application program.
The standard function library file is a standard function library file of a used compiling tool, and the standard function library file is different according to different used compiling tools. Taking the gsoap tool as an example, the two standard function library files stdsoap2.h and stdsoap2.cpp in the gsoap tool are packaged into the application program. Wherein the stdsoap2.h file is a header file of the standard soap protocol, and the stdsoap2.cpp file is a source file of the standard soap protocol. The encapsulation of the two standard function library files provides the bottom layer implementation of the related functions of the soap protocol, such as the bottom layer implementation of the data structures of the soap network connection, communication, XML analysis, serialization and deserialization C/C + +, and the like.
As can be seen from the above, the source code file generated by compiling includes: nsap, soundc.cpp, soundclient.cpp, soundh.h, soundclub.h. I.e. the four source code files and the standard function library file mentioned above are encapsulated into the application.
Step S192, according to the source code information corresponding to the service interface in the existing application program input in the encapsulated application program, call the service interface in the existing application program.
The source code information corresponding to the service interface in the input existing program service is input according to the requirement, namely the corresponding source code information is input by calling which service interfaces, and the source code information carries the application program self-defined identification of the existing application program to which the service interface corresponding to the source code information belongs, so that the service interface to be called can be clearly known to be the service interface in the existing application program when the application program is input and checked, and the programming efficiency is improved.
After the source code information corresponding to the service interface in the existing application program is input into the packaged application program, the application program can realize the calling of the service interface corresponding to the input source code information when being executed.
By configuring the application program custom identifier and the header file custom identifier, after the source code file of the existing application program is generated by compiling, the source code information of the service interface in the application program comprises the application program custom identifier, so that a software engineer can intuitively know which source code information in each existing application program is specifically available for calling from the obtained stub file, and for which application program the source code information corresponding to a certain service interface belongs to, the readability of the source code file is improved, and the software engineer can conveniently call the specific service interface through the source code information.
In an exemplary embodiment, as shown in fig. 5, before step S030, the method of this embodiment further includes:
step S020, reading an application program custom identifier and a header file custom identifier corresponding to each existing application program from a specified configuration file;
in this embodiment, before step S131, the method further includes:
step S210, reading the uniform resource locator of the application description file corresponding to each existing application from the designated configuration file, where the designated configuration file is used to provide a set of application custom identifiers, a set of header custom identifiers, and a set of uniform resource locators corresponding to the existing applications.
Specifically, the specific configuration file may be as shown in fig. 13, and of course, the configuration file is only an exemplary diagram adapted to the application and should not be considered as limiting the scope of application of the present application. In the specific configuration file shown in fig. 13, information of each existing application is recorded by a section represented by a middle bracket, for example, [ WebServiceInfo1] represents information of an existing application 1, and in [ WebServiceInfo1], Name Service1 represents an application-specific identifier Service1 configured for the existing application 1, Header1.h represents a Header-file-configuration Header1.h correspondingly generated for the existing application 1, and WSDL https:// ×.com/xxwsdl represents a Uniform Resource Locator (URL) of a WSDL file corresponding to the existing application.
After reading the application self-definition identifier and the header file self-definition identifier configured for each existing application from the specified configuration file, according to the configured application variables and the configured header file variables, step S030 and step S110 of the above embodiment may be executed. After the uniform resource locator of the application description file corresponding to each existing application is read from the specified configuration file, step S130 (or step S131) and the following steps are executed.
By designating the configuration file as an interactive interface with a user (such as a software engineer), the user configures the application self-definition identifier, the header file self-definition identifier and the uniform resource locator of the corresponding application description file for each existing application in the interactive interface. The service interface calling method of the application program is configured into the executable program, so that a user inputs related information (namely the application program custom identifier, the header file custom identifier and the uniform resource locator of the corresponding application program description file configured for the existing application program) in a specified configuration file, the source code file of the existing application program can be obtained by executing the configured executable program, and the source code file comprises source code information configured for the service interface in the existing application program according to the application program custom identifier.
The following is an embodiment of an apparatus of the present application, which can be used to execute embodiments of a service interface calling method of an application program described above in the present application. For details that are not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the service interface calling method of the application program of the present application.
Fig. 9 is a block diagram illustrating an apparatus for calling a service interface of an application according to an exemplary embodiment, which may be used in the apparatus 100 shown in fig. 1 to perform all or part of the steps of the method for calling a service interface of an application according to any of the embodiments. As shown in fig. 9, the service interface calling device of the application program includes but is not limited to: the system comprises an acquisition module 110, a header file generation module 130, a target header file generation module 150, a source code file generation module 170 and a calling module 190, wherein:
an acquisition module 110 configured to perform: and acquiring application program self-defining identifications respectively configured for the existing application programs and header file self-defining identifications respectively configured for header files correspondingly generated by the existing application programs.
A header file generating module 130, connected to the obtaining module 110, configured to perform: and compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier.
A target header file generating module 150, connected to the header file generating module 130, configured to perform: and summarizing all header files through the header file custom identifier to obtain a target header file, and declaring a service interface contained in the existing application program according to the application program custom identifier by the target header file.
A source code file generating module 170, connected to the target header file generating module 150, configured to perform: and compiling and generating a source code file according to the target header file, wherein the source code file comprises source code information configured for a service interface in the existing application program according to the self-defined identifier of the application program.
A calling module 190, connected to the source code file generating module 170, configured to perform: calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program, wherein the source code information corresponding to the service interface in the existing application program carries the application program custom identification corresponding to the existing application program.
In one embodiment, the service interface calling device of the application further includes:
a variable configuration module configured to perform: configuring application variables and corresponding generated header configuration header variables for each existing application.
An assignment module configured to perform: assigning the application program variable as an application program custom identifier and assigning the header file variable as a header file custom identifier.
In one embodiment, the header file generation module includes:
a header file generation unit configured to perform: and taking the application program variable, the header file variable and the uniform resource locator of the application program description file corresponding to each existing application program as parameters, and compiling by using a header file generation command to generate a header file corresponding to each existing application program, wherein the file name of the header file is a header file self-defined identifier.
In one embodiment, the service interface calling device of the application further includes:
a read module configured to perform: and reading the application program custom identifier and the header file custom identifier corresponding to each existing application program from the specified configuration file.
A uniform resource locator reading module configured to perform: and reading the uniform resource locator of the application program description file corresponding to each existing application program from the specified configuration file, wherein the specified configuration file is used for providing a set of application program self-definition identifications corresponding to the existing application programs, a set of header file self-definition identifications and a set of uniform resource locators.
In one embodiment, the target header file generation module includes:
a target header file generation unit configured to perform: and copying all header files to the target header file through a copying command by taking the header file custom identifications corresponding to all header files and the file name of the target header file as parameters to obtain the target header file.
In one embodiment, the source code file generation module includes:
a specifying unit configured to perform: an output folder is specified for the source code file.
A source code file generation unit configured to perform: and taking the file name of the target header file, the file name of the output folder and the path of the output folder as parameters, and compiling by using a source code file generation command to generate a source code file, wherein the source code file is positioned in the output folder under the path.
In one embodiment, the calling module includes:
an encapsulation unit configured to perform: and packaging the source code file and the standard function library file to the application program.
A calling unit configured to perform: and calling the service interface in the existing application program service according to the source code information corresponding to the service interface in the existing program service input in the packaged application program.
The implementation process of the function and the action of each module or unit in the device is specifically detailed in the implementation process of the corresponding step in the service interface calling method of the application program, and is not described herein again.
Each module or unit may also be a functional module, configured to execute a corresponding step in the service interface calling method of the application program. It is understood that these modules or units may be implemented in hardware, software, or a combination of both. When implemented in hardware, these modules or units may be implemented as one or more hardware modules, such as one or more application specific integrated circuits. When implemented in software, these modules or units may be implemented as one or more computer programs executing on one or more processors, such as the programs stored in memory 101 executed by processor 105 of FIG. 1.
In an exemplary embodiment, there is also provided a service interface calling apparatus of an application program, as shown in fig. 10, including:
a processor 1001; and
a memory 1002, on which computer readable instructions 1002 are stored, wherein the computer readable instructions 1002, when executed by the processor 1001, implement the service interface calling method of the application program in the embodiments described above.
The specific manner in which the processor of the apparatus performs operations in this embodiment has been described in detail in the embodiment related to the service interface calling method of the application program, and will not be described in detail here.
In an exemplary embodiment, a storage medium is further provided, on which a computer program is stored, the storage medium being a computer-readable storage medium, such as a transitory and non-transitory computer-readable storage medium, including instructions, and the computer program, when executed by a processor, implements the service interface calling method of the application program in the above-described method embodiment.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (10)

1. A service interface calling method of an application program is characterized by comprising the following steps:
acquiring application program self-defining identifications respectively configured for existing application programs and header file self-defining identifications respectively configured for header files correspondingly generated by the existing application programs;
compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier;
summarizing all header files through the header file custom identifier to obtain a target header file, and declaring a service interface contained in the existing application program according to the application program custom identifier by the target header file;
compiling and generating a source code file according to the target header file, wherein the source code file comprises source code information configured for a service interface in the existing application program according to the application program custom identifier;
and calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program, wherein the source code information corresponding to the service interface in the existing application program carries the application program custom identifier corresponding to the existing application program.
2. The method of claim 1, wherein prior to obtaining the application custom identifier configured for each existing application and the header custom identifier configured for the header corresponding to each existing application, further comprising:
configuring an application program variable and a corresponding generated header file configuration header file variable for each existing application program;
and assigning the application program variable as the application program custom identifier, and assigning the header file variable as the header file custom identifier.
3. The method of claim 2, wherein compiling the header file corresponding to each existing application according to the application custom identifier and the header file custom identifier comprises:
and compiling and generating a header file corresponding to each existing application program by using a header file generation command by taking the application program variable, the header file variable and the uniform resource locator of the application program description file corresponding to each existing application program as parameters, wherein the file name of the header file is the header file custom identifier.
4. The method of claim 3, wherein before assigning the application variable to the application custom identifier and assigning the header variable to the header custom identifier, further comprising:
reading the application program custom identifier and the header file custom identifier corresponding to each existing application program from a specified configuration file;
before the step of generating a header file corresponding to each existing application program by using header file generation command compilation with the application program variable, the header file variable, and the uniform resource locator of the application program description file corresponding to each existing application program as parameters, the method further includes:
and reading the uniform resource locator of the application program description file corresponding to each existing application program from the specified configuration file.
5. The method according to claim 1, wherein the aggregating all header files through the header file custom identifier to obtain a target header file comprises:
and copying all header files to the target header file through a copying command by taking the header file custom identifications corresponding to all header files and the file names of the target header file as parameters to obtain the target header file.
6. The method of claim 1, wherein compiling from the target header file to generate a source code file comprises:
designating an output folder for the source code file;
and compiling and generating the source code file by using a source code file generation command by taking the file name of the target header file, the file name of the output file folder and the path of the output file folder as parameters, wherein the source code file is positioned in the output file folder under the path.
7. The method according to any one of claims 1 to 6, wherein the calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program comprises:
packaging the source code file and the standard function library file to an application program;
and calling the service interface in the existing application program according to the source code information corresponding to the service interface in the existing application program, which is input in the packaged application program.
8. A service interface calling apparatus for an application program, comprising:
an acquisition module configured to perform: acquiring application program self-defining identifications respectively configured for existing application programs and header file self-defining identifications respectively configured for header files correspondingly generated by the existing application programs;
a header file generation module configured to perform: compiling and generating a header file corresponding to each existing application program according to the application program custom identifier and the header file custom identifier;
a target header file generation module configured to perform: summarizing all header files through the header file custom identifier to obtain a target header file, and declaring a service interface contained in the existing application program according to the application program custom identifier by the target header file;
a source code file generation module configured to perform: compiling and generating a source code file according to the target header file, wherein the source code file comprises source code information configured for a service interface in the existing application program according to the application program custom identifier;
a calling module configured to perform: and calling the service interface in the existing application program through the source code information corresponding to the service interface in the existing application program, wherein the source code information corresponding to the service interface in the existing application program carries the application program custom identifier corresponding to the existing application program.
9. An apparatus for calling a service interface of an application program, the apparatus comprising:
a processor; and
a memory having computer readable instructions stored thereon which, when executed by the processor, implement the method of any of claims 1 to 7.
10. A storage medium on which a computer program is stored, which computer program, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN201810858538.4A 2018-07-31 2018-07-31 Service interface calling method and device of application program and storage medium Active CN109086147B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810858538.4A CN109086147B (en) 2018-07-31 2018-07-31 Service interface calling method and device of application program and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810858538.4A CN109086147B (en) 2018-07-31 2018-07-31 Service interface calling method and device of application program and storage medium

Publications (2)

Publication Number Publication Date
CN109086147A CN109086147A (en) 2018-12-25
CN109086147B true CN109086147B (en) 2022-02-22

Family

ID=64831114

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810858538.4A Active CN109086147B (en) 2018-07-31 2018-07-31 Service interface calling method and device of application program and storage medium

Country Status (1)

Country Link
CN (1) CN109086147B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10732944B1 (en) * 2019-05-14 2020-08-04 Baidu Usa Llc Generic verification approach for Protobuf based projects
CN111985055B (en) * 2020-08-28 2023-08-08 北京世冠金洋科技发展有限公司 Model packaging method and device and electronic equipment
CN114327415B (en) * 2022-03-17 2022-05-31 武汉天喻信息产业股份有限公司 Compiling method and device for compiling java file
CN114760290B (en) * 2022-05-07 2024-04-12 北京字跳网络技术有限公司 Application development method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5790861A (en) * 1995-07-07 1998-08-04 Sun Microsystems, Inc. Method and apparatus for generating executable code from object-oriented C++ source code
CN105786498A (en) * 2016-02-25 2016-07-20 广州阿里巴巴文学信息技术有限公司 Method and device for modifying application and electronic device
CN106528171A (en) * 2016-11-24 2017-03-22 郑州云海信息技术有限公司 Method, device and system for designing interface between heterogeneous computing platforms
CN107291480A (en) * 2017-08-15 2017-10-24 中国农业银行股份有限公司 A kind of function calling method and device
CN108197440A (en) * 2017-11-28 2018-06-22 五八有限公司 A kind of Code obfuscation method, equipment and computer readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8806453B1 (en) * 2011-09-15 2014-08-12 Lockheed Martin Corporation Integrating disparate programming languages to form a new programming language

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5790861A (en) * 1995-07-07 1998-08-04 Sun Microsystems, Inc. Method and apparatus for generating executable code from object-oriented C++ source code
CN105786498A (en) * 2016-02-25 2016-07-20 广州阿里巴巴文学信息技术有限公司 Method and device for modifying application and electronic device
CN106528171A (en) * 2016-11-24 2017-03-22 郑州云海信息技术有限公司 Method, device and system for designing interface between heterogeneous computing platforms
CN107291480A (en) * 2017-08-15 2017-10-24 中国农业银行股份有限公司 A kind of function calling method and device
CN108197440A (en) * 2017-11-28 2018-06-22 五八有限公司 A kind of Code obfuscation method, equipment and computer readable storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于ObjectARX 自定义实体的冒口系统参数化设计;龙娟等;《铸造技术》;20121231;第33卷(第12期);第1412-1414页 *
自编头文件的C-MEX混合编程;汤俊等;《机械制造与自动化》;20150228;第44卷(第2期);第101-102页 *

Also Published As

Publication number Publication date
CN109086147A (en) 2018-12-25

Similar Documents

Publication Publication Date Title
CN109086147B (en) Service interface calling method and device of application program and storage medium
US11188310B2 (en) Automatically generating an interface description in an interface description language
CN106874174B (en) Method and device for realizing interface test and function test
CN107832045B (en) Method and apparatus for cross programming language interface conversion
US8005878B2 (en) Providing processing instructions for updating schema
CN109062563B (en) Method and device for generating page
CN109725901A (en) Development approach, device, equipment and the computer storage medium of front-end code
CN104731589A (en) Automatic generation method and device of user interface (UI)
CN114981775B (en) Cloud-based API metadata management method and system for integrated API management
CN101405761B (en) For service reception and the method and system processing data
CN102622237B (en) A kind of collocation method of business function procedure and system
CN108279882B (en) Framework generation method, device, equipment and computer readable medium
CN109976793A (en) A kind of operation method of application program, device, equipment and medium
CN110795181A (en) Application program interface display method and device based on skip protocol and electronic equipment
CN114510452A (en) SOC (System on chip) integration method and device and electronic equipment
CN112507005A (en) Method and device for processing message
CN113641700A (en) Data processing method and device based on Spring boot frame
CN113076294A (en) Information sharing method and device
CN110688145B (en) Android MVP code automatic generation method and device, medium and electronic equipment
CN109814915A (en) Method for parameter configuration, device, medium and electronic equipment based on lua
CN111680247B (en) Local calling method, device and equipment of webpage character strings and storage medium
CN116436936A (en) Data storage system, method, storage medium and electronic equipment
CN115981643A (en) Configuration method, system, equipment and storage medium of business association component
US11792269B2 (en) Method for generating application for controlling external electronic device and electronic apparatus for supporting the same
CN108932130B (en) Code generation method and device for realizing server function call

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