CN111064716B - Message conversion method, device, storage medium and server - Google Patents

Message conversion method, device, storage medium and server Download PDF

Info

Publication number
CN111064716B
CN111064716B CN201911235910.7A CN201911235910A CN111064716B CN 111064716 B CN111064716 B CN 111064716B CN 201911235910 A CN201911235910 A CN 201911235910A CN 111064716 B CN111064716 B CN 111064716B
Authority
CN
China
Prior art keywords
message
converted
protocol
target
conversion
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
CN201911235910.7A
Other languages
Chinese (zh)
Other versions
CN111064716A (en
Inventor
李杰铭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Mengma Electric Technology Co ltd
Original Assignee
Shenzhen Mengma Electric Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Mengma Electric Technology Co ltd filed Critical Shenzhen Mengma Electric Technology Co ltd
Priority to CN201911235910.7A priority Critical patent/CN111064716B/en
Publication of CN111064716A publication Critical patent/CN111064716A/en
Application granted granted Critical
Publication of CN111064716B publication Critical patent/CN111064716B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Communication Control (AREA)

Abstract

The present application relates to the field of message processing technologies, and in particular, to a message conversion method, an apparatus, a storage medium, and a server. The method comprises the following steps: determining a protocol type of a message to be converted, wherein the message to be converted comprises at least one field; determining a protocol type of a target message, wherein the target message comprises at least one field; searching a preset protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining a target protocol conversion path of the message to be converted; and converting the message to be converted into the target message according to the target protocol conversion path. By the method and the device, the target protocol conversion path of the message to be converted can be determined quickly and accurately, so that the message to be converted is converted into the target message under the target message protocol quickly and accurately.

Description

Message conversion method, device, storage medium and server
Technical Field
The present application relates to the field of message processing technologies, and in particular, to a message conversion method, an apparatus, a storage medium, and a server.
Background
With the development of the technology of the internet of things, a plurality of manufacturers participating in the production of the equipment of the internet of things exist, and different manufacturers of the internet of things do not have a uniform protocol standard. In the related art, when an application platform interfaces with a device, either the device vendor adjusts the message protocol supported by the device to fit the message protocol requirements of the application platform or the platform vendor adjusts the message protocol supported by the platform to fit the message protocol requirements of the device.
However, whichever method is adopted, the message to be converted cannot be quickly and accurately converted into the target message under the target message protocol according to the protocol type of the target message.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present application and therefore may include information that does not constitute prior art known to a person of ordinary skill in the art.
Disclosure of Invention
In view of this, embodiments of the present application provide a message conversion method, an apparatus, a storage medium, and a server, so as to solve the problem that, in the prior art, a message to be converted cannot be quickly and accurately converted into a target message under a target message protocol according to a protocol type of the target message.
In a first aspect of the embodiments of the present application, a method for message conversion is provided, where the method includes:
determining a protocol type of a message to be converted, wherein the message to be converted comprises at least one field;
determining a protocol type of a target message, wherein the target message comprises at least one field;
searching a preset protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining a target protocol conversion path of the message to be converted;
and converting the message to be converted into the target message according to the target protocol conversion path.
In some embodiments of the present application, the searching a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining the target protocol conversion path of the message to be converted includes:
when the target protocol conversion path of the message to be converted is found to be more than or equal to 2, counting the total conversion times of the message to be converted under each protocol conversion path;
and ranking the total conversion times according to the sequence from small to large, and taking the protocol conversion path with the first ranking as a target protocol conversion path of the message to be converted.
In some embodiments of the present application, when the target protocol conversion path of the message to be converted is found to be greater than or equal to 2, the method further includes:
ranking the total conversion times under each protocol conversion path according to the sequence from small to large, and determining a predetermined number of protocol conversion paths from small to large as alternative protocol conversion paths;
and randomly selecting one protocol conversion path from the alternative protocol conversion paths as a target protocol conversion path of the message to be converted.
In some embodiments of the present application, before the searching a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining the target protocol conversion path of the message to be converted, the method further includes:
checking the data type of each field in the message to be converted;
when the data types of the fields are in one-to-one correspondence with the data types of the preset fields, allowing the message to be converted to carry out protocol conversion; and
and when the data type of each field and the data type of each preset field have the data type which does not correspond to each other, converting the field which does not correspond to the data type into the field which corresponds to the data type.
In some embodiments of the present application, after converting, when there is a data type of each field and a data type of a predetermined field that do not correspond to a data type, a field of the non-corresponding data type into a field of a corresponding data type, the method further includes:
verifying the data type of the converted field;
and when the data type of the converted field is consistent with that of the preset field, allowing the message to be converted to carry out protocol conversion.
In some embodiments of the present application, after the converting the message to be converted into the target message according to the target protocol conversion path, the method further includes:
verifying the data type of each field in the message to be converted to obtain a verification result;
and when the verification result is that the data types of the converted fields in the message to be converted are consistent with the data types of the fields in the target message, outputting the result of the protocol conversion.
In some embodiments of the present application, the obtaining a target message protocol, wherein the target message protocol contains at least one field, comprises:
acquiring a protocol identifier of the target message;
and searching a preset protocol field configuration table according to the protocol identifier of the target message, and determining the field content contained in the target message.
In a second aspect of the embodiments of the present application, there is provided a message conversion apparatus, including:
the device comprises a first determining module, a second determining module and a sending module, wherein the first determining module is used for determining the protocol type of a message to be converted, and the message to be converted comprises at least one field;
a second determining module, configured to determine a protocol type of a target message, where the target message includes at least one field;
a conversion path determining module, configured to search a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determine a target protocol conversion path of the message to be converted;
and the conversion module is used for converting the message to be converted into the target message according to the target protocol conversion path.
In some embodiments of the present application, the second determining module includes:
the first acquiring subunit is used for acquiring the protocol identifier of the target message;
and the second acquisition subunit is used for searching a preset protocol field configuration table according to the protocol identifier of the target message and determining the field content contained in the target message.
In some embodiments of the present application, the conversion path determining module may include:
the first counting unit is used for counting the total conversion times of the message to be converted under each protocol conversion path when the target protocol conversion path of the message to be converted is found to be more than or equal to 2;
and the first selection unit is used for ranking the total conversion times in a sequence from small to large, and taking the protocol conversion path with the first ranking as a target protocol conversion path of the message to be converted.
In other embodiments of the present application, the conversion path determining module may include:
a second counting unit, configured to count total times of conversion of the message to be converted in each protocol conversion path when the target protocol conversion path of the message to be converted is found to be greater than or equal to 2;
the ranking unit is used for ranking the total conversion times under each protocol conversion path according to the sequence from small to large and determining a predetermined number of protocol conversion paths from small to large as alternative protocol conversion paths;
and the second selection unit randomly selects one protocol conversion path from the alternative protocol conversion paths as a target protocol conversion path of the message to be converted.
In a third aspect of the embodiments of the present application, a computer-readable storage medium is provided, which stores a message conversion program, and when the message conversion program is executed by a processor, the message conversion program implements the steps of the message conversion method as described above.
In a fourth aspect of the embodiments of the present application, there is provided a server, including a memory, a processor, and a message conversion program stored in the memory and executable on the processor, where the processor implements the steps of the message conversion method when executing the message conversion program.
Compared with the prior art, the embodiment of the application has the advantages that: the method comprises the steps of firstly determining the protocol type of a message to be converted and the protocol type of a target message; then, according to the protocol type of the message to be converted and the protocol type of the target message, searching a preset protocol conversion rule table, and determining a target protocol conversion path of the message to be converted; and finally, converting the message to be converted into the target message according to the target protocol conversion path. In the embodiment of the application, the protocol type of the target message and the protocol type of the message to be converted are analyzed, and the preset message protocol conversion rule table is searched, so that the target protocol conversion path of the message to be converted can be quickly determined. Therefore, the message to be converted can be quickly and accurately converted into the target message under the target message protocol.
Other features and advantages of the present application will be apparent from the following detailed description, or may be learned by practice of the application.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a diagram illustrating a system architecture to which a message transformation method is applied in one embodiment of the present application;
FIG. 2 is a detailed flowchart of a message conversion method according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating the step S220 according to an embodiment of the present application;
FIG. 4 is a detailed flowchart of S230 according to an embodiment of the present application;
fig. 5 is a diagram of a specific application scenario of a message conversion method in an embodiment of the present application;
FIG. 6 is another detailed flowchart of S230 in an embodiment of the present application;
FIG. 7 is a detailed flow chart of another message conversion method according to an embodiment of the present application;
FIG. 8 is a detailed flowchart of yet another message conversion method according to an embodiment of the present application;
FIG. 9 is a detailed flowchart of another message conversion method according to an embodiment of the present application;
FIG. 10 is a block diagram of a message conversion apparatus according to an embodiment of the present application;
fig. 11 is a schematic block diagram of a server in an embodiment of the present application.
Detailed Description
In order to make the objects, features and advantages of the present invention more apparent and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the embodiments described below are only a part of the embodiments of the present application, 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 application.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
In addition, in the description of the present application, the terms "first," "second," "third," and the like are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
Fig. 1 is a schematic diagram illustrating a system architecture of an exemplary application environment to which a message conversion method and apparatus, an image processing method and apparatus according to an embodiment of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation. For example, server 105 may be a server cluster comprised of multiple servers, or the like.
In a specific application embodiment of the present application, a user may send a JASON message conversion request to a server 105 by using a terminal device 101 (or terminal device 102 or 103), and after receiving the JASON message conversion request sent by the terminal device 101 (or terminal device 102 or 103), the server 105 first extracts a message to be converted and a protocol type thereof, and a target message and a protocol type thereof from the JASON message conversion request; then searching a preset protocol conversion rule table to determine a protocol conversion path for converting the message to be converted into a target message; and then, converting the message to be converted into a corresponding target message according to the protocol conversion path. Further, the server may send the target message to the terminal device 101 (which may also be the terminal device 102 or 103).
It should be noted that JSON (JavaScript Object Notation) is a lightweight data exchange format, which is based on a subset of JavaScript. JSON adopts a text format completely independent of language, does not carry any tags, but also uses a habit similar to that of the C language family, and is an ideal data exchange language due to the unique characteristics of JSON, which is easy for human reading and writing and easy for machine conversion and generation. For example, JSON may be used to transfer an array, an object, or even a complex object that includes both. In the embodiment of the present application, the message protocol may be described in a JASON format, for example, one message protocol may include one or more field types of an object, an array, a string, a number, and a boolean value in the JASON format.
It should be noted that the message conversion method provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the message protocol conversion apparatus is generally disposed in the server 105. However, in other embodiments of the present application, the terminal device may also have a similar function as the server, so as to execute the message conversion method provided by the embodiments of the present application.
According to the technical scheme of the embodiment of the application, the protocol type of the target message and the protocol type of the message to be converted are analyzed, the preset protocol conversion rule table is searched, the target protocol conversion path of the message to be converted can be rapidly and accurately determined, and the message to be converted is rapidly and accurately converted into the target message under the target protocol.
As shown in fig. 2, an embodiment of the present application provides an implementation flow diagram of a message protocol conversion method, where the method includes:
step S210, determining the protocol type of the message to be converted, wherein the message to be converted comprises at least one field;
step S220, determining the protocol type of a target message, wherein the target message comprises at least one field;
step S230, according to the protocol type of the message to be converted and the protocol type of the target message, searching a preset protocol conversion rule table, and determining a target protocol conversion path of the message to be converted;
step S240, converting the message to be converted into the target message according to the target protocol conversion path.
The above steps are explained in detail below.
In step S210, a protocol type of a message to be converted is determined, wherein the message to be converted includes at least one field.
It can be understood that the protocol type of the message to be converted may be any one of the existing Json format message protocol types, or may also be a message protocol type customized by a user or other message protocols, which is not particularly limited in this embodiment of the present application. The field is a variable representing the association with an object or class, and each field is composed of a plurality of data items of the same field type divided by a certain boundary. Wherein, one data item comprises a data type and data. And the data types comprise types of objects, arrays, numbers, character strings, Boolean values and the like. For example, when there are three messages to be converted A, B, C, the protocol type of the message a to be converted is a, and the message content of the message a to be converted includes 2 data types: an array and a string; the protocol type of the message B to be converted is B, and the message content of the message B to be converted comprises 3 data types: object, array, and boolean values; the protocol type of the message C to be converted is C, and the message content of the message C to be converted comprises 4 data types: objects, numbers, strings, and boolean values.
In an embodiment of the application, a user may input a message to be converted, which is desired to be converted, in an output window of a display interface of an electronic device, and a server may obtain a message conversion request of the user through a network and extract a protocol type and field contents of the message to be converted from the message conversion request.
The method has the advantages that the user can select the message to be converted automatically based on the actual situation of the user, so that the message conversion efficiency is improved, and the experience degree of the user is also improved.
In step S220, a protocol type of a target message is determined, wherein the target message comprises at least one field.
It can be understood that the protocol type of the target message may be any one of the existing Json format message protocol types, or a message protocol type customized by a user or other message protocols, which is not particularly limited in this embodiment of the present application.
Still as explained in the above example, the message a to be converted needs to be converted into the target message protocol D, and the target message under the target message protocol D includes 2 data types: object and boolean value. The message B to be converted needs to be converted into a target message protocol E, and the target message under the target message protocol E comprises 3 data types: object, array, and boolean. The message C to be converted needs to be converted into a target message protocol F, and the target message under the target message protocol F contains 4 data types: objects, numbers, strings, and boolean values.
As shown in fig. 3, in an embodiment of the present application, the step S220 specifically includes the following steps:
step S310, acquiring the protocol identification of the target message.
It will be appreciated that by assigning a unique protocol identifier to each message, the protocol type of the target message can be quickly determined among a large number of message protocols by looking for the protocol identifier corresponding to the target message. The protocol identification can be a digital identification, an alphabetic identification, a symbol identification, and also can be other identifications which can uniquely distinguish different message protocols. For example, when there are only three messages to be converted A, B, C, the protocol identifications of the messages to be converted A, B, C can be 001, 002, 003, respectively.
Step S320, according to the protocol identifier of the target message, searching a predetermined protocol field configuration table, and determining the field content included in the target message.
It can be understood that the predetermined protocol field configuration table may be uploaded by a user through a display interface output window of the electronic device, or may be stored in advance by the server. By looking up a predetermined protocol field configuration table, the contents of the fields contained in the target message can be determined.
For example, the protocol type of the target message is D, the protocol identifier is 004, and the target message contains 2 data types: objects and boolean values, data values are "{" name ": zhangsan", "age": 20"," height ": 180", "sex": male "}" and "false", respectively.
The method has the advantages that the server can conveniently and quickly determine the protocol type of the target message so as to perform message conversion, and the message conversion efficiency is improved.
In step S230, a predetermined protocol conversion rule table is searched according to the protocol type of the message to be converted and the protocol type of the target message, and a target protocol conversion path of the message to be converted is determined.
It is to be understood that the target protocol conversion path is for each message, and the protocol type of each message may be the same or different. Thus, under different message protocols, there is generally no need for conversion between messages of the same message protocol type, whereas there is a need for conversion between messages of different message protocol types. When converting between messages of different message protocol types, the conversion paths of the message protocols and the total number of conversions may be different. The target protocol conversion path may be a protocol conversion path with the shortest conversion time, or may be a protocol conversion path with the smallest total conversion times, or may be an ideal protocol conversion path under other preferential standards.
The predetermined protocol conversion rule table may be uploaded by a user through a display interface output window of the electronic device, or may be stored in advance by the server. Therefore, by looking up a predetermined protocol conversion rule table, a specific conversion path for converting the message to be converted into the target message under the target protocol can be determined.
As shown in fig. 4, in an embodiment of the present application, the step S230 specifically includes the following steps:
step S410, when the target protocol conversion paths of the message to be converted are found to be greater than or equal to 2, counting the total conversion times of the message to be converted under each protocol conversion path.
It can be understood that when only one target protocol conversion path of the message to be converted is found, the entry target protocol conversion path may be directly used for conversion. And when the target protocol conversion path of the message to be converted is found to be more than or equal to 2, the optimal target protocol conversion path needs to be selected. In this embodiment, the total number of times of conversion of the message to be converted in each conversion path may be counted, and then a suitable target protocol conversion path may be selected according to the number difference of the total number of times of conversion in each protocol conversion path.
Step S420, rank the total conversion times in the order from small to large, and use the first ranked protocol conversion path as the target protocol conversion path of the message to be converted.
It is understood that by ranking the total number of conversion under various protocol conversion paths, the conversion path with the minimum total number of protocol conversion, i.e., the first ranked protocol conversion path, can be obtained.
It should be noted that, when the number of protocol conversions is greater than or equal to 2 times, the output result of the previous conversion is the input result of the next conversion. Specifically, a protocol conversion path (S _1, S _2,. S _ n) for converting the message to be converted (message protocol a) into the target message (target message protocol B) may be searched from the existing message protocols, and the following constraints are satisfied:
the input protocol of S _1 is A;
the output protocol of S _2 is B;
the input protocol of S _ n is the same as the output protocol of S _ n-1.
Wherein, S _1, S _2 and S _ n are message nodes under each message protocol type.
It can be understood that the message to be converted can be converted into the target message under the target message protocol B by sequentially performing message protocol conversion through the message nodes S _1, S _2, and S _ N, that is, by performing message protocol conversion N times.
As shown in fig. 5, which is a specific application scenario diagram according to an embodiment of the present application, a message protocol type of a message to be converted is a, and a message protocol type of a target message is B. When a user wants to convert a message to be converted into a target message under a target message protocol B, a predetermined message protocol conversion rule table can be searched, and 2 protocol conversion paths can be found: the first protocol conversion path is to convert the protocol type A into the protocol type E, convert the protocol type E into the protocol type C, and finally convert the protocol type C into the protocol type B; the second protocol conversion path is to convert protocol type a to protocol type D, path S1, and then convert protocol type D to protocol type B, path S2. It will be appreciated that the first protocol conversion path requires 3 conversions, whereas the second protocol conversion path requires only 2 conversions. Therefore, the second protocol conversion path is the conversion path with the minimum total conversion times, and the protocol conversion path can be selected preferentially.
As shown in fig. 6, in another embodiment of the present application, step S230 specifically includes the following steps:
step S610, when the target protocol conversion paths of the message to be converted are found to be greater than or equal to 2, counting the total conversion times of the message to be converted in each protocol conversion path.
It can be understood that when only one target protocol conversion path of the message to be converted is found, the entry target protocol conversion path may be directly used for conversion. And when the target protocol conversion path of the message to be converted is found to be more than or equal to 2, the optimal target protocol conversion path needs to be selected. In this embodiment, the total number of times of conversion of the message to be converted in each conversion path may be counted, and then a suitable target protocol conversion path may be selected according to the number difference of the total number of times of conversion in each protocol conversion path.
Step S620, ranking the total conversion times under each protocol conversion path according to the sequence from small to large, and determining a predetermined number of protocol conversion paths from small to large as alternative protocol conversion paths.
It should be noted that, the protocol conversion paths with the predetermined number can be flexibly set according to the congestion degree of the network and the requirements of the user on the conversion rate, the accuracy and the like, generally, the more congested the network, the smaller the predetermined number; the higher the user's requirements on the conversion rate or accuracy, the smaller the predetermined number. For example, as shown in fig. 5, the message protocol type of the message to be converted is converted into the target message protocol type, and 2 protocol conversion paths are found, and both of the two protocol conversion paths may be used as the alternative protocol conversion paths.
Step S630, randomly selecting one protocol conversion path from the alternative protocol conversion paths as a target protocol conversion path of the message to be converted.
In an embodiment of the present application, before randomly selecting one protocol conversion path from the alternative protocol conversion paths, the method may further include:
firstly, a protocol conversion record of the message to be converted is obtained.
Secondly, extracting the converted protocol path from the protocol conversion record of the message to be converted.
It is understood that before a protocol conversion path is randomly selected from the alternative protocol conversion paths, one or more protocol conversion paths may have been selected from the alternative protocol conversion paths for conversion, but the conversion may not be successful due to network congestion and the like. At this time, the past protocol conversion condition of the message to be converted can be known by acquiring the protocol conversion record of the message to be converted and extracting the converted protocol path from the protocol conversion record of the message to be converted.
And finally, removing the converted protocol path from the alternative protocol conversion path.
It will be appreciated that the converted protocol paths generally have a lower probability of being converted again, and may be eliminated from the alternative protocol conversion paths at this time.
The method has the advantages that the alternative protocol conversion path is convenient to update in real time, and the selected protocol conversion path is ensured to meet the actual requirement.
As shown in fig. 7, in an embodiment of the present application, before step S230, the method further includes:
step S710, checking the data type of each field in the message to be converted;
step S720, when the data types of the fields are in one-to-one correspondence with the data types of the preset fields, allowing the message to be converted to carry out protocol conversion; and
step S730, when the data type of each field and the data type of each predetermined field have a data type that does not correspond to each other, converting the field of the data type that does not correspond to each other into a field replacement of the corresponding data type.
It can be understood that, by checking whether the data types of the fields in the message to be converted correspond to the data types of the predetermined fields one to one, it can be determined whether the message to be converted has the converted right. For example, a message a to be converted uploaded by a user contains 2 data types: an array and a string. The server checks whether the data type of each field in the received message A to be converted only contains 2 data types: an array and a string. If yes, opening the authority of the message to be converted for protocol conversion. If the server verifies that the data types of all the fields in the received message A to be converted are array and Boolean value, indicating that the data types which do not correspond to each other exist: a boolean value, in which case the field corresponding to the boolean value needs to be converted into a field in a string format.
This has the advantage that it can be ensured that the converted message is the message that the user currently needs to convert, thereby improving the pertinence of message protocol conversion.
As shown in fig. 8, in an embodiment of the present application, after step S730, the method further includes:
step S810, verifying the data type of the converted field;
step S820, when the data type of the converted field is consistent with the data type of the predetermined field, allowing the message to be converted to perform protocol conversion.
It can be understood that whether the converted field in the message to be converted is correct or not can be determined by checking whether the data type of the converted field corresponds to the data type of the predetermined field one to one. For example, a message a to be converted uploaded by a user contains 2 data types: an array and a string. The server checks whether the data type of each field in the received message A to be converted only contains 2 data types: an array and a string. If yes, the authority of the message to be converted for protocol conversion is opened, namely the conversion is successful.
This has the advantage that it can be ensured that the converted message is the message that the user currently needs to convert, thereby improving the pertinence of message protocol conversion.
In step S240, the message to be converted is converted into the target message according to the target protocol conversion path.
It is to be understood that, after determining the target protocol conversion path, the server may convert the message to be converted into the target message according to the target protocol conversion path.
In one embodiment of the present application, the field data type of each message may be the same or different. Thus, under different message protocols, fields of the same data type do not need to be converted, while fields of different data types do need to be converted. Therefore, after the target protocol conversion path is determined, the server can sequentially convert the data types of the fields in the message to be converted according to the target protocol conversion path, so as to convert the message to be converted into the target message.
For example, when the protocol type a of the message to be converted, the message to be converted includes 2 data types: array and string, which needs to be converted into the target message, protocol type D, and target message contains 2 data types: object and boolean value. At this time, a corresponding rule table for converting the array and the character string in the message to be converted into the specific data type in the target message respectively can be obtained according to the protocol type of the message to be converted and the protocol identifier of the target message. For example, the rule table may be: the array field in the message to be converted is converted into the object field in the target message, and the character string field in the message to be converted is converted into the Boolean value field in the target message.
As shown in fig. 9, in an embodiment of the present application, after step S240, the method further includes:
step S910, verifying the data type of each field in the message to be converted to obtain a verification result;
step S920, when the verification result is that the data type of each converted field in the message to be converted is consistent with the data type of each field in the target message, outputting the result of the protocol conversion.
It can be understood that after the conversion, whether the conversion is successful or not can be determined by checking the data type of each field in the converted message to be converted. And when the data type of each field in the converted message to be converted is consistent with the data type of each field in the target message, the conversion is successful, and the result of the protocol conversion at this time, namely the target message, can be output.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 10 shows a structure diagram of an embodiment of a message conversion apparatus according to an embodiment of the present application, which corresponds to a message conversion method according to the foregoing embodiment.
In an embodiment of the present application, the message protocol conversion apparatus includes:
a first determining module 1010, configured to determine a protocol type of a message to be converted, where the message to be converted includes at least one field;
a second determining module 1020, configured to determine a protocol type of a target message, where the target message includes at least one field;
a conversion path determining module 1030, configured to search a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determine a target protocol conversion path of the message to be converted;
the conversion module 1040 is configured to convert the message to be converted into the target message according to the target protocol conversion path.
In an embodiment of the present application, the second determining module 1020 may include:
the first acquiring subunit is used for acquiring the protocol identifier of the target message;
and the second acquisition subunit is used for searching a preset protocol field configuration table according to the protocol identifier of the target message and determining the field content contained in the target message.
In an embodiment of the present application, the conversion path determining module 1030 may include:
the first counting unit is used for counting the total conversion times of the message to be converted under each protocol conversion path when the target protocol conversion path of the message to be converted is found to be more than or equal to 2;
and the first selection unit is used for ranking the total conversion times in a sequence from small to large, and taking the protocol conversion path with the first ranking as a target protocol conversion path of the message to be converted.
In another embodiment of the present application, the conversion path determining module 1030 may include:
a second counting unit, configured to count total times of conversion of the message to be converted in each protocol conversion path when the target protocol conversion path of the message to be converted is found to be greater than or equal to 2;
the ranking unit is used for ranking the total conversion times under each protocol conversion path according to the sequence from small to large and determining a predetermined number of protocol conversion paths from small to large as alternative protocol conversion paths;
and the second selection unit randomly selects one protocol conversion path from the alternative protocol conversion paths as a target protocol conversion path of the message to be converted.
Compared with the prior art, the embodiment of the application has the advantages that: the method comprises the steps of firstly determining the protocol type of a message to be converted and the protocol type of a target message; then, according to the protocol type of the message to be converted and the protocol type of the target message, searching a preset protocol conversion rule table, and determining a target protocol conversion path of the message to be converted; and finally, converting the message to be converted into the target message according to the target protocol conversion path. In the embodiment of the application, the protocol type of the target message and the protocol type of the message to be converted are analyzed, and the preset message protocol conversion rule table is searched, so that the target protocol conversion path of the message to be converted can be quickly determined. Therefore, the message to be converted can be quickly and accurately converted into the target message under the target message protocol.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, modules and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Fig. 11 shows a schematic block diagram of a server provided in an embodiment of the present application, and for convenience of explanation, only a part related to the embodiment of the present application is shown.
As shown in fig. 11, the server 11 of this embodiment includes: a processor 110, a memory 111 and a computer program 112 stored in said memory 111 and executable on said processor 110. The processor 110 executes the computer program 112 to implement the steps in the above-mentioned message conversion method embodiments, such as the steps S210 to S240 shown in fig. 2. Alternatively, the processor 110, when executing the computer program 112, implements the functions of the modules/units in the above device embodiments, such as the functions of the modules 1010 to 1040 shown in fig. 10.
Illustratively, the computer program 112 may be partitioned into one or more modules/units that are stored in the memory 111 and executed by the processor 110 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 112 in the server 11.
The server 11 may be a server having a protocol conversion function. It will be appreciated by those skilled in the art that the server 11 is merely an example of the server 11 and does not constitute a limitation of the server 11 and may include more or less components than those shown, or some components in combination, or different components, e.g. the server 11 may also include a network access device, a bus, etc.
The Processor 110 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 111 may be an internal storage unit of the server 11, such as a memory of the server 11. The memory 111 may also be an external storage device of the server 11, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the server 11. Further, the memory 111 may also include both an internal storage unit and an external storage device of the server 11. The memory 111 is used for storing the computer program and other programs and data required by the server 11. The memory 111 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of 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, devices or units, and may be in an electrical, mechanical 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 network 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 application 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 modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (8)

1. A method of message conversion, the method comprising:
determining a protocol type of a message to be converted, wherein the message to be converted comprises at least one field;
determining a protocol type of a target message, wherein the target message comprises at least one field;
searching a preset protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining a target protocol conversion path of the message to be converted;
converting the message to be converted into the target message according to the target protocol conversion path;
the searching a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining the target protocol conversion path of the message to be converted includes:
when the target protocol conversion path of the message to be converted is found to be more than or equal to 2, counting the total conversion times of the message to be converted under each protocol conversion path;
ranking the total conversion times according to the sequence from small to large, and taking the protocol conversion path with the first ranking as a target protocol conversion path of the message to be converted;
or when the target protocol conversion paths of the message to be converted are found to be more than or equal to 2, ranking the total conversion times under each protocol conversion path according to the sequence from small to large, and determining a preset number of protocol conversion paths from small to large as alternative protocol conversion paths;
and randomly selecting one protocol conversion path from the alternative protocol conversion paths as a target protocol conversion path of the message to be converted.
2. The message conversion method according to claim 1, wherein before the searching a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determining the target protocol conversion path of the message to be converted, further comprising:
checking the data type of each field in the message to be converted;
when the data types of the fields are in one-to-one correspondence with the data types of the preset fields, allowing the message to be converted to carry out protocol conversion; and
and when the data type of each field and the data type of each preset field have the data type which does not correspond to each other, converting the field which does not correspond to the data type into the field which corresponds to the data type.
3. The message conversion method according to claim 2, wherein, when there is a non-corresponding data type between the data type of each field and the data type of each predetermined field, the method further comprises, after converting the field of the non-corresponding data type into the field of the corresponding data type:
verifying the data type of the converted field;
and when the data type of the converted field is consistent with that of the preset field, allowing the message to be converted to carry out protocol conversion.
4. The message conversion method according to claim 1, wherein after the converting the message to be converted into the target message according to the target protocol conversion path, further comprising:
verifying the data type of each field in the message to be converted to obtain a verification result;
and when the verification result is that the data types of the converted fields in the message to be converted are consistent with the data types of the fields in the target message, outputting the result of the protocol conversion.
5. The message conversion method according to claim 1, wherein obtaining a target message protocol, wherein the target message protocol contains at least one field, comprises:
acquiring a protocol identifier of the target message;
and searching a preset protocol field configuration table according to the protocol identifier of the target message, and determining the field content contained in the target message.
6. A message conversion apparatus, characterized in that the apparatus comprises:
the device comprises a first determining module, a second determining module and a sending module, wherein the first determining module is used for determining the protocol type of a message to be converted, and the message to be converted comprises at least one field;
a second determining module, configured to determine a protocol type of a target message, where the target message includes at least one field;
a conversion path determining module, configured to search a predetermined protocol conversion rule table according to the protocol type of the message to be converted and the protocol type of the target message, and determine a target protocol conversion path of the message to be converted, where the conversion path determining module includes:
when the target protocol conversion path of the message to be converted is found to be more than or equal to 2, counting the total conversion times of the message to be converted under each protocol conversion path;
ranking the total conversion times according to the sequence from small to large, and taking the protocol conversion path with the first ranking as a target protocol conversion path of the message to be converted;
or when the target protocol conversion paths of the message to be converted are found to be more than or equal to 2, ranking the total conversion times under each protocol conversion path according to the sequence from small to large, and determining a preset number of protocol conversion paths from small to large as alternative protocol conversion paths;
randomly selecting one protocol conversion path from the alternative protocol conversion paths as a target protocol conversion path of the message to be converted;
and the conversion module is used for converting the message to be converted into the target message according to the target protocol conversion path.
7. A computer-readable storage medium storing a message conversion program, wherein the message conversion program, when executed by a processor, implements the steps of the message conversion method according to any one of claims 1 to 5.
8. A server comprising a memory, a processor and a message conversion program stored in said memory and executable on said processor, characterized in that said processor implements the steps of the message conversion method according to any of claims 1 to 5 when executing said message conversion program.
CN201911235910.7A 2019-12-05 2019-12-05 Message conversion method, device, storage medium and server Active CN111064716B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911235910.7A CN111064716B (en) 2019-12-05 2019-12-05 Message conversion method, device, storage medium and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911235910.7A CN111064716B (en) 2019-12-05 2019-12-05 Message conversion method, device, storage medium and server

Publications (2)

Publication Number Publication Date
CN111064716A CN111064716A (en) 2020-04-24
CN111064716B true CN111064716B (en) 2022-03-11

Family

ID=70299846

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911235910.7A Active CN111064716B (en) 2019-12-05 2019-12-05 Message conversion method, device, storage medium and server

Country Status (1)

Country Link
CN (1) CN111064716B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112422565B (en) * 2020-11-18 2023-02-03 青岛海尔科技有限公司 Message processing method and device, storage medium and electronic device
CN113489686B (en) * 2021-06-16 2023-01-10 杭州深渡科技有限公司 Data conversion method and system based on knx protocol
CN116614565B (en) * 2023-07-18 2023-10-10 河北六联通信科技有限公司 Multi-protocol fusion communication method, platform, system and medium for scene law enforcement

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007274611A (en) * 2006-03-31 2007-10-18 Fujitsu Ltd Conversion system selecting method
CN101420386A (en) * 2008-12-09 2009-04-29 南京西倍特科技有限公司 Multi-field integrated metering network interconnecting routing method
US9237125B1 (en) * 2013-05-05 2016-01-12 Applied Knight, LLC System and associated methods for secure communications
CN105451165A (en) * 2015-12-01 2016-03-30 中国通信建设集团设计院有限公司 Near field communication method and device based on multiple protocols
WO2016165421A1 (en) * 2015-09-21 2016-10-20 中兴通讯股份有限公司 Method and apparatus for converting different interface protocol messages
CN107454058A (en) * 2017-06-29 2017-12-08 广州视源电子科技股份有限公司 A kind of data transmission method for uplink, system, readable storage medium storing program for executing and computer equipment
WO2018018607A1 (en) * 2016-07-29 2018-02-01 深圳市赛亿科技开发有限公司 Method and device for fixed conversion of transmission protocol based on message protocol identification
CN109561104A (en) * 2018-12-28 2019-04-02 深圳市创梦天地科技有限公司 A kind of communication protocol conversion method and device
CN110021082A (en) * 2019-03-29 2019-07-16 深圳猛犸电动科技有限公司 A kind of work information acquisition device and acquisition method
CN110166431A (en) * 2019-04-16 2019-08-23 中国平安人寿保险股份有限公司 Multi-protocol data conversion method, device and computer equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1973504A (en) * 2004-06-07 2007-05-30 99有限公司 Method and apparatus for routing communications
GB0518515D0 (en) * 2005-09-10 2005-10-19 Ibm Object request broker
GB2512061A (en) * 2013-03-18 2014-09-24 Rapid Addition Ltd Transactional message format data conversion

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007274611A (en) * 2006-03-31 2007-10-18 Fujitsu Ltd Conversion system selecting method
CN101420386A (en) * 2008-12-09 2009-04-29 南京西倍特科技有限公司 Multi-field integrated metering network interconnecting routing method
US9237125B1 (en) * 2013-05-05 2016-01-12 Applied Knight, LLC System and associated methods for secure communications
WO2016165421A1 (en) * 2015-09-21 2016-10-20 中兴通讯股份有限公司 Method and apparatus for converting different interface protocol messages
CN105451165A (en) * 2015-12-01 2016-03-30 中国通信建设集团设计院有限公司 Near field communication method and device based on multiple protocols
WO2018018607A1 (en) * 2016-07-29 2018-02-01 深圳市赛亿科技开发有限公司 Method and device for fixed conversion of transmission protocol based on message protocol identification
CN107925652A (en) * 2016-07-29 2018-04-17 深圳市赛亿科技开发有限公司 A kind of transport protocol fixed conversion method and device based on message protocol identification
CN107454058A (en) * 2017-06-29 2017-12-08 广州视源电子科技股份有限公司 A kind of data transmission method for uplink, system, readable storage medium storing program for executing and computer equipment
CN109561104A (en) * 2018-12-28 2019-04-02 深圳市创梦天地科技有限公司 A kind of communication protocol conversion method and device
CN110021082A (en) * 2019-03-29 2019-07-16 深圳猛犸电动科技有限公司 A kind of work information acquisition device and acquisition method
CN110166431A (en) * 2019-04-16 2019-08-23 中国平安人寿保险股份有限公司 Multi-protocol data conversion method, device and computer equipment

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
"One More Weight is Enough: Toward the Optimal Traffic Engineering with OSPF";K. Xu, H. Liu, J. Liu and M. Shen;《2011 31st International Conference on Distributed Computing Systems》;20110725;836-846页 *
"面向智能家居的设备资源模型的研究";李达;《中国优秀硕士论文全文数据库(电子期刊) 工程科技Ⅱ辑》;20150315(第3期);C038-1697页 *
基于特征关键字的多协议数据流转换方法;林霞等;《计算机工程》;20110305(第05期);288-290+293页 *
无线传感器网络中拥塞避免的转换路由协议;张志等;《华中科技大学学报(自然科学版)》;20101015(第10期);18-22页 *

Also Published As

Publication number Publication date
CN111064716A (en) 2020-04-24

Similar Documents

Publication Publication Date Title
CN111064716B (en) Message conversion method, device, storage medium and server
US10579654B2 (en) Method and device for generating online question paths from existing question banks using a knowledge graph
CN112868004B (en) Resource recommendation method and device, electronic equipment and storage medium
CN111144402A (en) OCR recognition accuracy calculation method, device, equipment and storage medium
CN109829073B (en) Image searching method and device
CN109672608B (en) Method for transmitting messages according to time
CN109063142B (en) Webpage resource pushing method, server and storage medium
TWI581115B (en) Active preference learning method and system
CN107729491B (en) Method, device and equipment for improving accuracy rate of question answer search
CN113032580A (en) Associated file recommendation method and system and electronic equipment
CN104267974B (en) The call method and device of business interface
CN112307318B (en) Content publishing method, system and device
CN109542757A (en) Interface testing environment determines method, apparatus, electronic equipment and storage medium
US20180139288A1 (en) Method, device, and non-transitory computer-readable recording medium
CA3147341A1 (en) Category phrase recognition method, model training method, device and system
CN111552831B (en) Music recommendation method and server
CN108540521A (en) A kind of method of synchronizing information, terminal device and server
CN112948526A (en) User portrait generation method and device, electronic equipment and storage medium
CN112148962B (en) Method and device for pushing information
CN111489207A (en) Evaluation information writing method and device based on block chain system and hardware equipment
WO2023170555A1 (en) Systems and methods for biomedical information extraction, analytic generation and visual representation thereof
CN107025294B (en) Information acquisition method and device
CN109740130A (en) Method and apparatus for generating file
CN113486025B (en) Data storage method, data query method and device
CN108023949A (en) dial-up networking method, system, intelligent terminal and server

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