CN103235718A - Method and device for generating remote procedure call (RPC) code - Google Patents

Method and device for generating remote procedure call (RPC) code Download PDF

Info

Publication number
CN103235718A
CN103235718A CN2013101046756A CN201310104675A CN103235718A CN 103235718 A CN103235718 A CN 103235718A CN 2013101046756 A CN2013101046756 A CN 2013101046756A CN 201310104675 A CN201310104675 A CN 201310104675A CN 103235718 A CN103235718 A CN 103235718A
Authority
CN
China
Prior art keywords
rpc
code
file
information
xml 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.)
Pending
Application number
CN2013101046756A
Other languages
Chinese (zh)
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.)
Maipu Communication Technology Co Ltd
Original Assignee
Maipu Communication 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 Maipu Communication Technology Co Ltd filed Critical Maipu Communication Technology Co Ltd
Priority to CN2013101046756A priority Critical patent/CN103235718A/en
Publication of CN103235718A publication Critical patent/CN103235718A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a method and a device for generating a remote procedure call (RPC) code, and relates to the technical field of communication. A user input does not need to be received to finish encapsulation and de-encapsulation of a protocol layer in the process of realizing communication between equipment, so that the time is saved and the efficiency of communication between equipment is improved. The embodiment of the invention comprises the steps as follows: obtaining a template file and an XML (extensive markup language) file marking the user demand to obtain first information in the XML file, generating the RPC code by the first information in combination with the template file, and finishing RPC encapsulation and/or RPC de-encapsulation when the RPC code is called by an RPC client end or an RPC server end. The technical scheme adopted by the invention is mainly applied to the process of automatically generating the code.

Description

