CN109922148B - Cross-platform service method, device and system - Google Patents

Cross-platform service method, device and system Download PDF

Info

Publication number
CN109922148B
CN109922148B CN201910161663.4A CN201910161663A CN109922148B CN 109922148 B CN109922148 B CN 109922148B CN 201910161663 A CN201910161663 A CN 201910161663A CN 109922148 B CN109922148 B CN 109922148B
Authority
CN
China
Prior art keywords
service
communication protocol
preset communication
server
target server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910161663.4A
Other languages
Chinese (zh)
Other versions
CN109922148A (en
Inventor
徐海涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201910161663.4A priority Critical patent/CN109922148B/en
Publication of CN109922148A publication Critical patent/CN109922148A/en
Application granted granted Critical
Publication of CN109922148B publication Critical patent/CN109922148B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a cross-platform service method, a device and a system. Wherein, the method comprises the following steps: acquiring a service routing table corresponding to the service request; determining a target server according to the service routing table; and sending a service request to the target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be recognized by the target server. The invention solves the technical problem that cross-language service cannot be carried out between the existing enterprise service devices.

Description

Cross-platform service method, device and system
Technical Field
The invention relates to the field of internet, in particular to a cross-platform service method, a device and a system.
Background
With the rapid development of internet technology, especially the popularization of smart phones, the communication demands between terminal devices increase, the communication services of internet companies are expanding due to the increase and iteration of communication demands and the increase of user volume. The traditional monolithic architecture communication mode has been unable to adapt to the rapid change of the internet era, and therefore, the internet companies are faced with more and more challenges. For example, as code libraries expand, code maintainability and flexibility decrease, and test costs and online update costs increase significantly. Also, as the number of users increases, internet companies face problems of how to improve the response between communication devices and how to efficiently store large data after the increase in the number of users.
In view of the above problems, many internet companies solve the above problems by upgrading their own software Architecture and splitting the services, for example, splitting the Service Architecture into an SOA (Service-Oriented Architecture) or microservice Architecture mode. The industry now has a micro-service open source framework oriented to various development languages, which can be directly used, such as dubbo oriented to java, spring child and the like.
However, in the existing enterprise service technology, cross-language services cannot be realized, and the existing enterprise service equipment supports more functions and is not simplified enough, which results in higher customization cost of the enterprise service equipment.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a cross-platform service method, a device and a system, which at least solve the technical problem that cross-language service cannot be carried out among the existing enterprise service devices.
According to an aspect of an embodiment of the present invention, there is provided a cross-platform service method, including: acquiring a service routing table corresponding to the service request; determining a target server according to the service routing table; sending a service request to a target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be recognized by the target server
Further, the format of the fields contained in the preset communication protocol is the JSON format.
Further, the cross-platform service method further comprises the following steps: acquiring service information of a server cluster from a registration center, wherein a target server is a server in the server cluster; generating a service routing table of each service according to the service information; and determining a service routing table corresponding to the service request from the service routing table of each service.
Further, the cross-platform service method further comprises the following steps: determining a target server by any one of the following methods: sequencing the servers in the service routing table, and determining a target server according to a sequencing result in a polling mode; or, randomly selecting a server from the service routing table as a target server; or, based on the weight value of each server determined in the service routing table, determining the target server according to the weight value of each server.
Further, the preset communication protocol includes at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following components: the service number, the second preset communication protocol at least includes: a service path.
Further, the cross-platform service method further comprises the following steps: determining a service instance corresponding to the service request from a service routing table based on a service number in a first preset communication protocol; acquiring a target server corresponding to a service instance; and sending a service request to the target server through a first preset communication protocol.
Further, the cross-platform service method further comprises the following steps: determining a service instance corresponding to the service request from a service routing table based on a service path in a second preset communication protocol; acquiring a target server corresponding to a service instance; and sending a service request to the target server through a second preset communication protocol.
According to another aspect of the embodiments of the present invention, there is also provided a cross-platform service method, including: registering the service information of each server to a registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry; the method comprises the steps of determining data corresponding to a service request under the condition that the service request sent by an application terminal where the service application is located is received, wherein the application terminal sends the service request based on a preset communication protocol, and the preset communication protocol is used for converting the service request into a language which can be identified by a target server.
Further, the cross-platform service method further comprises the following steps: analyzing the service request to obtain an analysis result; and obtaining the service instance requested by the application terminal according to the analysis result, wherein the data corresponding to the service request at least comprises the service instance.
Further, the cross-platform service method further comprises the following steps: constructing a response packet according to the service instance; and sending the response packet to the application terminal so that the application terminal calls the data.
According to another aspect of the embodiments of the present invention, there is also provided a cross-platform service system, including: the server cluster is used for registering the service information of each server to the registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry; and the application terminal is used for acquiring a service routing table corresponding to the service request from the registration center, then determining a target server in the server cluster according to the service routing table, and sending the service request to the target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be identified by the target server.
Further, the cross-platform service system further comprises: and the gateway equipment is connected with the application terminals and is used for receiving the service requests sent by the plurality of application terminals and acquiring the data requested by each service request from the target server according to the service requests.
According to another aspect of the embodiments of the present invention, there is also provided a cross-platform service device, including: the acquisition module is used for acquiring a service routing table corresponding to the service request; the first determining module is used for determining a target server according to the service routing table; the first sending module is used for sending the service request to the target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be recognized by the target server.
According to another aspect of the embodiments of the present invention, there is also provided a cross-platform service device, including: the registration module is used for registering the service information of each server to a registration center based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be identified by the registration center; the second determining module is used for determining data corresponding to the service request under the condition of receiving the service request sent by the terminal where the service application is located, wherein the terminal where the service application is located sends the service request based on a preset communication protocol, and the preset communication protocol is used for converting the service request into a language which can be identified by a target server; and the second sending module is used for sending the data corresponding to the service request to the terminal where the service application is located.
According to another aspect of the embodiments of the present invention, there is also provided a storage medium including a stored program, wherein the program executes a cross-platform service method.
According to another aspect of the embodiments of the present invention, there is also provided a processor for executing a program, wherein the program executes a cross-platform service method.
In the embodiment of the invention, a communication protocol is rewritten, a server cluster registers service information of each server to a registration center based on a service registration protocol, an application terminal acquires a service routing table corresponding to a service request from the registration center, then determines a target server in the server cluster according to the service routing table, and sends the service request to the target server based on a preset communication protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registration center, and the preset communication protocol is used for converting the service request into a language which can be recognized by the target server. In the process, the service information of each server in the server cluster is converted into the language which can be identified by the registration center, and the registration of the servers can be realized by the registration center, so that the registration among the cross-language platforms is realized. In addition, the service request sent by the application terminal is converted into the language which can be identified by the target server in the process, so that the target server can determine the service requested by the application terminal, and further send the data of the service requested by the application terminal to the application terminal, and communication between cross-language platforms is realized.
Therefore, the technical problem that cross-language service cannot be carried out among the existing enterprise service devices can be solved through the scheme provided by the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic structural diagram of a cross-platform service system according to an embodiment of the present invention;
FIG. 2 is an interaction diagram of an alternative cross-platform service system according to an embodiment of the invention;
FIG. 3 is a schematic diagram of an alternative registry logical data structure according to an embodiment of the present invention;
FIG. 4 is an interaction diagram of an alternative cross-platform service system according to an embodiment of the invention;
FIG. 5 is a block diagram of an alternative cross-platform service system according to an embodiment of the invention;
FIG. 6 is a flow diagram of a cross-platform service method according to an embodiment of the invention;
FIG. 7 is a flow diagram of a cross-platform service method according to an embodiment of the invention;
FIG. 8 is a schematic structural diagram of a cross-platform service device according to an embodiment of the present invention; and
fig. 9 is a schematic structural diagram of a cross-platform service device according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, 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 only a part of the embodiments of the present invention, and not all of the embodiments. 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.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above 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 capable of operation in sequences other than those illustrated or 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.
Example 1
According to an embodiment of the present invention, an embodiment of a cross-platform service system is provided, where the system can execute a cross-platform service method provided by the present application, where fig. 1 is a schematic structural diagram of the cross-platform service system according to the embodiment of the present invention, and as shown in fig. 1, the system includes: a server cluster 101, application terminals 103 and a registry 105.
The server cluster is used for registering the service information of each server to the registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry; and the application terminal is used for acquiring a service routing table corresponding to the service request from the registration center, then determining a target server in the server cluster according to the service routing table, and sending the service request to the target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be identified by the target server.
It should be noted that the registry is used for registering service information of the management server, and is one of important components of a service architecture; the server in the server cluster is used for providing instance application of the service; the application terminal may be an application of a consumption server, wherein the application terminal may initiate a service request and pull information provided by the server from a registry.
In addition, it should be noted that, in the framework of the cross-language service, the languages used by the registry and the server providing the service may be different, and the languages used by the server providing the service and the application terminal consuming the service may also be different, and the service registration protocol may convert the service information into the language that can be recognized by the registry, and the preset communication protocol is used for converting the service request into the language that can be recognized by the target server, so that cross-language registration between the registry and the server providing the service, and cross-language communication between the server providing the service and the application terminal consuming the service are realized.
As can be seen from the above, in a manner of rewriting the communication protocol, the server cluster registers the service information of each server in the registry based on the service registration protocol, and the application terminal obtains the service routing table corresponding to the service request from the registry, then determines the target server in the server cluster according to the service routing table, and sends the service request to the target server based on the preset communication protocol, where the service registration protocol is used to convert the service information into a language that can be recognized by the registry, and the preset communication protocol is used to convert the service request into a language that can be recognized by the target server.
It is easy to note that, by converting the service information of each server in the server cluster into a language that can be recognized by the registry, the registry can realize the registration of the servers, thereby realizing the registration between the cross-language platforms. In addition, the service request sent by the application terminal is converted into the language which can be identified by the target server in the process, so that the target server can determine the service requested by the application terminal, and further send the data of the service requested by the application terminal to the application terminal, and communication between cross-language platforms is realized.
Therefore, the technical problem that cross-language service cannot be carried out among the existing enterprise service devices can be solved through the scheme provided by the application.
In an alternative scheme, the server cluster registers the service information of each server to the registry based on a service registration protocol, wherein the interaction process between the server cluster and the registry is as shown in fig. 2. Specifically, the server cluster sets a communication protocol (i.e., a preset communication protocol) for providing a service, where the communication protocol may be an HTTP protocol or a TCP protocol. The server cluster then binds the address and port of the service and registers the service information to the registry via a service registration protocol. After the registration of the service information is completed, the server cluster can provide the service to the application terminal.
It should be noted that, in the interaction process shown in fig. 2, the service registration protocol is used to complete the registration of the service information of each server in the registry, and the problems that the existing cross-language service framework has a lot of functions, is not simplified, and cannot perform cross-language service can be solved. The service registration protocol adopts a JSON (JavaScript Object Notation) format, which is a lightweight data exchange format, and in the JS language, any supported type can be represented by the JSON format.
Alternatively, the main data structure of the service registration protocol may be as shown in table 1.
TABLE 1
Field(s) Type (B) Means of Must pass
protocol str Communication protocol Is that
sid str Service number Is that
name str Service name Is that
host str Service binding address Is that
port Int Service binding port Is that
status int Service status Is that
weight int Service weight Is that
In table 1, a protocol field is a communication protocol for the server cluster to perform communication, and a protocol included in the protocol field in the present application may be a preset communication protocol. In addition, the service state of the status field is a state whether the server can perform communication, and optionally, when the content of the status field is "1", the server is in an enabled state; when the content of the status field is "2", the server is in a disabled state.
Alternatively, the service registration protocol may be applied to most servers that can serve as a registry, in fig. 3, a zookeeper (a distributed application coordination service) node is a registry. Specifically, the server providing the service registers its own service information to the registry at startup, and after that, the logical data structure of the registry is as shown in fig. 3. Fig. 3 shows that there are 2 server nodes for the y-ms-registration/Services/1 service, and the registration information is in JSON format.
It should be noted that, since some characters in the service information are special characters in the zookeeper node, the registry may not be able to correctly resolve the characters, and therefore, before the server registers the service information in the registry, the server encodes the service information in a URL, that is, a URLEncoder is performed.
In addition, it should be noted that the server providing the service may also monitor the connection between the server and the registration center, and in case of an abnormal connection between the server and the registration center, the server re-registers the connection.
Further, after the registration of the service information in the registry is completed, the application terminal may request the service from the server, wherein an interaction process between the application terminal, the registry and the server cluster providing the service is as shown in fig. 4. Specifically, the application terminal acquires service information from the registry, generates a service routing table of each server according to the service information, determines a target server providing a service from the service routing table, and sends a service request to the target server based on a preset communication protocol.
Optionally, the application terminal may determine the target server by any one of the following manners:
the first method is as follows: and sequencing the servers in the service routing table, and determining a target server according to a sequencing result in a polling mode. For example, if the service routing table includes three servers A, B and C, the application terminal sequentially determines the target server in a loop according to the sequence A, B and C.
The second method comprises the following steps: and randomly selecting a server from the service routing table as a target server.
The third method comprises the following steps: based on the weight value of each server determined in the service routing table, a target server is determined according to the weight value of each server, for example, a server with the largest weight value is preferentially selected as the target server.
After determining the target server, the application terminal may send a service request to the target server through a preset communication protocol, where the preset communication protocol includes at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following components: the service number, the second preset communication protocol at least includes: a service path.
In an alternative, the first predetermined communication protocol is a TCP-based private communication protocol, wherein a data structure of the first predetermined communication protocol is shown in table 2.
TABLE 2
Field(s) Type (B) Means of Must pass
frameType byte Type of packet Is that
sid str Service number Whether or not
mid int Method numbering Whether or not
body byte array Payload Whether or not
bodyType byte Type of load Whether or not
id long Unique label of bag Is that
In table 2, the frameType field indicates the type of the data packet, wherein when the content of the frameType field is "1", the type of the data packet is a request packet; when the content of the frameType field is '2', the type of the data packet is a response packet; when the content of the frameType field is '3', the types of the data packets are request packets and response packets; when the content of the frameType field is "4", the type of the data packet is a heartbeat packet. In addition, the body type field indicates the type of the payload, wherein when the body type field content is "1", the type of the payload is byte [ ]; when the body type field content is '2', the type of the effective load is str; when the body type field content is "3", the type of the payload is JSON.
Specifically, the application terminal constructs the data information shown in table 2, converts the data information into a JSON character string, searches a service instance (for example, a weather query instance) required to be provided by the server from the service routing table according to the sid field in table 2, and sends a data packet of the service request according to the address and the port of the service instance provided by the server and the first preset communication protocol.
Further, after receiving a data packet of the service request sent by the application terminal, the server parses the service request to obtain a parsing result, and obtains a service instance requested by the application terminal according to the parsing result, wherein data corresponding to the service request at least includes the service instance. Specifically, the server finds a corresponding service method from a local method mapping table of the server according to a mid field in the first preset communication protocol, invokes a corresponding processing logic, constructs a response packet according to the service instance, sends the response packet to the application terminal, and sends data corresponding to the service request in the case of receiving response data returned by the service application.
In addition, after the application terminal receives the response packet, the application terminal selects synchronous calling or asynchronous calling service according to the identification of the response packet.
In another alternative, the second preset communication protocol is an HTTP-based communication protocol. Since the forwarding of the HTTP protocol is based on a path in the URL, a service path field is included in the service registration protocol corresponding to the second preset communication protocol. Specifically, when a server providing a service registers service information in a registration center, a service path that can be provided by the server is added to a service registration protocol in the form of a prefix. For example, if the server provides two URL addresses, i.e.,/user/getById and/user/list, the server adds "URL _ tag ═ user" to the service registration protocol. And the application terminal can pull the service information from the registration center, namely at this time, the application terminal does not generate the service routing table according to the sid field, but generates the service routing table according to the url _ tag field. Further, after the application terminal sends the service request, for example, initiates a service request of "/user/getById", the application terminal determines that the prefix of the service request is "/user", thereby determining a server providing the service according to the prefix of the service request to complete the request processing.
It should be noted that, as can be seen from the above, the cross-platform service system provided in the present application can implement a cross-language service registration component, a service query component, and a service call component only according to a service registration protocol and a preset communication protocol, thereby completing cross-platform enterprise servitization.
It should be noted that, as shown in fig. 5, the cross-platform service system provided in the present application further includes a gateway device 107. The gateway device is connected with the application terminals and is used for receiving service requests sent by the application terminals and acquiring data requested by each service request from the target server according to the service requests.
Alternatively, the gateway device may act as a service consumer together with the application terminal, and all service requests of the application terminal are forwarded by the gateway device. The gateway device subscribes all services as a globally unique application terminal, and internal calling and external calling of the services need to pass through the gateway device, so that the purpose of simplifying a service calling process is achieved, the problem that a service calling link is complex when the number of the application terminals is large is solved, the service calling link is simple when the number of the application terminals is large, and cross-platform deployment is more convenient.
It should be noted that the application terminal may send the service request to the gateway device, and the gateway device generates a first preset communication protocol according to the service request, determines a target server providing the service, then obtains data in the target server based on the first preset communication protocol, and finally forwards the obtained data to the application terminal.
In addition, the application terminal can also generate a first preset communication protocol according to the service request and then send the first preset communication protocol to the gateway equipment. And then the gateway equipment directly acquires the data in the target server based on the first preset communication protocol, and finally forwards the acquired data to the application terminal.
Example 2
According to the embodiment of the present invention, an embodiment of a cross-platform service method is further provided, and it should be noted that the application terminal in embodiment 1 may be used as an execution subject of the embodiment. Fig. 6 is a flowchart of a cross-platform service method according to an embodiment of the present invention, and as shown in fig. 6, the method includes the following steps:
step S602, obtaining a service routing table corresponding to the service request;
step S604, determining a target server according to the service routing table;
step S606, sending a service request to the target server based on a preset communication protocol, where the preset communication protocol is used to convert the service request into a language that can be recognized by the target server.
It should be noted that the format of the fields included in the preset communication protocol is JSON format. In addition, the registry is used for registering the service information of the management server, and is one of important components of the service architecture, so that the application terminal can obtain the service information of a server cluster from the registry and generate a service routing table of each service according to the service information, wherein the target server is a server in the server cluster. And before acquiring the service information of the server cluster from the registry, the server cluster registers the service information of each server to the registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry.
In addition, it should be noted that, in the framework of the cross-language service, the languages used by the registry and the server providing the service may be different, and the languages used by the server providing the service and the application terminal consuming the service may also be different, and the service registration protocol may convert the service information into the language that can be recognized by the registry, and the preset communication protocol is used for converting the service request into the language that can be recognized by the target server, so that cross-language registration between the registry and the server providing the service, and cross-language communication between the server providing the service and the application terminal consuming the service are realized.
Based on the schemes defined in steps S602 to S606, it can be known that, in a manner of rewriting the communication protocol, the server cluster registers the service information of each server in the registry based on the service registration protocol, the application terminal obtains the service routing table corresponding to the service request from the registry, then determines the target server in the server cluster according to the service routing table, and sends the service request to the target server based on the preset communication protocol, where the service registration protocol is used to convert the service information into a language that can be recognized by the registry, and the preset communication protocol is used to convert the service request into a language that can be recognized by the target server.
It is easy to note that, by converting the service information of each server in the server cluster into a language that can be recognized by the registry, the registry can realize the registration of the servers, thereby realizing the registration between the cross-language platforms. In addition, the service request sent by the application terminal is converted into the language which can be identified by the target server in the process, so that the target server can determine the service requested by the application terminal, and further send the data of the service requested by the application terminal to the application terminal, and communication between cross-language platforms is realized.
Therefore, the technical problem that cross-language service cannot be carried out among the existing enterprise service devices can be solved through the scheme provided by the application.
In an alternative scheme, the application terminal may determine the target server by any one of the following manners: sequencing the servers in the service routing table, and determining a target server according to a sequencing result in a polling mode, for example, if the service routing table comprises three servers A, B and C, the application terminal sequentially and circularly determines the target server according to the sequence of A, B and C; randomly selecting a server from the service routing table as a target server; based on the weight value of each server determined in the service routing table, a target server is determined according to the weight value of each server, for example, a server with the largest weight value is preferentially selected as the target server.
After determining the target server, the application terminal may send a service request to the target server through a preset communication protocol, where the preset communication protocol includes at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following components: the service number, the second preset communication protocol at least includes: a service path.
In an optional scheme, the first preset communication protocol is a TCP-based private communication protocol, and the application terminal determines a service instance corresponding to the service request from the service routing table based on a service number in the first preset communication protocol, acquires a target server corresponding to the service instance, and then sends the service request to the target server through the first preset communication protocol.
Specifically, the application terminal constructs the data information shown in table 2, converts the data information into a JSON character string, searches a service instance (for example, a weather query instance) required to be provided by the server from the service routing table according to the sid field in table 2, and sends a data packet of the service request according to the address and the port of the service instance provided by the server and the first preset communication protocol.
In another alternative, the second preset communication protocol is an HTTP-based communication protocol. The application terminal determines a service instance corresponding to the service request from the service routing table based on a service path in a second preset communication protocol, acquires a target server corresponding to the service instance, and then sends the service request to the target server through the second preset communication protocol.
Specifically, when a server providing a service registers service information in a registration center, a service path that can be provided by the server is added to a service registration protocol in the form of a prefix. For example, if the server provides two URL addresses, i.e.,/user/getById and/user/list, the server adds "URL _ tag ═ user" to the service registration protocol. And the application terminal can pull the service information from the registration center, namely at this time, the application terminal does not generate the service routing table according to the sid field, but generates the service routing table according to the url _ tag field. Further, after the application terminal sends the service request, for example, initiates a service request of "/user/getById", the application terminal determines that the prefix of the service request is "/user", thereby determining a server providing the service according to the prefix of the service request to complete the request processing.
It should be noted that, as can be seen from the above, the cross-platform service system provided in the present application can implement a cross-language service registration component, a service query component, and a service call component only according to a service registration protocol and a preset communication protocol, thereby completing cross-platform enterprise servitization.
Example 3
According to the embodiment of the present invention, an embodiment of a cross-platform service method is further provided, and it should be noted that the target server in embodiment 1 may be used as an execution subject in this embodiment. Fig. 7 is a flowchart of a cross-platform service method according to an embodiment of the present invention, and as shown in fig. 7, the method includes the following steps:
step S702, registering the service information of each server to a registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be identified by the registry;
step S704, determining data corresponding to a service request under the condition of receiving the service request sent by an application terminal where the service application is located, wherein the application terminal sends the service request based on a preset communication protocol, and the preset communication protocol is used for converting the service request into a language which can be identified by a target server;
step S706, sending the data corresponding to the service request to the application terminal.
It should be noted that, in the framework of the cross-language service, the languages used by the registry and the server providing the service may be different, and the languages used by the server providing the service and the application terminal consuming the service may also be different, and the service registration protocol may convert the service information into the language that can be recognized by the registry, and the preset communication protocol is used to convert the service request into the language that can be recognized by the target server, so that cross-language registration between the registry and the server providing the service, and cross-language communication between the server providing the service and the application terminal consuming the service are realized.
In addition, it should be noted that the application terminal may send the service request to the target server through a preset communication protocol, where the preset communication protocol includes at least one of the following: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following components: the service number, the second preset communication protocol at least includes: a service path.
In an optional scheme, the first preset communication protocol is a TCP-based private communication protocol, and the application terminal determines a service instance corresponding to the service request from the service routing table based on a service number in the first preset communication protocol, acquires a target server corresponding to the service instance, and then sends the service request to the target server through the first preset communication protocol.
In another alternative, the second preset communication protocol is an HTTP-based communication protocol. The application terminal determines a service instance corresponding to the service request from the service routing table based on a service path in a second preset communication protocol, acquires a target server corresponding to the service instance, and then sends the service request to the target server through the second preset communication protocol.
Based on the schemes defined in the foregoing steps S702 to S706, it can be known that, in a manner of rewriting the communication protocol, the server cluster registers the service information of each server in the registry based on the service registration protocol, the application terminal obtains the service routing table corresponding to the service request from the registry, then determines a target server in the server cluster according to the service routing table, and sends the service request to the target server based on the preset communication protocol, where the service registration protocol is used to convert the service information into a language that can be recognized by the registry, and the preset communication protocol is used to convert the service request into a language that can be recognized by the target server.
It is easy to note that, by converting the service information of each server in the server cluster into a language that can be recognized by the registry, the registry can realize the registration of the servers, thereby realizing the registration between the cross-language platforms. In addition, the service request sent by the application terminal is converted into the language which can be identified by the target server in the process, so that the target server can determine the service requested by the application terminal, and further send the data of the service requested by the application terminal to the application terminal, and communication between cross-language platforms is realized.
Therefore, the technical problem that cross-language service cannot be carried out among the existing enterprise service devices can be solved through the scheme provided by the application.
In an optional scheme, in the case of receiving a service request sent by an application terminal where a service application is located, a target server parses the service request to obtain a parsing result, and obtains a service instance requested by the application terminal according to the parsing result, where data corresponding to the service request at least includes the service instance. Specifically, the server finds a corresponding service method from a method mapping table local to the server according to a mid field in the first preset communication protocol, invokes a corresponding processing logic, constructs a response packet according to the service instance, and sends the response packet to the application terminal, so that the application terminal invokes data.
In addition, after the application terminal receives the response packet, the application terminal selects synchronous calling or asynchronous calling service according to the identification of the response packet.
It should be noted that, as can be seen from the above, the cross-platform service system provided in the present application can implement a cross-language service registration component, a service query component, and a service call component only according to a service registration protocol and a preset communication protocol, thereby completing cross-platform enterprise servitization.
Example 4
According to an embodiment of the present invention, an embodiment of a cross-platform service device is further provided, where it is to be noted that the device may execute the cross-platform service method provided in embodiment 2, where fig. 8 is a schematic structural diagram of the cross-platform service device according to the embodiment of the present invention, and as shown in fig. 8, the device includes: an acquisition module 801, a first determination module 803, and a first sending module 805.
The acquiring module 801 is configured to acquire a service routing table corresponding to the service request; a first determining module 803, configured to determine a target server according to the service routing table; the first sending module 805 is configured to send a service request to the target server based on a preset communication protocol, where the preset communication protocol is used to convert the service request into a language that can be recognized by the target server, and a format of a field included in the preset communication protocol is a JSON format.
It should be noted that the acquiring module 801, the first determining module 803, and the first sending module 805 correspond to steps S602 to S606 in embodiment 2, and the three modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure in embodiment 2.
In an optional aspect, the obtaining module includes: the device comprises a first obtaining module, a generating module and a second determining module. The first acquisition module is used for acquiring service information of a server cluster from a registration center, wherein a target server is a server in the server cluster; the generating module is used for generating a service routing table of each service according to the service information; and the second determining module is used for determining a service routing table corresponding to the service request from the service routing table of each service.
In an optional scheme, the first determining module is further configured to determine the target server by any one of: sequencing the servers in the service routing table, and determining a target server according to a sequencing result in a polling mode; or, randomly selecting a server from the service routing table as a target server; or, based on the weight value of each server determined in the service routing table, determining the target server according to the weight value of each server.
In an alternative, the preset communication protocol includes at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following components: the service number, the second preset communication protocol at least includes: a service path.
In an alternative, the first sending module includes: the device comprises a third determining module, a second obtaining module and a second sending module. The third determining module is configured to determine, based on the service number in the first preset communication protocol, a service instance corresponding to the service request from the service routing table; the second acquisition module is used for acquiring a target server corresponding to the service instance; and the second sending module is used for sending the service request to the target server through the first preset communication protocol.
In an alternative, the first sending module includes: the device comprises a fourth determining module, a third obtaining module and a third sending module. The fourth determining module is configured to determine, based on a service path in the second preset communication protocol, a service instance corresponding to the service request from the service routing table; the third acquisition module is used for acquiring a target server corresponding to the service instance; and the third sending module is used for sending the service request to the target server through a second preset communication protocol.
Example 5
According to an embodiment of the present invention, an embodiment of a cross-platform service device is further provided, where it is to be noted that the device may execute the cross-platform service method provided in embodiment 9, where fig. 9 is a schematic structural diagram of the cross-platform service device according to the embodiment of the present invention, and as shown in fig. 9, the device includes: a registration module 901, a second determination module 903, and a second sending module 905.
The registration module 901 is configured to register the service information of each server to the registry based on a service registration protocol, where the service registration protocol is used to convert the service information into a language that can be recognized by the registry; a second determining module 903, configured to determine, when a service request sent by a terminal where the service application is located is received, data corresponding to the service request, where the terminal where the service application is located sends the service request based on a preset communication protocol, and the preset communication protocol is used to convert the service request into a language that can be recognized by a target server; a second sending module 905, configured to send data corresponding to the service request to a terminal where the service application is located.
It should be noted that the registration module 901, the second determination module 903, and the second sending module 905 correspond to steps S702 to S706 in embodiment 3, and the three modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure in embodiment 3.
In an alternative, the second determining module includes: the device comprises an analysis module and a processing module. The analysis module is used for analyzing the service request to obtain an analysis result; and the processing module is used for obtaining the service instance requested by the application terminal according to the analysis result, wherein the data corresponding to the service request at least comprises the service instance.
In an optional scheme, the second sending module includes: the device comprises a construction module, a third sending module and a fourth sending module. The construction module is used for constructing a response packet according to the service instance; and the third sending module is used for sending the response packet to the application terminal so as to enable the application terminal to call the data.
Example 6
According to another aspect of the embodiments of the present invention, there is also provided a storage medium including a stored program, wherein the program executes the cross-platform service method provided by the above-described embodiments.
Example 7
According to another aspect of the embodiments of the present invention, a processor is further provided, where the processor is configured to execute a program, where the program executes the cross-platform service method provided by the foregoing embodiments.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components 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, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (15)

1. A cross-platform service method, comprising:
acquiring a service routing table corresponding to the service request;
determining a target server according to the service routing table;
sending the service request to the target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be recognized by the target server;
the target server registers service information to a registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry;
before the service information is registered to the registration center, the service information is coded by a Uniform Resource Locator (URL);
wherein the preset communication protocol comprises at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following steps: the service number, the second preset communication protocol at least includes: and the first preset communication protocol is a TCP-based private communication protocol, and the second preset communication protocol is an HTTP-based communication protocol.
2. The method according to claim 1, wherein the format of the default communication protocol containing field is JSON format.
3. The method of claim 1, wherein obtaining a service routing table corresponding to the service request comprises:
acquiring service information of a server cluster from a registration center, wherein the target server is a server in the server cluster;
generating a service routing table of each service according to the service information;
and determining a service routing table corresponding to the service request from the service routing table of each service.
4. The method of claim 1, wherein determining a destination server from the service routing table comprises:
determining the target server by any one of the following methods:
sequencing the servers in the service routing table, and determining the target server according to the sequencing result in a polling mode; alternatively, the first and second electrodes may be,
randomly selecting a server from the service routing table as the target server; alternatively, the first and second electrodes may be,
and determining the target server according to the weight value of each server based on the weight value of each server determined in the service routing table.
5. The method of claim 1, wherein sending the service request to the target server based on a predetermined communication protocol comprises:
determining a service instance corresponding to the service request from the service routing table based on the service number in the first preset communication protocol;
acquiring a target server corresponding to the service instance;
and sending the service request to the target server through the first preset communication protocol.
6. The method of claim 1, wherein sending the service request to the target server based on a predetermined communication protocol comprises:
determining a service instance corresponding to the service request from the service routing table based on a service path in the second preset communication protocol;
acquiring a target server corresponding to the service instance;
and sending the service request to the target server through the second preset communication protocol.
7. A cross-platform service method, comprising:
registering the service information of each server to a registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry;
determining data corresponding to a service request under the condition of receiving the service request sent by an application terminal where the service application is located, wherein the application terminal sends the service request based on a preset communication protocol, and the preset communication protocol is used for converting the service request into a language which can be identified by a target server;
sending data corresponding to the service request to the application terminal;
before the service information is registered to the registration center, the service information is coded by a Uniform Resource Locator (URL);
wherein the preset communication protocol comprises at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following steps: the service number, the second preset communication protocol at least includes: and the first preset communication protocol is a TCP-based private communication protocol, and the second preset communication protocol is an HTTP-based communication protocol.
8. The method of claim 7, wherein determining the data corresponding to the service request comprises:
analyzing the service request to obtain an analysis result;
and obtaining a service instance requested by the application terminal according to the analysis result, wherein the data corresponding to the service request at least comprises the service instance.
9. The method of claim 8, wherein sending data corresponding to the service request to the application terminal comprises:
constructing a response packet according to the service instance;
and sending the response packet to the application terminal so that the application terminal calls the data.
10. A cross-platform service system, comprising:
the server cluster is used for registering the service information of each server to a registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry;
the application terminal is used for acquiring a service routing table corresponding to a service request from the registration center, then determining a target server in the server cluster according to the service routing table, and sending the service request to the target server based on a preset communication protocol, wherein the preset communication protocol is used for converting the service request into a language which can be identified by the target server;
before the service information is registered in the registration center, the server cluster encodes the service information by using a Uniform Resource Locator (URL);
wherein the preset communication protocol comprises at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following steps: the service number, the second preset communication protocol at least includes: and the first preset communication protocol is a TCP-based private communication protocol, and the second preset communication protocol is an HTTP-based communication protocol.
11. The system of claim 10, further comprising:
and the gateway equipment is connected with the application terminals and is used for receiving the service requests sent by the application terminals and acquiring the data requested by each service request from the target server according to the service requests.
12. A cross-platform service apparatus, comprising:
the acquisition module is used for acquiring a service routing table corresponding to the service request;
the first determining module is used for determining a target server according to the service routing table;
a first sending module, configured to send the service request to the target server based on a preset communication protocol, where the preset communication protocol is used to convert the service request into a language recognizable by the target server;
the target server registers service information to a registry based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registry;
the cross-platform service device is further used for encoding the service information by using a Uniform Resource Locator (URL) before the service information is registered to the registration center;
wherein the preset communication protocol comprises at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following steps: the service number, the second preset communication protocol at least includes: and the first preset communication protocol is a TCP-based private communication protocol, and the second preset communication protocol is an HTTP-based communication protocol.
13. A cross-platform service apparatus, comprising:
the registration module is used for registering the service information of each server to a registration center based on a service registration protocol, wherein the service registration protocol is used for converting the service information into a language which can be recognized by the registration center;
the second determining module is used for determining data corresponding to a service request under the condition that the service request sent by a terminal where the service application is located is received, wherein the terminal where the service application is located sends the service request based on a preset communication protocol, and the preset communication protocol is used for converting the service request into a language which can be identified by a target server;
a second sending module, configured to send data corresponding to the service request to a terminal where the service application is located;
the cross-platform service device is further used for encoding the service information by using a Uniform Resource Locator (URL) before the service information is registered to the registration center;
wherein the preset communication protocol comprises at least one of: the communication device comprises a first preset communication protocol and a second preset communication protocol, wherein the first preset communication protocol at least comprises the following steps: the service number, the second preset communication protocol at least includes: and the first preset communication protocol is a TCP-based private communication protocol, and the second preset communication protocol is an HTTP-based communication protocol.
14. A storage medium comprising a stored program, wherein the program performs the cross-platform service method of any one of claims 1 to 9.
15. A processor, configured to run a program, wherein the program when running performs the cross-platform service method of any one of claims 1 to 9.
CN201910161663.4A 2019-03-04 2019-03-04 Cross-platform service method, device and system Active CN109922148B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910161663.4A CN109922148B (en) 2019-03-04 2019-03-04 Cross-platform service method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910161663.4A CN109922148B (en) 2019-03-04 2019-03-04 Cross-platform service method, device and system

Publications (2)

Publication Number Publication Date
CN109922148A CN109922148A (en) 2019-06-21
CN109922148B true CN109922148B (en) 2022-02-25

Family

ID=66963185

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910161663.4A Active CN109922148B (en) 2019-03-04 2019-03-04 Cross-platform service method, device and system

Country Status (1)

Country Link
CN (1) CN109922148B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110661780A (en) * 2019-08-15 2020-01-07 西安雷迪信息技术有限公司 Wireless city data sharing method and system based on SAAS application
CN110955452B (en) * 2019-09-05 2021-03-05 华为技术有限公司 Non-invasive interaction method and electronic equipment
CN113839865B (en) * 2021-11-30 2022-03-01 北京鲸鲮信息系统技术有限公司 Management method and system for cross-domain call service

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262560A (en) * 2010-05-27 2011-11-30 阿里巴巴集团控股有限公司 Calling method, device and system for remote service
CN105117316A (en) * 2015-08-07 2015-12-02 北京思特奇信息技术股份有限公司 Automatic check and maintenance method and system for server
CN105515759A (en) * 2015-11-27 2016-04-20 国网信息通信产业集团有限公司 Micro service registration method and micro service registration system
CN106411933A (en) * 2016-11-15 2017-02-15 深圳市彬讯科技有限公司 Lightweight RPC framework capable of service management and language calling
CN106453288A (en) * 2016-09-29 2017-02-22 上海和付信息技术有限公司 Asynchronous mode supporting distributed micro service framework system and implementation method thereof
CN107911430A (en) * 2017-11-06 2018-04-13 上海电机学院 A kind of micro services infrastructure equipment
CN108255615A (en) * 2017-11-30 2018-07-06 平安科技(深圳)有限公司 Across language call method, server and storage medium
CN109246251A (en) * 2018-11-13 2019-01-18 杭州数梦工场科技有限公司 A kind of micro services call method, device, system, equipment and readable storage medium storing program for executing

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002060154A1 (en) * 2001-01-25 2002-08-01 Abaco Pr, Inc. System and method for remote communication transactions
CN102724327B (en) * 2012-06-29 2016-04-13 百度在线网络技术(北京)有限公司 For Real-time Network page browsing service provider system and the method for browser
US20150019621A1 (en) * 2013-07-10 2015-01-15 Afreey Inc. Cross-Platform System for Remote-Controlling Network Camera
CN108429808B (en) * 2018-03-13 2020-12-01 南京邮电大学 Method and system for cross-platform resource interaction of Internet of things

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262560A (en) * 2010-05-27 2011-11-30 阿里巴巴集团控股有限公司 Calling method, device and system for remote service
CN105117316A (en) * 2015-08-07 2015-12-02 北京思特奇信息技术股份有限公司 Automatic check and maintenance method and system for server
CN105515759A (en) * 2015-11-27 2016-04-20 国网信息通信产业集团有限公司 Micro service registration method and micro service registration system
CN106453288A (en) * 2016-09-29 2017-02-22 上海和付信息技术有限公司 Asynchronous mode supporting distributed micro service framework system and implementation method thereof
CN106411933A (en) * 2016-11-15 2017-02-15 深圳市彬讯科技有限公司 Lightweight RPC framework capable of service management and language calling
CN107911430A (en) * 2017-11-06 2018-04-13 上海电机学院 A kind of micro services infrastructure equipment
CN108255615A (en) * 2017-11-30 2018-07-06 平安科技(深圳)有限公司 Across language call method, server and storage medium
CN109246251A (en) * 2018-11-13 2019-01-18 杭州数梦工场科技有限公司 A kind of micro services call method, device, system, equipment and readable storage medium storing program for executing

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
【RPC专栏】从跨语言调用到dubbo2.js;公众号-芋道源码;《https://blog.csdn.net/github_38592071/article/details/103370806》;20180715;全文 *

Also Published As

Publication number Publication date
CN109922148A (en) 2019-06-21

Similar Documents

Publication Publication Date Title
CN109922148B (en) Cross-platform service method, device and system
CN106464564B (en) Method, system and the computer-readable medium for encapsulating and routing for network packet
JP4762658B2 (en) Method and apparatus for providing distributed SLF routing functionality in an internet multimedia subsystem (IMS) network
US9246819B1 (en) System and method for performing message-based load balancing
CN102571947B (en) Processing method proxy method, device and system
CN101848235B (en) Real-time multimedia data P2P transmission scheme for supporting NAT traversal
EP2765756A1 (en) Service configuration method and device
CN107463453B (en) Method, device, equipment and storage medium for communication between different applications of same terminal
CN110740187B (en) Method for realizing micro-service architecture
CN113810438A (en) Scheduling and requesting methods of service computing resources, node equipment and terminal
CN111131037A (en) Data transmission method, device, medium and electronic equipment based on virtual gateway
CN108319463A (en) A kind of application upgrade method, apparatus
CN105376225A (en) Software-as-a-service method and device
CN111683066A (en) Heterogeneous system integration method and device, computer equipment and storage medium
CN111988171A (en) Method, proxy server and system for calling SOAP Web service based on RESTful style request
WO2022179353A1 (en) Domain name resolution method and apparatus, and computer device
CN111245918A (en) Service request transmission method and device
CN107222365B (en) Data processing method and device and server
US9929951B1 (en) Techniques for using mappings to manage network traffic
CN108345508A (en) Interface calls test method and device
CN113709177B (en) Method for processing message and external call gateway
CN115225606A (en) Domain name access method and system of cross-network protocol of container cloud platform
CN114327823A (en) Method, system, terminal and storage medium for calling resources of micro-service cluster
CN114125024A (en) Audio transmission method, electronic device and readable storage medium
CN112217852A (en) Platform-as-a-service system and method based on workflow engine

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant