CN112506679A - RPC service calling method and equipment - Google Patents

RPC service calling method and equipment Download PDF

Info

Publication number
CN112506679A
CN112506679A CN202011497239.6A CN202011497239A CN112506679A CN 112506679 A CN112506679 A CN 112506679A CN 202011497239 A CN202011497239 A CN 202011497239A CN 112506679 A CN112506679 A CN 112506679A
Authority
CN
China
Prior art keywords
rpc service
request message
calling
rpc
url
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
CN202011497239.6A
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.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group 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 China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202011497239.6A priority Critical patent/CN112506679A/en
Publication of CN112506679A publication Critical patent/CN112506679A/en
Pending legal-status Critical Current

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
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • 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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/544Remote

Landscapes

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

Abstract

The embodiment of the invention provides a method and equipment for calling RPC service, wherein the method comprises the following steps: determining a corresponding calling url and parameters according to the access type of the RPC service; generating a request message according to the calling url and the parameters; sending the request message to a system control layer through rest so that the system control layer calls RPC service through a java reflection mechanism according to the request message; and receiving a calling result of the RPC service returned by the system control layer. The method provided by the embodiment can achieve the purpose of testing the RPC service interface, so that a tester can test the RPC service interface by using a tool for testing the rest interface, and the problem that the existing tester cannot find the RPC interface in time and further cannot repair the RPC interface to cause corresponding RPC service errors is solved.

Description