Method and device that a kind of remote procedure call RPC code generates
Technical field
The present invention relates to communication technical field, relate in particular to method and device that a kind of remote procedure call RPC code generates.
Background technology
(English full name is XML: Extensible Markup Language, the Chinese full name is: extend markup language) (English full name is RPC: Remote Procedure Call, the Chinese full name is: remote procedure call) at present in the Internet network application, especially very general based on using in the application of WEB.Google, Microsoft etc. provide based on the application of XML core, storehouse or development language.Language such as Java/JSP, PHP, C#, Python, Perl are often adopted in application based on XML RPC, these language have all comprised the characteristic that is conducive to the abbreviated character string manipulation, the storehouse of XML processing very efficiently all is provided usually, therefore, can very simple realization encapsulates and decapsulation based on XML.In fact the target of RPC requires the user except being concerned about that the concrete function of client and server end realizes, does not need to be concerned about how client realizes calling, and how server end obtains details such as parameter.
At present, distributed communication system is used day by day general, in this system, as realizing down the functions such as configuration of forwarding list item, data sync, integrated circuit board and chip, just need be applied to the RPC agreement, to satisfy the communication requirement between the distributed elements.But, in the process of above-mentioned application RPC, need the realization personnel to import encapsulation and decapsulation that relevant RPC code is finished protocol layer, will expend a large amount of time and efforts of user like this and debug, reduced the communication efficiency between the equipment plate card.
Summary of the invention
Method and device that embodiments of the invention provide a kind of code to generate, do not need to receive encapsulation and the decapsulation that the user imports to finish protocol layer in the process of in realizing communication facilities, communicating by letter between distributed elements, thereby saved the time, improved the communication efficiency of equipment room.
For achieving the above object, embodiments of the invention adopt following technical scheme:
The method that a kind of RPC code generates comprises:
Obtain template file and expandable mark language XML file, described XML file is used for the identifying user demand;
Obtain the first information in the described XML file, the described first information comprises function name, parameter, parameter type;
According to the first information in described template file and the described XML file, generate the RPC code.
The device that a kind of RPC code generates comprises:
Acquiring unit is used for obtaining template file and expandable mark language XML file, and described XML file is used for the identifying user demand; Also be used for obtaining the first information of described XML file, the described first information comprises function name, parameter, parameter type; And according to the first information in described template file and the described XML file, generate the RPC code, finish RPC encapsulation and/or RPC decapsulation.
Method and device that the RPC code that the embodiment of the invention provides generates, obtain the template file of the formation rule that comprises RPC fixed code and the variable code of RPC, and obtain the XML file of identifying user demand, and then obtain the first information in the XML file, this first information generates the RPC code in conjunction with above-mentioned template file, finish the RPC encapsulation during by the RPC client call when this RPC code, when being called by the RPC server end by this RPC code, finish the RPC decapsulation.In existing scheme, import to finish encapsulation by the reception user and compare with decapsulation, the present invention does not need to receive encapsulation and the decapsulation that the user imports to finish protocol layer, thereby has saved the time, has improved the communication efficiency of equipment room.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art, to do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art below, apparently, accompanying drawing in describing below only is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
The process flow diagram of a kind of RPC code generating method that Fig. 1 provides for one embodiment of the invention;
The process flow diagram of a kind of RPC code generating method that Fig. 2 provides for another embodiment of the present invention;
The composition frame chart of a kind of RPC code generating unit that Fig. 3 provides for another embodiment of the present invention;
The composition frame chart of the another kind of RPC code generating unit that Fig. 4 provides for another embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
The method that one embodiment of the invention provides a kind of RPC code to generate, as shown in Figure 1, this method comprises:
101, obtain template file and XML file.
Wherein, the XML file is used for the identifying user demand.
102, obtain the first information in the XML file.
Wherein, the first information comprises function name, parameter, three kinds of necessary informations of parameter type, according to comprising all the other any one or a few information in the actual conditions first information.
103, according to the first information in template file and the XML file, generate the RPC code.
What deserves to be explained is that generate the RPC code in this step, this RPC code is made of a plurality of files.。
Optionally, the RPC code utilizes code generator to generate.
What deserves to be explained is that the RPC code comprises two parts in the present embodiment, i.e. variable code and fixed code.Fixed code is included in the template file, and also comprises the formation rule of the variable code of RPC in the template file; The variable code of RPC obtains user's different demands by the get label, and user's demand is included in the XML file.When the operation code maker, template file analyzing XML file, and from this XML file, obtain the first information, (English full name is: XML Path, Chinese full name is: the XML path) the above-mentioned first information resolved in language by XPath again.And then template file generates the RPC code in conjunction with the first information.
Optionally, the formation rule of the variable code of RPC refers to the tectonic framework of the variable code of RPC, and obtains the variable code of RPC of different user demands, has unified framework, and this framework needs different user's requests to fill, and constitutes the variable code of RPC.
The method that the RPC code that the embodiment of the invention provides generates, obtain the template file of the formation rule that comprises RPC fixed code and the variable code of RPC, obtain the XML file of identifying user demand, and then obtain the first information in the XML file, this first information generates the RPC code in conjunction with above-mentioned template file, thereby finishes RPC encapsulation and/or RPC decapsulation when being called by RPC client or RPC server end.In existing scheme, import to finish encapsulation by the reception user and compare with decapsulation, the present invention does not need to receive encapsulation and the decapsulation that the user imports to finish protocol layer, thereby has saved the time, has improved the communication efficiency of equipment room.
The method that another embodiment of the present invention provides a kind of RPC code to generate, as shown in Figure 2, this method comprises:
201, analyze the RPC code, and obtain the formation rule of RPC fixed code and the variable code of RPC.
Wherein, the formation rule of the variable code of RPC is identical with the related content of description among the last embodiment 103, no longer is repeated in this description at this.
202, according to the RPC fixed code of obtaining and the formation rule of the variable code of RPC, the structure template file.
203, receive the header file of user's input.
Wherein, header file is used for the identifying user demand, comprises function name, parameter, three kinds of information of parameter type in the header file at least, can also comprise all the other any one or a few information according to actual conditions.
204, by first preset rules header file is converted to the XML file.
Wherein, first rule comprises uses Java language that described header file is changed, and namely is converted to the XML file.
What deserves to be explained is that template file is by Jet markup language structure, again by, XML is a kind of extendible SGML, can well be as the input of Jet template file, when then header file being converted into the XML file herein, its flesh and blood does not change.
205, by second preset rules, from the XML file, obtain the first information.
Wherein, the first information is identical with associated description in the last embodiment step 102, in this no longer repeat specification.
Be specially: second preset rules comprises utilizes code generator to move described template file, according to described template file analyzing XML file, and obtains the first information from this XML file.
206, utilize code generator, according to the first information in template file and the XML file, generate the RPC code.
Optionally, the RPC code calls for RPC client and/or RPC server end.
What deserves to be explained is, generate the RPC code herein, thereby finished encapsulation and the decapsulation of RPC code when being called by RPC client or RPC server end.
Worth explanation, the RPC code is the C language codes in the RPC code that this step generates, thereby can use in multiple systems, comprises distributed system or integrated system.
The method that the RPC code that the embodiment of the invention provides generates, by analyzing the characteristic of RPC code, obtain template file, the header file that receives user's input also is converted to this header file the XML file of identifying user demand, and then obtain the first information in the XML file, this first information generates in conjunction with above-mentioned template file and is used for the RPC code that RPC client and/or RPC server end call, thereby finishes RPC encapsulation and/or RPC decapsulation.In existing scheme, import to finish encapsulation by the reception user and compare with decapsulation, the present invention does not need to receive encapsulation and the decapsulation that the user imports to finish protocol layer, thereby has saved the time, improved the communication efficiency of equipment room, can be applied in distributed system or the integrated system.
The device that another embodiment of the present invention provides a kind of RPC code to generate, as shown in Figure 3, this device comprises: acquiring unit 31.
Acquiring unit 31 is used for obtaining template file and XML file; Also be used for obtaining the first information of XML file, wherein, the first information comprises function name, parameter, parameter type; And according to the first information in above-mentioned template file and the XML file, generate the RPC code, finish RPC encapsulation and/or RPC decapsulation when being called by RPC client or RPC server end.
Optionally, the XML file is used for the identifying user demand.
Optionally, as shown in Figure 4, this device also comprises: tectonic element 32; Described acquiring unit 31 comprises: receive subelement 311, conversion subelement 312, operation subelement 313, generate subelement 314.
Tectonic element 32 is used for analyzing the RPC code before described acquiring unit 31 obtains template file, obtains the formation rule of RPC fixed code and the variable code of RPC; According to the formation rule of described RPC fixed code and the variable code of RPC, the structure template file.
Receive subelement 311, be used for receiving the header file of user's input, this header file is used for the identifying user demand.
Conversion subelement 312 is used for by first preset rules header file that described reception subelement 311 receives being converted to the XML file, and first rule comprises uses Java language that above-mentioned header file is changed.
Optionally, described acquiring unit 31, be used for obtaining the first information of stating the XML file, specifically comprise: by second preset rules from the XML file, obtain the first information, wherein, second preset rules comprises utilizes code generator operation template file, according to this template file analyzing XML file, and from this XML file, obtain the described first information.
Operation subelement 313 is used for moving this template file before the template file analyzing XML file that obtains according to described acquiring unit.
Generate subelement 314, be used for the first information of the described template file that moves according to described operation subelement 313 and the XML file that obtains; Generate the RPC code.
Optionally, this RPC code is applied to RPC client and/or RPC server end.
The device that the RPC code that the embodiment of the invention provides generates, obtain the XML file of template file and identifying user demand by acquiring unit, and then obtain the first information in the XML file, this first information generates the RPC code in conjunction with above-mentioned template file, thereby finishes RPC encapsulation and/or RPC decapsulation when being called by RPC client or RPC server end.In existing scheme, import to finish encapsulation by the reception user and compare with decapsulation, the present invention does not need to receive encapsulation and the decapsulation that the user imports to finish protocol layer, thereby has saved the time, has improved the communication efficiency of equipment room.
Through the above description of the embodiments, the those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential common hardware, can certainly pass through hardware, but the former is better embodiment under a lot of situation.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in the storage medium that can read, floppy disk as computing machine, hard disk or CD etc., comprise some instructions with so that computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
The above; only be the specific embodiment of the present invention, but protection scope of the present invention is not limited thereto, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of described claim.

