[0033] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, the specific implementation manners of the present invention will now be described in detail with reference to the accompanying drawings.
[0034] refer to figure 1 , is a schematic diagram of the structure of the remote object calling system of the present invention.
[0035] A remote object invocation system generally includes a client and a server. Usually, when a client accesses a business service on the server, a service interface needs to be defined for this business development. However, in a complex system, many business service modules are often involved, so , each time a business service is added, a new service interface needs to be defined, which requires maintenance of a large number of business service interfaces, which is extremely inconvenient for system expansion and maintenance.
[0036] In order to solve the above problems, the present invention defines a unified service interface on the server side, so as to uniformly process calls from clients to business services. Specifically, after the client uploads corresponding invocation information according to the service object to be invoked, the unified service interface instantiates each received invocation information to obtain the corresponding service object.
[0037] Further, in order to solve the problems of cross-platform call obstruction and low transmission efficiency in the prior art, the client and the server communicate through RPC communication middleware in the present invention. Preferably, ICE middleware can be specifically used.
[0038] ICE is an open source, cross-platform, cross-language high-performance RPC communication middleware, which supports mainstream development languages C++, Java, C#, PHP, Python, android, iOS and other mobile development languages, and supports Window, Linux, Unix and other operating system platforms; RPC is the basic function provided by ICE, which supports synchronous and asynchronous method calls, adopts binary communication protocol, data compression, and high transmission efficiency.
[0039] The implementation of the unified calling service of the present invention will be introduced in detail below.
[0040] Specifically, the definition of a unified service interface includes: defining a unified service interface function, the parameters of the function include: a string representing the service class name, method name and parameter type of the called service; a string representing the class method parameter ; a string representing the class constructor parameter; a string representing the method's return result.
[0041] For example, in a specific embodiment, the unified service interface is defined as follows:
[0042] bool RemoteObjectCall(string strClassFullName, string strMethodParam, string strInitParam, out string strOutResult);
[0043] Regarding the parameter description in the above RemoteObjectCall function:
[0044] (a) strClassFullName: specifies the parameters of the service class name, method name and parameter type"
[0045] (b) strMethodParam: class method parameter string;
[0046] (c) strInitParam: class constructor parameter string;
[0047] (d) strOutResult: The method returns the result string.
[0048] Specifically, the uploading of the corresponding call information includes: the client uploads the call information through a call function, the parameters of the call function represent the call information, and the parameters of the call function include: the service class name of the called service, the method Parameters with names and parameter types; strings representing class method parameters; and strings representing method return results.
[0049] For example, in a specific embodiment, the calling function is as follows:
[0050]RPCProxyer.CallObject("class.method(string,int,…)",stringmethodparam,out string strOutResult);
[0051] RPCProxyer represents the API installed on the client. CallObject is the calling function. The first parameter includes the service class name, method name and parameter type of the called service. The value of this part of the parameter will be assigned to the first RemoteObjectCall above. The parameter strClassFullName; the second parameter represents the method parameter, and the value of this part of the parameter will be assigned to the second parameter strMethodParam of the above-mentioned RemoteObjectCall; the third parameter strInitParam of RemoteObjectCall is the default value; the value of the fourth parameter strOutResult of RemoteObjectCall will be Assigned to the third parameter strOutResult of CallObject.
[0052] Specifically, the unified service interface includes the following units:
[0053] The parameter parsing unit is used to obtain the calling information from the relevant parameters of the calling function of the client, and parse out the service class name, method name and parameter type from the calling information; for example, parse from the strClassFullName string in the above-mentioned RemoteObjectCall function Display the service class name, method name and parameter type.
[0054] The assembly object determination unit is used to use the reflection mechanism to locate the assembly object where the service class is located according to the name of the service class;
[0055] A class instance object creation unit, which is used to dynamically create class instance objects by using assembly objects;
[0056] The instance method calling unit is used to obtain the instance method according to the method name of the service class, and call the instance method;
[0057] The result return unit is used to assign the return result strOutResult of the method call to the related parameter strOutResult of the calling function to return to the client. The method here returns the result strOutResult in the form of a string, which can be in formats such as XML and JSon.
[0058] Correspondingly, the present invention also discloses a method for invoking a remote object, comprising the following steps:
[0059] S1. Define a unified service interface on the server side, including: define a unified service interface function, the parameters of the function include: a string representing the service class name, method name and parameter type of the called service; a string representing the class method parameter ; a string representing the class constructor parameter; a string representing the method's return result.
[0060] For example, in a specific embodiment, the unified service interface is defined as follows:
[0061] bool RemoteObjectCall(string strClassFullName, string strMethodParam, string strInitParam, out string strOutResult);
[0062] Regarding the parameter description in the above RemoteObjectCall function:
[0063] (a) strClassFullName: specifies the parameters of the service class name, method name and parameter type"
[0064] (b) strMethodParam: class method parameter string;
[0065] (c) strInitParam: class constructor parameter string;
[0066] (d) strOutResult: The method returns the result string.
[0067] S2. The client uploads the corresponding call information according to the service object to be called, including: the client uploads the call information through a call function, and the parameters of the call function include: the service class name, method name and parameter type of the called service Parameters; a string representing the class method's parameters; and a string representing the method's return result.
[0068] For example, in a specific embodiment, the calling function is as follows:
[0069] RPCProxyer.CallObject("class.method(string,int,…)",stringmethodparam,out string strOutResult);
[0070] RPCProxyer represents the API installed on the client. CallObject is the calling function. The first parameter includes the service class name, method name and parameter type of the called service. The value of this part of the parameter will be assigned to the first RemoteObjectCall above. The parameter strClassFullName; the second parameter represents the method parameter, and the value of this part of the parameter will be assigned to the second parameter strMethodParam of the above-mentioned RemoteObjectCall; the third parameter strInitParam of RemoteObjectCall is the default value; the value of the fourth parameter strOutResult of RemoteObjectCall will be Assigned to the third parameter strOutResult of CallObject.
[0071] S3. The unified service interface instantiates the corresponding service object for each received call information, specifically including:
[0072] S31. Obtain call information from the relevant parameters of the call function of the client, and parse out the service class name, method name and parameter type from the call information; for example, parse out the service class name from the strClassFullName string in the above-mentioned RemoteObjectCall function , method name and parameter type;
[0073] S32. Use the reflection mechanism to locate the assembly object where the service class is located according to the service class name;
[0074] S33. Using the assembly object to dynamically create a class instance object;
[0075] S34. Obtain an instance method according to the method name of the service class, and call the instance method;
[0076] S35. Assign the return result strOutResult of the method call to the related parameter strOutResult of the calling function to return to the client. The method here returns the result strOutResult in the form of a string, which can be in formats such as XML and JSon.
[0077] Further, in order to solve the problems of cross-platform call obstruction and low transmission efficiency in the prior art, the client and the server communicate through RPC communication middleware in the present invention. Preferably, ICE middleware can be specifically used.
[0078] ICE is an open source, cross-platform, cross-language high-performance RPC communication middleware, which supports mainstream development languages C++, Java, C#, PHP, Python, android, iOS and other mobile development languages, and supports Window, Linux, Unix and other operating system platforms; RPC is the basic function provided by ICE, which supports synchronous and asynchronous method calls, adopts binary communication protocol, data compression, and high transmission efficiency.
[0079] In summary, implementing the remote object calling method and system of the present invention has the following beneficial effects: the present invention defines a unified service interface on the server side, and the unified service interface instantiates the corresponding service object for each received calling information , that is, all business services provide external access through the unified service interface. To expand new business services, it is only necessary to implement specific business services. There is no need to define interfaces for new business services. The system is flexible and convenient to expand and easy to maintain; Further, in the present invention, the client and the server communicate through RPC communication middleware, support multiple common development languages and operating system platforms; support synchronous and asynchronous method calls, adopt binary communication protocol, data compression, and high transmission efficiency .
[0080] Embodiments of the present invention have been described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementations, and the above-mentioned specific implementations are only illustrative, rather than restrictive, and those of ordinary skill in the art will Under the enlightenment of the present invention, many forms can also be made without departing from the gist of the present invention and the protection scope of the claims, and these all belong to the protection of the present invention.