RPC service calling method and equipment
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a method and equipment for calling RPC service.
Background
With the development of business and the arrival of big data era, the pressure of service providers is increasing, and the processing capacity of a stand-alone application is limited in software and hardware. Thus, a distributed service architecture arises.
The conventional distributed service framework (e.g., Dubbo, HSF, gRPC, etc.) is implemented by Remote Procedure Call (RPC).
However, the existing tester can only test the RPC service written by the developer by writing a local test class, and cannot find the problem of the RPC interface in time, and further cannot repair the RPC interface, so that the corresponding RPC service is in error.
Disclosure of Invention
The embodiment of the invention provides an RPC service calling method and equipment, aiming at solving the problems that the existing testers cannot find an RPC interface in time and further cannot repair the RPC interface, so that corresponding RPC service errors are caused.
In a first aspect, an embodiment of the present invention provides a method for RPC service invocation, including:
determining a corresponding calling url and parameters according to the access type of the RPC service;
generating a request message according to the uniform resource locator (url) and the parameter;
sending the request message to a system control layer through representational state transfer (rest for short), so that the system control layer calls RPC service through a java reflection mechanism according to the request message;
and receiving a calling result of the RPC service returned by the system control layer.
In one possible design, the determining the corresponding call url and parameters according to the type of the RPC service includes:
acquiring a corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter;
and determining a calling url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
In one possible design, the sending the request packet to the system control layer through rest includes:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
In a second aspect, an embodiment of the present invention provides another RPC interface calling method, including:
receiving a request message sent by a client through rest, wherein the request message is generated by the client according to a call url and parameters after the client determines the corresponding call url and parameters according to the access type of the RPC service;
according to the request message, calling RPC service through a java reflection mechanism;
and returning the call result of the RPC service to the client.
In a possible design, the invoking of the RPC service through the java reflection mechanism according to the request packet includes:
calling a corresponding method to obtain a parameter corresponding to the request message;
and obtaining a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calling the RPC service.
In a third aspect, an embodiment of the present invention provides an RPC service invocation device, including:
the call information determining module is used for determining a corresponding call url and parameters according to the access type of the RPC service;
the message generation module is used for generating a request message according to the calling url and the parameters;
the message sending module is used for sending the request message to a system control layer through rest so that the system control layer can call RPC service according to the request message through a java reflection mechanism;
and the result receiving module is used for receiving the call result of the RPC service returned by the system control layer.
In one possible design, the call information determination module determines the corresponding call url and parameters according to the type of the RPC service, including:
acquiring a corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter;
and determining a calling url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
In one possible design, the sending module sends the request packet to the system control layer through rest, including:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
In a fourth aspect, an embodiment of the present invention provides another RPC service call device, including:
the message receiving module is used for receiving a request message sent by a client through rest, and the request message is generated by the client according to a call url and parameters after the client determines the corresponding call url and parameters according to the access type of the RPC service;
the service calling module is used for calling RPC service through a java reflection mechanism according to the request message;
and the result returning module is used for returning the calling result of the RPC service to the client.
In one possible design, the service invocation module invokes RPC service through java's reflection mechanism according to the request packet, including:
calling a corresponding method to obtain a parameter corresponding to the request message;
and obtaining a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calling the RPC service.
In a fifth aspect, an embodiment of the present invention provides an RPC service call device, including: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing the memory-stored computer-executable instructions causes the at least one processor to perform the RPC service invocation method as described above in the first aspect and in various possible designs of the first aspect.
In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, where computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the RPC service invocation method according to the first aspect and various possible designs of the first aspect is implemented.
In a seventh aspect, an embodiment of the present invention provides another RPC service invocation device, including: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing the memory-stored computer-executable instructions causes the at least one processor to perform the RPC service call method as described above in the second aspect and in various possible designs of the second aspect.
In an eighth aspect, an embodiment of the present invention provides another computer-readable storage medium, where computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the RPC service invocation method according to the second aspect and various possible designs of the second aspect is implemented.
In a ninth aspect, the present application provides a computer program product, which includes computer instructions for executing the method of the first aspect by a processor.
In a tenth aspect, an embodiment of the present application provides another computer program product, which includes computer instructions for executing the method of the second aspect by a processor.
In the method and the device for calling the RPC service, a corresponding calling url and parameters are determined according to the access type of the RPC service, and a request message is generated according to the calling url and the parameters; sending the request message to a system control layer through rest so that the system control layer calls RPC service through a java reflection mechanism according to the request message; receiving the RPC service calling result returned by the system control layer, achieving the purpose of testing the RPC service interface, enabling a tester to use a tool for testing the rest interface to test the RPC service interface, solving the problem that the existing tester can not find the RPC interface in time, and further can not repair the RPC interface, and causing the problem that the corresponding RPC service is wrong.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is an application scenario diagram of an RPC service invocation method according to an embodiment of the present invention;
FIG. 2 is a first flowchart of a RPC service invocation method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a second method for RPC service invocation according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an application example of the RPC service invocation method according to the embodiment of the present invention;
fig. 5 is a first schematic structural diagram of an RPC service call device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an RPC service call device according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a hardware structure of an RPC service call device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
With the development of business and the arrival of big data era, the pressure of service providers is increasing, and the processing capacity of a stand-alone application is limited in software and hardware. Thus, a distributed service architecture arises. In a traditional distributed service framework (e.g. Dubbo, HSF, gRPC, etc.) it is implemented by remote procedure call protocol RPC. However, the existing tester can only test the RPC service written by the developer by writing a local test class, and cannot find the problem of the RPC interface in time, and further cannot repair the RPC interface, so that the corresponding RPC service is in error.
Therefore, in view of the above problems, the present invention provides an RPC service invocation method, which determines a corresponding invocation url and parameters according to an entry type of an RPC service, and generates a request message according to the invocation url and the parameters; sending the request message to a system control layer through rest so that the system control layer calls RPC service through a java reflection mechanism according to the request message; receiving the RPC service calling result returned by the system control layer, achieving the purpose of testing the RPC service interface, enabling a tester to use a tool for testing the rest interface to test the RPC service interface, solving the problem that the existing tester can not find the RPC interface in time, and further can not repair the RPC interface, and causing the problem that the corresponding RPC service is wrong.
Fig. 1 is an application scenario diagram of an RPC service invocation method provided by the present invention. As shown in fig. 1, the client 101 may determine a corresponding call url and parameters according to the entry type of the RPC service, and generate a request packet according to the call url and the parameters; the request message may be sent to the system control layer 102 through rest, so that the system control layer 102 invokes the RPC service according to the request message through a java reflection mechanism, and may also receive an RPC service invocation result returned by the system control layer 102.
Information interaction can be performed between the client 101 and the system control layer 102, so that the purpose of testing the RPC service interface is achieved. The client 101 may include an operation interface, and a tester may perform corresponding operations on the operation interface. After the system control layer 102 obtains the request message transmitted by the front end of the client 101 through rest, the interface is invoked through the java reflection mechanism, and the invocation result is returned to the client 101.
Fig. 2 is a first schematic flow chart of an RPC service invocation method according to an embodiment of the present invention, where an execution main body of the embodiment may be a client in the embodiment shown in fig. 1. As shown in fig. 2, the method may include:
s201, determining a corresponding call url and parameters according to the access type of the RPC service.
Here, the entries of the RPC service may be of map, json, DTO, or the like, and the client may determine the corresponding call url and parameters according to the different types of entries. (if the RPC service entry is map, call url http:// ip: port/contentPrath/RPC/callServiceWithMapParam parameter { "callMethod": print "," serviceBean ": testServestParam", "requestParam": "{ \\ animals \":': name \ ": test \" }, \\\ date \ 1522561245022, \\ "dog \" { \\\ \ count \ 0, \\\\ name \ dog \ and \ "twoFeet \ false } }" }).
Optionally, the determining the corresponding call url and the parameter according to the entry type of the RPC service includes:
acquiring a corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter;
and determining a calling url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
The corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter can be determined according to actual conditions. The client searches the calling url and the parameter corresponding to the entry type of the RPC service in the preset corresponding relation between the type of the entry of the RPC service and the calling url and the parameter, if the calling url and the parameter are found, the calling url and the parameter are obtained, and if the calling url and the parameter are not found, a corresponding prompt can be given, for example, the searching fails, so as to prompt relevant personnel to perform corresponding processing in time.
In addition, the client supports the interface test of the input parameter in various data formats, and the tester only needs to input the corresponding input parameter and determines the corresponding call url and the corresponding parameter according to the type of the input parameter, so that the aim of testing the RPC service interface can be fulfilled.
And S202, generating a request message according to the calling url and the parameters.
In the embodiment of the invention, a request message is generated according to the calling url and the parameters, the request message comprises a called method name and a service class name, a corresponding method can be called according to the two items, the request message also comprises a request parameter, and the transmitted data can be processed in a program mode according to the class name, the method name and the specific parameter. The request parameter in the request message may be in json format.
S203, sending the request message to a system control layer through rest so that the system control layer can call RPC service according to the request message through a java reflection mechanism.
Optionally, the sending the request packet to the system control layer through rest includes:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
Specifically, the client may adopt a springmvc architecture, and the reference to the system control layer (Controller) includes:
the client submits the request message to the DispatcterServlet;
inquiring one or more HandlerMappings by the DispatcterServlet Controller to find a Controller for processing the request message;
the DispatcterServlet submits the request message to a Controller;
and after the Controller calls the service logic for processing, returning to ModelAndView.
In addition, after the system control layer receives the request message, when the SpringMvc is started, all Bean classes, namely classes marked by components such as @ Controller and @ Component, are loaded, then the method of @ RequestMapping is also added into a set, and the method is matched according to a value path in the @ RequestMapping, and then the corresponding packing method can be called. Wherein, the Spring MVC belongs to the subsequent product of the Spring FrameWork and is fused in the Spring Web Flow. The Spring framework provides a fully functional MVC module that builds Web applications. The Spring pluggable MVC framework is used, so that when the Spring is used for WEB development, the Spring MVC framework using the Spring or other MVC development frameworks such as Struts1 (which are not used generally at present), Struts 2 (which are used in a common old project) and the like can be selected to be used. The request may be mapped using @ RequestMapping in Spring MVC, by which it may be specified which URL requests the controller may handle.
And reading the body part data of the request message by using the RequestBody, namely, obtaining the related parameters input in the request. The @ RequestBody is to convert an input (request. getinputstream ()) of the entire httpervletrequest into one object, and a common conversion is to use a json method, and a getString method is used to obtain specific parameters. Wherein the public interface class HttpServletRequest is inherited from serverequest. The request from the client browser is encapsulated into an http servletrequest object. The object contains the client request information including the address of the request, the parameters of the request, the submitted data, the ip of the uploaded file client and even the operating system of the client.
The initialized bean in the Spring container is obtained through the getBean method of the ApplicationContext, and all the information (method, attribute, class name, parent class name, all the interfaces realized, and the like) which is required can be obtained through the method in the class through the getBean. The Chinese meaning of the ApplicationContext is "application context", which is inherited from the BeanFactory interface, and besides all functions of the BeanFactory, the ApplicationContext performs good support in the aspects of international support, resource access (such as URL and file), event propagation and the like, and can be applied to Java APP and Java Web.
And S204, receiving a calling result of the RPC service returned by the system control layer.
The system control layer returns the call result of the RPC service to the client, the client can display the result, relevant personnel can check corresponding information conveniently, the result can be stored, the relevant personnel can inquire the corresponding information conveniently, and the actual application requirement is met.
In the RPC service calling method provided by this embodiment, a corresponding calling url and parameters are determined according to the entry type of the RPC service, and a request message is generated according to the calling url and the parameters; sending the request message to a system control layer through rest so that the system control layer calls RPC service through a java reflection mechanism according to the request message; receiving the RPC service calling result returned by the system control layer, achieving the purpose of testing the RPC service interface, enabling a tester to use a tool for testing the rest interface to test the RPC service interface, solving the problem that the existing tester can not find the RPC interface in time, and further can not repair the RPC interface, and causing the problem that the corresponding RPC service is wrong.
Fig. 3 is a schematic flow diagram of a second method for RPC service invocation according to an embodiment of the present invention, where an execution main body of the embodiment may be a system control layer in the embodiment shown in fig. 1. As shown in fig. 3, the method may include:
s301, receiving a request message sent by a client through rest, wherein the request message is generated by the client according to a call url and parameters after the client determines the corresponding call url and parameters according to the access type of the RPC service.
The client determines a corresponding call url and parameters according to the access type of the RPC service, generates a request message according to the call url and the parameters, and sends the request message to a system control layer through rest. Among them, rest, that is, representational state transfer (representational state transfer), is a software architecture style, is a design and development mode for network applications, and can reduce the complexity of development and improve the scalability of the system.
And S302, calling the RPC service through a java reflection mechanism according to the request message.
Optionally, the invoking of the RPC service through the java reflection mechanism according to the request packet includes:
calling a corresponding method to obtain a parameter corresponding to the request message;
and obtaining a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calling the RPC service.
And S303, returning the call result of the RPC service to the client.
The client transmits the relevant parameters input by the tester to the system control layer through rest, and the system control layer calls the RPC service through a java reflection mechanism and returns the call result to the client.
According to the RPC service calling method provided by the embodiment, the request message sent by the client through rest is received, according to the request message, the RPC service is called through a java reflection mechanism, the calling result of the RPC service is returned to the client, the purpose of testing an RPC service interface can be achieved, so that a tester can test the RPC service interface by using a tool for testing the rest interface, the problem that the existing tester cannot find the RPC interface in time is solved, the RPC interface cannot be repaired, and the problem that corresponding RPC service is in error is caused.
In order to better understand the above method, an application example of the RPC service call method of the present invention is described in detail below.
With reference to the foregoing embodiments, in this embodiment, an interaction process between a client and a system control layer is taken as an example for description, and this description is not intended to limit the scheme of the present invention.
As shown in fig. 4, the present application example may include:
s401, the client side obtains the corresponding relation between the preset RPC service parameter entering type and the calling url and the parameter.
S402, the client determines a call url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
And S403, the client generates a request message according to the calling url and the parameters, and sends the request message to a system control layer through rest.
The client sends the request message to a system control layer through rest, and the method comprises the following steps:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
S404, the system control layer receives the request message and calls a corresponding method to obtain the corresponding parameters of the request message.
S405, the system control layer obtains a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calls the RPC service.
S406, the system control layer returns the call result of the RPC service to the client.
As can be seen from the above description, the control layer of the system of this embodiment obtains the request packet transmitted by the client through rest, calls the interface through the java reflection mechanism, and returns the call result to the client, so as to achieve the purpose of testing the RPC service interface, so that a tester can test the RPC service interface by using a tool for testing the rest interface, and solve the problem that the existing tester cannot find the RPC interface in time, and further cannot repair the RPC interface, thereby causing an error in the corresponding RPC service.
Fig. 5 is a schematic structural diagram of an RPC service call device according to an embodiment of the present invention. As shown in fig. 4, the RPC service call device 50 includes: a calling information determining module 501, a message generating module 502, a message sending module 503 and a result receiving module 504.
And the call information determining module 501 is configured to determine a corresponding call url and a parameter according to the entry type of the RPC service.
A message generating module 502, configured to generate a request message according to the call url and the parameter.
The message sending module 503 is configured to send the request message to a system control layer through rest, so that the system control layer invokes an RPC service according to the request message through a java reflection mechanism.
And a result receiving module 504, configured to receive a call result of the RPC service returned by the system control layer.
In one possible design, the call information determining module 501 determines the corresponding call url and parameters according to the type of the RPC service, including:
acquiring a corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter;
and determining a calling url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
In a possible design, the sending module 503 sends the request packet to the system control layer through rest, including:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
The device provided in this embodiment may be used to implement the technical solution of the method embodiment shown in fig. 1, and the implementation principle and technical effect are similar, which are not described herein again.
Fig. 6 is a schematic structural diagram of an RPC service call device according to an embodiment of the present invention. As shown in fig. 6, the RPC service call device 60 includes: a message receiving module 601, a service calling module 602 and a result returning module 603.
The message receiving module 601 is configured to receive a request message sent by a client through rest, where the request message is generated by the client according to a call url and parameters after the client determines corresponding call url and parameters according to a reference type of an RPC service.
And the service calling module 602 is configured to call the RPC service through a java reflection mechanism according to the request message.
And a result returning module 603, configured to return the call result of the RPC service to the client.
In one possible design, the service invocation module 602 invokes RPC service according to the request packet through a java reflection mechanism, including:
calling a corresponding method to obtain a parameter corresponding to the request message;
and obtaining a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calling the RPC service.
The device provided in this embodiment may be used to implement the technical solution of the method embodiment shown in fig. 2, and the implementation principle and technical effect are similar, which are not described herein again.
Fig. 7 is a schematic diagram of a hardware structure of an RPC service call device according to an embodiment of the present invention. As shown in fig. 7, the RPC service call device 70 of the present embodiment includes: a processor 701 and a memory 702; wherein
A memory 702 for storing computer-executable instructions;
the processor 701 is configured to execute the computer executable instructions stored in the memory to implement the steps performed by the RPC service invocation method in the embodiment of fig. 2. Reference may be made in particular to the description relating to the method embodiments described above.
Alternatively, the memory 702 may be separate or integrated with the processor 701.
When the memory 702 is provided separately, the RPC service call device further includes a bus 703 for connecting the memory 702 and the processor 701.
The embodiment of the invention provides another RPC service calling device, which comprises: a processor and a memory; wherein
A memory for storing computer execution instructions;
a processor, configured to execute the computer executable instructions stored in the memory to implement the steps performed by the RPC service invocation method in the embodiment of fig. 3. Reference may be made in particular to the description relating to the method embodiments described above.
Alternatively, the memory may be separate or integrated with the processor.
When the memory is independently set, the RPC service call device further includes a bus for connecting the memory and the processor.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer execution instruction is stored in the computer-readable storage medium, and when a processor executes the computer execution instruction, the RPC service invocation method described in fig. 2 is implemented.
An embodiment of the present invention further provides another computer-readable storage medium, where a computer execution instruction is stored in the computer-readable storage medium, and when the computer execution instruction is executed by a processor, the RPC service call method as described in fig. 3 is implemented.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules is only one logical division, and other divisions may be realized in practice, for example, a plurality of modules may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each module may exist alone physically, or two or more modules are integrated into one unit. The unit formed by the modules can be realized in a hardware form, and can also be realized in a form of hardware and a software functional unit.
The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present application.
It should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile storage NVM, such as at least one disk memory, and may also be a usb disk, a removable hard disk, a read-only memory, a magnetic or optical disk, etc.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (enhanced Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The storage medium may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the storage medium may reside as discrete components in an electronic device or host device.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (12)

1. A RPC service calling method is characterized by comprising the following steps:
determining a corresponding calling uniform resource locator url and parameters according to the access type of the remote procedure call RPC service;
generating a request message according to the calling url and the parameters;
sending the request message to a system control layer through representational state transfer (rest) so that the system control layer calls RPC service through a java reflection mechanism according to the request message;
and receiving a calling result of the RPC service returned by the system control layer.
2. The method of claim 1, wherein determining the corresponding call url and parameters according to the type of the RPC service includes:
acquiring a corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter;
and determining a calling url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
3. The method according to claim 1 or 2, wherein the sending the request packet to a system control layer through rest comprises:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
4. A RPC interface calling method is characterized by comprising the following steps:
receiving a request message sent by a client through rest, wherein the request message is generated by the client according to a call url and parameters after the client determines the corresponding call url and parameters according to the access type of the RPC service;
according to the request message, calling RPC service through a java reflection mechanism;
and returning the call result of the RPC service to the client.
5. The method of claim 4, wherein the invoking of the RPC service through a java reflection mechanism according to the request message comprises:
calling a corresponding method to obtain a parameter corresponding to the request message;
and obtaining a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calling the RPC service.
6. An RPC service invocation device, comprising:
the call information determining module is used for determining a corresponding call url and parameters according to the access type of the RPC service;
the message generation module is used for generating a request message according to the calling url and the parameters;
the message sending module is used for sending the request message to a system control layer through rest so that the system control layer can call RPC service according to the request message through a java reflection mechanism;
and the result receiving module is used for receiving the call result of the RPC service returned by the system control layer.
7. The apparatus of claim 6, wherein the call information determination module determines the corresponding call url and parameters according to the type of the RPC service, including:
acquiring a corresponding relation between the type of the preset RPC service access parameter and the calling url and the parameter;
and determining a calling url and parameters corresponding to the access type of the RPC service according to the corresponding relation.
8. The apparatus according to claim 6 or 7, wherein the message sending module sends the request message to a system control layer through rest, and includes:
and sending the request message to a Dispatcherservlet through rest so that the Dispatcherservlet queries one or more HandlerMappings, determines a system control layer for processing the request message, and sends the request message to the system control layer.
9. An RPC service invocation device, comprising:
the message receiving module is used for receiving a request message sent by a client through rest, and the request message is generated by the client according to a call url and parameters after the client determines the corresponding call url and parameters according to the access type of the RPC service;
the service calling module is used for calling RPC service through a java reflection mechanism according to the request message;
and the result returning module is used for returning the calling result of the RPC service to the client.
10. The device of claim 9, wherein the service invocation module invokes RPC service according to the request message through java's reflection mechanism, and comprises:
calling a corresponding method to obtain a parameter corresponding to the request message;
and obtaining a method object of the RPC service through a java reflection mechanism according to the obtained parameters, and calling the RPC service.
11. An RPC service invocation device, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing the memory-stored computer-executable instructions causes the at least one processor to perform the RPC service call method of any of claims 1-3.
12. A computer-readable storage medium having stored thereon computer-executable instructions that, when executed by a processor, implement the RPC service call method of any of claims 1 to 3.
CN202011497239.6A 2020-12-17 2020-12-17 RPC service calling method and equipment Pending CN112506679A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011497239.6A CN112506679A (en) 2020-12-17 2020-12-17 RPC service calling method and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011497239.6A CN112506679A (en) 2020-12-17 2020-12-17 RPC service calling method and equipment

Publications (1)

Publication Number Publication Date
CN112506679A true CN112506679A (en) 2021-03-16

Family

ID=74922279

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011497239.6A Pending CN112506679A (en) 2020-12-17 2020-12-17 RPC service calling method and equipment

Country Status (1)

Country Link
CN (1) CN112506679A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160173648A1 (en) * 2014-12-16 2016-06-16 Software Ag System and method for condition-based application logic shifting between a client and a server
CN107360261A (en) * 2017-09-07 2017-11-17 北京奇艺世纪科技有限公司 A kind of HTTP request processing method, device and electronic equipment
CN108901022A (en) * 2018-06-28 2018-11-27 深圳云之家网络有限公司 A kind of micro services universal retrieval method and gateway
CN109426608A (en) * 2017-08-29 2019-03-05 中国电信股份有限公司 The test method and device of Distributed Services, computer readable storage medium
CN111176761A (en) * 2019-12-23 2020-05-19 中国联合网络通信集团有限公司 Micro-service calling method and device
CN111240668A (en) * 2018-11-28 2020-06-05 常熟昊虞电子信息科技有限公司 Method for constructing user interface framework based on Spring MVC

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160173648A1 (en) * 2014-12-16 2016-06-16 Software Ag System and method for condition-based application logic shifting between a client and a server
CN109426608A (en) * 2017-08-29 2019-03-05 中国电信股份有限公司 The test method and device of Distributed Services, computer readable storage medium
CN107360261A (en) * 2017-09-07 2017-11-17 北京奇艺世纪科技有限公司 A kind of HTTP request processing method, device and electronic equipment
CN108901022A (en) * 2018-06-28 2018-11-27 深圳云之家网络有限公司 A kind of micro services universal retrieval method and gateway
CN111240668A (en) * 2018-11-28 2020-06-05 常熟昊虞电子信息科技有限公司 Method for constructing user interface framework based on Spring MVC
CN111176761A (en) * 2019-12-23 2020-05-19 中国联合网络通信集团有限公司 Micro-service calling method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
GAVINLOO: "利用SpringMVC实现基于Http和Json的轻量级RPC框架", pages 1 - 4, Retrieved from the Internet <URL:https://blog.csdn.net/gavinloo/article/details/73321477> *
WEIXIN_39872395: "rest服务_使用基于SpringMVC的透明RPC开发微服务", pages 1 - 5, Retrieved from the Internet <URL:https://blog.csdn.net/weixin_39872395/article/details/111169274> *

Similar Documents

Publication Publication Date Title
CN109922158A (en) Data processing method, device, medium and electronic equipment based on micro services
CN111858296B (en) Interface testing method, device, equipment and storage medium
US10452522B1 (en) Synthetic data generation from a service description language model
CN111597110B (en) Page test method and device, electronic equipment and storage medium
CN112187933B (en) Method and system for monitoring services in multi-architecture cloud platform
CN110838071A (en) Policy data processing method and device and server
CN111510330B (en) Interface management device, method and storage medium
CN112306881A (en) Simulation data generation method, device, equipment and storage medium
CN109462507B (en) Configuration updating method, device and system and electronic equipment
CN111026634A (en) Interface automation test system, method, device and storage medium
CN113127108A (en) Service request processing method and device, storage medium and electronic equipment
CN108089972B (en) Interface test method and device
WO2019223136A1 (en) Data acquisition method and apparatus, and computer device and storage medium
CN110990081A (en) Microservice registration and discovery method and device, storage medium and electronic equipment
CN111913764A (en) Service dependency analysis method, electronic device, and storage medium
CN113919948B (en) Data updating method and device, electronic equipment and storage medium
CN112671574B (en) Front-end and back-end joint debugging method and device, proxy equipment and storage medium
CN114328210A (en) Test method, test device and computer readable storage medium
CN107908565B (en) Test method and test equipment
CN106302011B (en) Multi-terminal-based test method and terminal
CN112506679A (en) RPC service calling method and equipment
CN115599677A (en) Paas cloud remote debugging method, device and equipment
CN111752559B (en) Front-end and back-end separation system, method, device and storage medium
CN111538606B (en) Method, device and equipment for testing simulation Dubbo interface
CN110327626B (en) Virtual server creation method and device

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
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20210316