Claims (10)

1. the method that remote procedure call RPC code generates is characterized in that, comprising:
Obtain template file and expandable mark language XML file, described XML file is used for the identifying user demand;
Obtain the first information in the described XML file, the described first information comprises function name, parameter, parameter type;
According to the first information in described template file and the described XML file, generate the RPC code.
2. the method that generates of RPC code according to claim 1 is characterized in that, described obtain template file before, also comprise:
Analyze the RPC code, obtain the formation rule of RPC fixed code and the variable code of RPC;
According to the described RPC fixed code of obtaining and the formation rule of the variable code of RPC, the structure template file.
3. according to the method for the described RPC code generation of claim 1, it is characterized in that the described XML file that obtains specifically comprises:
Receive the header file of user's input, described header file is used for the identifying user demand;
By first preset rules described header file is converted to the XML file, described first rule comprises uses Java language that described header file is changed.
4. the method that generates of RPC code according to claim 1 is characterized in that the described first information that obtains in the described XML file comprises:
By second preset rules from described XML file, obtain the described first information, described second preset rules comprises utilizes code generator to move described template file, resolves described XML file according to described template file, and obtain the described first information from described XML file.
5. according to the method for claim 1 or 4 described RPC codes generations, it is characterized in that, described according to the first information in described template file and the described XML file, generate the RPC code, specifically comprise:
Utilize code generator, according to the first information in described template file and the described XML file, generate to be used for the described RPC code that RPC client and/or RPC server end call.
6. the device that the RPC code generates is characterized in that, comprising:
Acquiring unit is used for obtaining template file and expandable mark language XML file, and described XML file is used for the identifying user demand; Also be used for obtaining the first information of described XML file, the described first information comprises function name, parameter, parameter type; And according to the first information in described template file and the described XML file, generate the RPC code.
7. the device that generates of RPC code according to claim 6 is characterized in that this device also comprises:
Tectonic element is used for analyzing the RPC code before described acquiring unit obtains described template file, obtains the formation rule of RPC fixed code and the variable code of RPC; According to the formation rule of described RPC fixed code and the variable code of RPC, the structure template file.
8. the device that generates of RPC code according to claim 6 is characterized in that described acquiring unit comprises:
Receive subelement, be used for receiving the header file of user's input, described header file is used for the identifying user demand;
The conversion subelement is used for by first preset rules described header file that described reception subelement receives being converted to the XML file, and described first rule comprises uses Java language that described header file is changed.
9. the device of RPC code generation according to claim 6 is characterized in that,
Described acquiring unit is used for obtaining the first information of described XML file, specifically comprise: by second preset rules from described XML file, obtain the described first information, described second preset rules comprises utilizes code generator to move described template file, resolve described XML file according to described template file, and from described XML file, obtain the described first information.
10. according to the device of claim 6 or 9 described RPC codes generations, it is characterized in that described acquiring unit also comprises:
The operation subelement is used for moving described template file before resolving described XML file according to described template file;
Generate subelement, be used for the first information according to described template file and described XML file, generate and be used for the described RPC code that RPC client and/or RPC server end call.
CN2013101046756A 2013-03-28 2013-03-28 Method and device for generating remote procedure call (RPC) code Pending CN103235718A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2013101046756A CN103235718A (en) 2013-03-28 2013-03-28 Method and device for generating remote procedure call (RPC) code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2013101046756A CN103235718A (en) 2013-03-28 2013-03-28 Method and device for generating remote procedure call (RPC) code

Publications (1)

Publication Number Publication Date
CN103235718A true CN103235718A (en) 2013-08-07

Family

ID=48883763

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2013101046756A Pending CN103235718A (en) 2013-03-28 2013-03-28 Method and device for generating remote procedure call (RPC) code

Country Status (1)

Country Link
CN (1) CN103235718A (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105022619A (en) * 2014-04-25 2015-11-04 无锡物联网产业研究院 Code processing method and device
CN108337236A (en) * 2017-12-28 2018-07-27 杭州马猴烧韭科技有限公司 A kind of gRPC call methods and device based on Protobuf and HTTP/1.1
CN108509201A (en) * 2018-03-20 2018-09-07 深圳神州数码云科数据技术有限公司 A kind of code generating method and device
CN108647033A (en) * 2018-04-03 2018-10-12 四川新网银行股份有限公司 A kind of SDK automatic packaging methods of open platform
CN108762764A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 Code automatic generation method, device, computer equipment and storage medium
CN109274773A (en) * 2018-11-14 2019-01-25 四川长虹电器股份有限公司 A kind of realization remote service calling method, device and system
CN110232007A (en) * 2019-05-21 2019-09-13 昆明能讯科技有限责任公司 A kind of electric power enterprise information service monitoring method based on APM technology
CN111324343A (en) * 2020-02-20 2020-06-23 支付宝(杭州)信息技术有限公司 Code generation method and device
CN117519670A (en) * 2023-12-25 2024-02-06 杭银消费金融股份有限公司 Method and system for automatically generating RPC (remote procedure control) codes
WO2024044914A1 (en) * 2022-08-29 2024-03-07 西门子股份公司 Method for generating code for describing remote procedure call, and electronic device, medium and program product

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7028312B1 (en) * 1998-03-23 2006-04-11 Webmethods XML remote procedure call (XML-RPC)
CN1783883A (en) * 2004-12-02 2006-06-07 国际商业机器公司 Method and system for setting specific transmission attribute from customer end without relationship of transmission
CN101523849A (en) * 2007-06-29 2009-09-02 捷讯研究有限公司 System and method for communication protocol mapping

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7028312B1 (en) * 1998-03-23 2006-04-11 Webmethods XML remote procedure call (XML-RPC)
CN1783883A (en) * 2004-12-02 2006-06-07 国际商业机器公司 Method and system for setting specific transmission attribute from customer end without relationship of transmission
CN101523849A (en) * 2007-06-29 2009-09-02 捷讯研究有限公司 System and method for communication protocol mapping

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
罗玲等: "基于XML的RPC技术分析", 《计算机科学》 *
邢昊 等: "基于Velocity的J2EE开发模式及其应用", 《计算机应用》 *
黄永平 等: "Jabber与SOAP的代理框架及远程管理", 《吉林大学学报》 *

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105022619A (en) * 2014-04-25 2015-11-04 无锡物联网产业研究院 Code processing method and device
CN108337236A (en) * 2017-12-28 2018-07-27 杭州马猴烧韭科技有限公司 A kind of gRPC call methods and device based on Protobuf and HTTP/1.1
CN108509201A (en) * 2018-03-20 2018-09-07 深圳神州数码云科数据技术有限公司 A kind of code generating method and device
CN108647033A (en) * 2018-04-03 2018-10-12 四川新网银行股份有限公司 A kind of SDK automatic packaging methods of open platform
CN108762764A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 Code automatic generation method, device, computer equipment and storage medium
CN109274773B (en) * 2018-11-14 2021-01-26 四川长虹电器股份有限公司 Method, device and system for realizing remote service calling
CN109274773A (en) * 2018-11-14 2019-01-25 四川长虹电器股份有限公司 A kind of realization remote service calling method, device and system
CN110232007A (en) * 2019-05-21 2019-09-13 昆明能讯科技有限责任公司 A kind of electric power enterprise information service monitoring method based on APM technology
CN111324343A (en) * 2020-02-20 2020-06-23 支付宝(杭州)信息技术有限公司 Code generation method and device
CN111324343B (en) * 2020-02-20 2022-03-25 蚂蚁财富(上海)金融信息服务有限公司 Code generation method and device
WO2024044914A1 (en) * 2022-08-29 2024-03-07 西门子股份公司 Method for generating code for describing remote procedure call, and electronic device, medium and program product
CN117519670A (en) * 2023-12-25 2024-02-06 杭银消费金融股份有限公司 Method and system for automatically generating RPC (remote procedure control) codes
CN117519670B (en) * 2023-12-25 2024-04-09 杭银消费金融股份有限公司 Method and system for automatically generating RPC (remote procedure control) codes

Similar Documents

Publication Publication Date Title
CN103235718A (en) Method and device for generating remote procedure call (RPC) code
JP6695984B2 (en) Multitask scheduling method, system, application server, and computer-readable storage medium
CN110083650B (en) Metadata self-discovery-based automatic generation method for data query interface
CN106445484A (en) Method and system for realizing data tracking through software development kit
CN101384086B (en) Network device configuring method apparatus and system
CN110119292A (en) System operational parameters querying method, matching process, device and node device
US9003433B2 (en) Off-premise and codeless process-centric business mashup to integrate BPEL based processes and web 2.0 widgets
CN103677821A (en) Method and device for publishing software development tool code
CN103780627A (en) Native APP, Web APP and Wechat-similar APP information synchronization system
CN105022619A (en) Code processing method and device
CN111880904A (en) Method, system and related device for arranging virtualization platform resources
CN101894059A (en) Method and system for detecting operating condition
CN106603593A (en) HTTP calling method and device based on adaption
CN105120002B (en) A kind of information processing method and device
CN107357810B (en) A kind of method and system for landing page for exporting special topic
CN104731650A (en) Acquisition method and device for system interface call information
CN107786425A (en) Information off-line treating method and apparatus
CN107888663A (en) A kind of method of distribution of document, equipment and computer-readable medium
CN102624876A (en) Data configuration method and data configuration device
CN106888264A (en) A kind of method for interchanging data and device
CN100499509C (en) A data configuration method, system and operating and maintenance center
CN105099784B (en) Label setting method, apparatus and system
CN101674327A (en) Heterogeneous system message integration method, framework and system
CN107741994A (en) A kind of data-updating method and device
CN103561113A (en) Web Service interface generating method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20130807

RJ01 Rejection of invention patent application after publication