CN113079198A - Method and device for converting cloud platform interface protocol - Google Patents

Method and device for converting cloud platform interface protocol Download PDF

Info

Publication number
CN113079198A
CN113079198A CN202110292495.XA CN202110292495A CN113079198A CN 113079198 A CN113079198 A CN 113079198A CN 202110292495 A CN202110292495 A CN 202110292495A CN 113079198 A CN113079198 A CN 113079198A
Authority
CN
China
Prior art keywords
platform
request
protocol
parameters
target platform
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.)
Granted
Application number
CN202110292495.XA
Other languages
Chinese (zh)
Other versions
CN113079198B (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.)
Qingdao Hisense Smart Life Technology Co Ltd
Original Assignee
Qingdao Hisense Smart Life 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 Qingdao Hisense Smart Life Technology Co Ltd filed Critical Qingdao Hisense Smart Life Technology Co Ltd
Priority to CN202110292495.XA priority Critical patent/CN113079198B/en
Publication of CN113079198A publication Critical patent/CN113079198A/en
Application granted granted Critical
Publication of CN113079198B publication Critical patent/CN113079198B/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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Landscapes

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

Abstract

The invention discloses a method and a device for converting a cloud platform interface protocol, wherein the method comprises the steps of acquiring request information of a source platform, wherein the request information comprises identification information and request content of a target platform, determining data of request protocols of the source platform and the target platform and a mapping relation between the source platform and the request protocol of the target platform from a protocol library and a mapping relation library according to the identification information of the target platform, converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform, and sending the request content converted into the protocol format of the target platform to the target platform. The protocol format of the request content sent by the source platform is converted into the protocol format of the request protocol of the target platform and then sent to the target platform, so that the protocols of the two cloud platforms can be quickly connected, and the communication efficiency is improved.

Description

Method and device for converting cloud platform interface protocol
Technical Field
The invention relates to the technical field of cloud platforms, in particular to a method and a device for converting a cloud platform interface protocol.
Background
With the rapid development of the internet industry, more and more enterprises build private cloud platforms for opening own services, and are in butt joint with other cloud platforms for ecological construction.
When two enterprise private cloud platforms need to carry out cloud and cloud docking to realize services, because the two cloud platforms have respective cloud docking protocol standards, the difference of the cloud docking protocols of the two parties causes that the two parties cannot be directly docked.
The docking of the cloud platforms is usually realized by using an http interface, each cloud platform has own docking protocol specification, the platforms cannot be unified, and manpower needs to be invested for adapting to the protocol of the other party during docking, so that the docking progress is slow.
Disclosure of Invention
The embodiment of the invention provides a method and a device for converting a cloud platform interface protocol, which are used for improving the butt joint communication efficiency of two cloud platforms.
In a first aspect, an embodiment of the present invention provides a method for converting a cloud platform interface protocol, including:
acquiring request information of a source platform, wherein the request information comprises identification information and request content of a target platform;
determining data of request protocols of the source platform and the target platform and a mapping relation between the request protocols of the source platform and the target platform from a protocol library and a mapping relation library according to the identification information of the target platform;
converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform;
and sending the request content converted into the protocol format of the target platform to the target platform.
According to the technical scheme, the protocol format of the request content sent by the source platform is converted into the protocol format of the request protocol of the target platform and then sent to the target platform, so that the protocols of the two cloud platforms can be quickly connected, and the communication efficiency is improved.
Optionally, the converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relationship between the request protocols of the source platform and the target platform includes:
according to all request parameters of the functions corresponding to the request protocol of the source platform in the tree structure of the request protocol of the target platform, the request parameters corresponding to the three-level nodes are subjected to recursion downwards according to the parent-child relationship, and a cycle is established;
when circulating to a request parameter corresponding to a branch node, establishing circulation for all sub-nodes under the branch node;
when the request parameters corresponding to the leaf nodes are circulated, converting the parameter values of the source platform into the values of the request parameters corresponding to the leaf nodes according to the mapping relation between the request parameters corresponding to the leaf nodes and the parameter values of the corresponding request parameters in the source platform, and recursively assigning the values to parent nodes of the request parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining the request content converted into the protocol format of the target platform.
Optionally, after sending the request content in the converted protocol format to the target platform, the method further includes:
acquiring response information of the target platform;
converting the protocol format of the response content into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relation between the response protocols of the source platform and the target platform;
and sending the response content converted into the protocol format of the source platform to the source platform.
Optionally, the converting the protocol format of the response content into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relationship between the response protocols of the source platform and the target platform includes:
for all response parameters of the functions corresponding to the response protocol of the target platform in the tree structure of the response protocol of the source platform, carrying out recursion and establishing a cycle downwards according to a parent-child relationship starting from the response parameters corresponding to the three-level nodes;
when circulating to the response parameters corresponding to the branch nodes, establishing circulation for all the sub-nodes under the branch nodes;
when the response parameters corresponding to the leaf nodes are circulated, converting the parameter values of the target platform into the values of the response parameters corresponding to the leaf nodes according to the mapping relation between the response parameters corresponding to the leaf nodes and the parameter values of the response parameters corresponding to the target platform, and recursively assigning the values to parent nodes of the response parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining response content converted into the protocol format of the source platform.
Optionally, before obtaining the request information of the source platform, the method further includes:
acquiring interface protocols of two cloud platforms to be butted;
configuring the same function name for two interface protocols with the same purpose;
converting parameters of two interface protocols with the same function name into a tree structure, and configuring information for each node in the tree structure;
converting the configured tree structure into an xml format file;
analyzing the xml format file and storing the xml format file into the protocol library;
traversing the tree structures of the parameters of the two interface protocols with the same function name, establishing a mapping relation of the parameters with the same mapping keywords, and storing the mapping relation into a mapping relation library.
Optionally, the converting the parameters of the two interface protocols with the same function name into a tree structure includes:
determining the identification information of the platform as a root node of the tree structure;
determining a function name as a primary node of the tree structure;
determining a request parameter or a response parameter in an interface protocol as a secondary node of the tree structure;
determining parameters in the interface protocol as three-level nodes; the parameters carrying the subordinate parameters are branch nodes, and the parameters with the values of the parameters as variables are leaf nodes.
Optionally, the configuring information for each node in the tree structure includes:
configuring identification information of a platform for a root node of the tree structure;
configuring a function name and an interface address for a first-level node of the tree structure;
configuring request parameters or response parameters for the secondary nodes;
configuring the positions of the parameters for the three-level nodes;
configuring the value type of the parameter for a branch node or a leaf node starting from the third-level node;
configuring the attribute of the parameter according to the value type of the parameter;
configuring mapping keywords for parameters or parameter values corresponding to each level of nodes; the mapping keywords of the parameters of the mapping relation to be established in the two interface protocols are the same.
In a second aspect, an embodiment of the present invention provides a device for converting a cloud platform interface protocol, including:
the system comprises a transceiving unit, a processing unit and a processing unit, wherein the transceiving unit is used for acquiring request information of a source platform, and the request information comprises identification information and request content of a target platform;
the processing unit is used for determining the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform from a protocol library and a mapping relation library according to the identification information of the target platform; converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform;
the transceiver unit is further configured to send the request content converted into the protocol format of the target platform to the target platform.
Optionally, the processing unit is specifically configured to:
according to all request parameters of the functions corresponding to the request protocol of the source platform in the tree structure of the request protocol of the target platform, the request parameters corresponding to the three-level nodes are subjected to recursion downwards according to the parent-child relationship, and a cycle is established;
when circulating to a request parameter corresponding to a branch node, establishing circulation for all sub-nodes under the branch node;
when the request parameters corresponding to the leaf nodes are circulated, converting the parameter values of the source platform into the values of the request parameters corresponding to the leaf nodes according to the mapping relation between the request parameters corresponding to the leaf nodes and the parameter values of the corresponding request parameters in the source platform, and recursively assigning the values to parent nodes of the request parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining the request content converted into the protocol format of the target platform.
Optionally, the processing unit is further configured to:
after the request content in the converted protocol format is sent to the target platform, response information of the target platform is obtained;
converting the protocol format of the response content into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relation between the response protocols of the source platform and the target platform;
and sending the response content converted into the protocol format of the source platform to the source platform.
Optionally, the processing unit is specifically configured to:
for all response parameters of the functions corresponding to the response protocol of the target platform in the tree structure of the response protocol of the source platform, carrying out recursion and establishing a cycle downwards according to a parent-child relationship starting from the response parameters corresponding to the three-level nodes;
when circulating to the response parameters corresponding to the branch nodes, establishing circulation for all the sub-nodes under the branch nodes;
when the response parameters corresponding to the leaf nodes are circulated, converting the parameter values of the target platform into the values of the response parameters corresponding to the leaf nodes according to the mapping relation between the response parameters corresponding to the leaf nodes and the parameter values of the response parameters corresponding to the target platform, and recursively assigning the values to parent nodes of the response parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining response content converted into the protocol format of the source platform.
Optionally, the processing unit is further configured to:
before acquiring request information of a source platform, acquiring interface protocols of two cloud platforms to be docked;
configuring the same function name for two interface protocols with the same purpose;
converting parameters of two interface protocols with the same function name into a tree structure, and configuring information for each node in the tree structure;
converting the configured tree structure into an xml format file;
analyzing the xml format file and storing the xml format file into the protocol library;
traversing the tree structures of the parameters of the two interface protocols with the same function name, establishing a mapping relation of the parameters with the same mapping keywords, and storing the mapping relation into a mapping relation library.
Optionally, the processing unit is specifically configured to:
determining the identification information of the platform as a root node of the tree structure;
determining a function name as a primary node of the tree structure;
determining a request parameter or a response parameter in an interface protocol as a secondary node of the tree structure;
determining parameters in the interface protocol as three-level nodes; the parameters carrying the subordinate parameters are branch nodes, and the parameters with the values of the parameters as variables are leaf nodes.
Optionally, the processing unit is specifically configured to:
configuring identification information of a platform for a root node of the tree structure;
configuring a function name and an interface address for a first-level node of the tree structure;
configuring request parameters or response parameters for the secondary nodes;
configuring the positions of the parameters for the three-level nodes;
configuring the value type of the parameter for a branch node or a leaf node starting from the third-level node;
configuring the attribute of the parameter according to the value type of the parameter;
configuring mapping keywords for parameters or parameter values corresponding to each level of nodes; the mapping keywords of the parameters of the mapping relation to be established in the two interface protocols are the same.
In a third aspect, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instructions stored in the memory and executing the method for converting the cloud platform interface protocol according to the obtained program.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is caused to execute the method for cloud platform interface protocol conversion.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram of a system architecture according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a method for cloud platform interface protocol conversion according to an embodiment of the present invention;
fig. 3 is a schematic diagram of an interface protocol according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a tree structure of parameters of an interface protocol according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a tree structure of parameters of an interface protocol according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a mapping relationship provided in an embodiment of the present invention;
fig. 7 is a schematic flowchart of a method for cloud platform interface protocol conversion according to an embodiment of the present invention;
fig. 8 is a schematic flowchart of a method for cloud platform interface protocol conversion according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a device for cloud platform interface protocol conversion according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, 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.
Fig. 1 is a system architecture provided in an embodiment of the present invention. As shown in fig. 1, the system architecture may be a server 100, and the server 100 may include a processor 110, a communication interface 120, and a memory 130.
The communication interface 120 is used for communicating with a terminal device, and transceiving information transmitted by the terminal device to implement communication.
The processor 110 is a control center of the server 100, connects various parts of the entire server 100 using various interfaces and lines, performs various functions of the server 100 and processes data by running or executing software programs and/or modules stored in the memory 130 and calling data stored in the memory 130. Alternatively, processor 110 may include one or more processing units.
The memory 130 may be used to store software programs and modules, and the processor 110 executes various functional applications and data processing by operating the software programs and modules stored in the memory 130. The memory 130 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to a business process, and the like. Further, the memory 130 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
It should be noted that the structure shown in fig. 1 is only an example, and the embodiment of the present invention is not limited thereto.
Based on the above description, fig. 2 shows in detail a flow of a method for cloud platform interface protocol conversion according to an embodiment of the present invention, where the flow may be executed by a device for cloud platform interface protocol conversion.
As shown in fig. 2, the process specifically includes:
step 201, acquiring request information of a source platform; and determining the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform from a protocol library and a mapping relation library according to the identification information of the target platform.
In the embodiment of the present invention, the request information may include identification information of the target platform and the request content. The identification information of the target platform can be used for querying the protocol library and the mapping relation library. The identification information of the target platform may be information such as a name and an id of the target platform.
Before obtaining the request information of the source platform, a protocol library and a mapping relation library need to be established. Specifically, the interface protocols of two cloud platforms to be docked may be obtained first, the same function name may be configured for the two interface protocols with the same purpose, then the parameters of the two interface protocols with the same function name may be converted into a tree structure, and information may be configured for each node in the tree structure. And converting the configured tree structure into an xml format file, analyzing the xml format file, and storing the xml format file into a protocol library. And finally traversing the tree structures of the parameters of the two interface protocols with the same function name, establishing a mapping relation of the parameters with the same mapping keywords, and storing the mapping relation into a mapping relation library.
When parameters of two interface protocols with the same function name are converted into a tree structure, identification information of a platform is generally determined as a root node of the tree structure; determining the function name as a primary node of a tree structure; determining a request parameter or a response parameter in an interface protocol as a secondary node of a tree structure; determining parameters in an interface protocol as three-level nodes; the parameters carrying the subordinate parameters are branch nodes, and the parameters with the values of the parameters as variables are leaf nodes.
When configuring information for each node in the tree structure, configuring identification information of the platform for a root node of the tree structure; configuring a function name and an interface address for a first-level node of a tree structure; configuring request parameters or response parameters for the secondary nodes; configuring the positions of the parameters for the three-level nodes; configuring the value type of the parameter for a branch node or a leaf node starting from the third-level node; configuring the attribute of the parameter according to the value type of the parameter; configuring mapping keywords for parameters or parameter values corresponding to each level of nodes; the mapping keywords of the parameters of the mapping relation to be established in the two interface protocols are the same.
For example, A, B two cloud platform interface protocols are defined for a protocol converter for protocol conversion, fig. 3 shows one of the interface protocols of a platform1 and B platform2, now the a platform wants to access the B platform to obtain user information, and the two interface protocols have the same format but different parameter names and parameter values. The platform A can realize the conversion of the interface protocol through the protocol converter, and directly accesses to the platform B.
The protocol converter is specifically implemented as follows:
first step, formatting cloud platform interface protocol
Firstly, a cloud platform interface protocol in an xml format is constructed.
Because the interface names with the same purpose in each cloud platform protocol are not uniform, the function is defined as an interface to be converted in each platform protocol in the patent, and a uniform function name is defined according to the purpose of the interface.
For an interface corresponding to a function in a cloud platform protocol, converting parameters in the interface into a tree structure, configuring platform information in a root node, taking a function name as a first-level node, configuring an interface address, identifying a request parameter or a response parameter by a second-level node, starting from a third-level node as a parameter in the interface, taking a parameter with a lower-level parameter as a branch node, and taking a parameter with a value of the parameter in the interface as a variable as a leaf node. The following attributes are added for the node:
a) parameter positions are defined for the three-level nodes, and the parameters are divided into param, header, form and json according to an http protocol. Such as the location attribute in the param tag in fig. 4, 5. The parameter location is used to identify the location in the http request for each parameter when a transition is requested.
b) Parameter value types are defined for branch nodes and leaf nodes starting from the three-level nodes, the nodes with the values of object types are defined as json, list and the like, and the nodes with the values of variables are defined as string, long, int, double, map and the like according to the types of the variables. Such as the paramType attribute in the param tag in fig. 4, 5. The parameter value type is used to extract the value of each parameter when a conversion is requested.
c) For all leaf nodes, their attributes are defined according to their types and ranges of values. If the enumeration type lists all enumeration values and splices with | symbols, the numerical type defines the range, unit and step length, and the undefined attribute is the transparent transmission type parameter. Such as the value tag under the param section tag in fig. 4 and 5. And the converter converts the value of the parameter in the source platform request into the value in the target platform protocol according to the attribute.
d) And defining parameter mapping keywords for nodes at all levels, wherein the parameter mapping keywords for establishing the mapping relation in the two protocols are consistent. Such as the mappingKey attribute in the param section tag in fig. 4 and 5. When the mapping keywords are used for automatically establishing the mapping relation between the protocols, the mapping relation is established by the same parameters of the mapping keywords between the two protocols.
And converting the sorted tree structure into an xml file, and subsequently putting the xml file into a protocol library. The sample format of the platform A xml file is shown in FIG. 4, and the sample format of the platform B xml file is shown in FIG. 5.
Second, store in the protocol library
The protocol converter constructs an xml file analysis algorithm according to the requirement for generating the xml file defined in the first step, recursively analyzes downwards from a root node, the root node of the xml file is firstly analyzed to obtain a cloud platform corresponding to the file, a function name and an interface address are analyzed from a first-level node, a second-level node confirms the purpose, and a parent-child relationship is established for parameters of subsequent nodes. And finally, storing the contents of attributes, parent-child relations, parameter values and the like of the parameters in three dimensions of platform and function level purposes.
Thirdly, establishing a mapping relation between cloud platform protocols
Selecting two cloud platforms to be converted, inquiring the protocol contents of the two platforms from the protocol library, traversing all parameters of the two platforms, and establishing a mapping relation for the parameters with the same mapping keywords. And storing the result to a mapping relation library for the request conversion interface to query. For example, A, B protocol, according to the value of mappingKey in the protocol library, the mapping relationship shown in fig. 6 will be established.
In specific application, after the request information of the source platform is acquired, the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform can be determined from the protocol library and the mapping relation library according to the identification information of the target platform. That is, after receiving the request, the request conversion interface of the protocol converter reads the data of the source platform and the target platform from the protocol library and the mapping relation library.
Step 202, converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform.
Specifically, all request parameters of the functions corresponding to the request protocol of the source platform in the tree structure of the request protocol of the target platform are recursed downwards according to the parent-child relationship from the request parameters corresponding to the three-level nodes, and a cycle is established. When the request parameters corresponding to the branch nodes are circulated, establishing circulation for all sub-nodes under the branch nodes; and when the request parameters corresponding to the leaf nodes are circulated, converting the parameter values of the source platform into the values of the request parameters corresponding to the leaf nodes according to the mapping relation between the request parameters corresponding to the leaf nodes and the parameter values of the corresponding request parameters in the source platform, and recursively assigning the values to parent nodes of the request parameters corresponding to the leaf nodes. And when the cycle is confirmed to be finished, obtaining the request content converted into the protocol format of the target platform.
For example, received requests and responses are converted according to a protocol conversion algorithm. The conversion algorithm is as follows:
a) and for all request parameters under corresponding functions in the target platform protocol, recursion is carried out from the parameters of the three-level nodes to the lower part according to the parent-child relationship established in the second step, and circulation is established.
b) When looping to a branch node. Establishing self-circulation for all child nodes under the node; and when the parameters are circulated to the leaf node parameters, converting the values of the corresponding parameters in the target platform request into the values of the parameters according to the parameter value mapping relation between the parameters and the mapped source platform parameters, and returning the values to the parent nodes of the parameters for assignment.
c) After the loop is completed, the request of the protocol structure of the source platform can be converted into the request of the protocol structure of the target platform.
Step 203, the request content converted into the protocol format of the target platform is sent to the target platform.
After the protocol format conversion is completed, the request content converted into the protocol format of the target platform can be sent to the target platform, then the response information of the target platform can be received, and the protocol format of the response content is converted into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relation between the response protocols of the source platform and the target platform. And transmitting the response content converted into the protocol format of the source platform to the source platform.
The protocol format conversion process can be that aiming at all response parameters of the corresponding functions of the response protocol of the target platform in the tree structure of the response protocol of the source platform, the response parameters corresponding to the three-level nodes are reduced downwards according to the parent-child relationship and a cycle is established; when the response parameters corresponding to the branch nodes are circulated, establishing circulation for all sub-nodes under the branch nodes; when the response parameters corresponding to the leaf nodes are circulated, converting the parameter values of the target platform into the values of the response parameters corresponding to the leaf nodes according to the mapping relation between the response parameters corresponding to the leaf nodes and the parameter values of the response parameters corresponding to the target platform, and recursively assigning the values to parent nodes of the response parameters corresponding to the leaf nodes; and when the cycle is confirmed to be finished, obtaining response content converted into the protocol format of the source platform.
That is, after the target platform responds, the response of the target platform protocol structure is converted into the response of the source platform protocol structure, again in a recursive loop.
Fig. 7 exemplarily shows a protocol conversion process, in which a platform protocol is formatted as required and converted into an XML file in a first step, the XML file is imported into a protocol library of a protocol converter in a second step, a platform in two protocol libraries to be converted is selected in a third step, and a mapping relationship is automatically established by the converter and stored in a mapping relationship library. The protocol converter provides a request conversion interface, converts the request information into a request in a target platform format according to the mapping relation of the source platform and the target platform in the mapping relation library, and forwards the request to the target platform.
In order to better explain the embodiment of the present invention, the above protocol conversion process will be described in a specific implementation scenario.
For the conversion of the platform A request into the platform B request, wherein A is a source platform and B is a target platform, the platform A request is assumed as follows:
Figure BDA0002982852890000131
assume the B platform response is:
Figure BDA0002982852890000132
the specific conversion flow shown in fig. 8 is as follows:
step 801, receive a request sent by a platform a.
Step 802, reading a protocol library and a mapping relation library.
1. Acquiring A, B parameter information corresponding to the interface protocol of the platform from a protocol library;
2. and acquiring A, B the mapping relation of the parameters corresponding to the interface protocol of the platform from the mapping relation library.
Step 803, a for loop is established for the request parameters in the tertiary nodes in the interface protocol of the B platform.
The method comprises the following specific steps:
front loop
For the leaf node, the parameter accessoken in the platform A mapping request is known according to the mapping relation, namely the value of the accessoken is assigned, and the accessoken is made to be 123456789.
For a branch node, a sub-loop is established for all child nodes:
front loop
And obtaining a parameter userid in the platform request of the mapping A according to the mapping relation, realizing the assignment of the account, and enabling the account to be the test.
}
And (5) ending the cycle, assigning values to account:
account:{
accountid:test
}
}
and step 804, ending the cycle and generating a request of the platform B.
{
〝accessToken〞:〝123456789〞
〝account〞:{
〝accountid〞:〝test〞
}
}
Step 805, the converted request is sent to the B platform.
At step 806, a response is received from the B platform.
Step 807, establish a for loop for the response parameters in the tertiary nodes in the A platform interface.
The method comprises the following specific steps:
front loop
For a branch node, a sub-loop is established for all child nodes:
front loop
And obtaining a parameter accounting in the platform response of the mapping B according to the mapping relation, realizing the value assignment of userid, and making the userid be the test.
And obtaining a parameter accountage in the platform response of the mapping B according to the mapping relation, assigning a value to the age, and enabling the age to be 20.
And obtaining a parameter accountsix in the platform response of the mapping B according to the mapping relation, assigning a value to the sex, and enabling the sex to be man.
}
And (5) ending the circulation, and assigning a value to the user:
user:{
userid:test
age:20
sex:man
}
}
step 808, sending the converted response to the a platform.
In the embodiment of the invention, request information of a source platform is obtained, the request information comprises identification information and request content of a target platform, data of request protocols of the source platform and the target platform and a mapping relation between the request protocols of the source platform and the target platform are determined from a protocol library and a mapping relation library according to the identification information of the target platform, a protocol format of the request content is converted into a protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform, and the request content converted into the protocol format of the target platform is sent to the target platform. The protocol format of the request content sent by the source platform is converted into the protocol format of the request protocol of the target platform and then sent to the target platform, so that the protocols of the two cloud platforms can be quickly connected, and the communication efficiency is improved.
Based on the same technical concept, fig. 9 exemplarily shows a structure of an apparatus for cloud platform interface protocol conversion according to an embodiment of the present invention, and the apparatus may perform a flow of cloud platform interface protocol conversion.
As shown in fig. 9, the apparatus specifically includes:
a transceiving unit 901, configured to acquire request information of a source platform, where the request information includes identification information of a target platform and request content;
a processing unit 902, configured to determine, from a protocol library and a mapping relationship library, data of request protocols of the source platform and the target platform and a mapping relationship between the request protocols of the source platform and the target platform according to the identification information of the target platform; converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform;
the transceiver 901 is further configured to send the request content converted into the protocol format of the target platform to the target platform.
Optionally, the processing unit 902 is specifically configured to:
according to all request parameters of the functions corresponding to the request protocol of the source platform in the tree structure of the request protocol of the target platform, the request parameters corresponding to the three-level nodes are subjected to recursion downwards according to the parent-child relationship, and a cycle is established;
when circulating to a request parameter corresponding to a branch node, establishing circulation for all sub-nodes under the branch node;
when the request parameters corresponding to the leaf nodes are circulated, converting the parameter values of the source platform into the values of the request parameters corresponding to the leaf nodes according to the mapping relation between the request parameters corresponding to the leaf nodes and the parameter values of the corresponding request parameters in the source platform, and recursively assigning the values to parent nodes of the request parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining the request content converted into the protocol format of the target platform.
Optionally, the processing unit 902 is further configured to:
after the request content in the converted protocol format is sent to the target platform, response information of the target platform is obtained;
converting the protocol format of the response content into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relation between the response protocols of the source platform and the target platform;
and sending the response content converted into the protocol format of the source platform to the source platform.
Optionally, the processing unit 902 is specifically configured to:
for all response parameters of the functions corresponding to the response protocol of the target platform in the tree structure of the response protocol of the source platform, carrying out recursion and establishing a cycle downwards according to a parent-child relationship starting from the response parameters corresponding to the three-level nodes;
when circulating to the response parameters corresponding to the branch nodes, establishing circulation for all the sub-nodes under the branch nodes;
when the response parameters corresponding to the leaf nodes are circulated, converting the parameter values of the target platform into the values of the response parameters corresponding to the leaf nodes according to the mapping relation between the response parameters corresponding to the leaf nodes and the parameter values of the response parameters corresponding to the target platform, and recursively assigning the values to parent nodes of the response parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining response content converted into the protocol format of the source platform.
Optionally, the processing unit 902 is further configured to:
before acquiring request information of a source platform, acquiring interface protocols of two cloud platforms to be docked;
configuring the same function name for two interface protocols with the same purpose;
converting parameters of two interface protocols with the same function name into a tree structure, and configuring information for each node in the tree structure;
converting the configured tree structure into an xml format file;
analyzing the xml format file and storing the xml format file into the protocol library;
traversing the tree structures of the parameters of the two interface protocols with the same function name, establishing a mapping relation of the parameters with the same mapping keywords, and storing the mapping relation into a mapping relation library.
Optionally, the processing unit 902 is specifically configured to:
determining the identification information of the platform as a root node of the tree structure;
determining a function name as a primary node of the tree structure;
determining a request parameter or a response parameter in an interface protocol as a secondary node of the tree structure;
determining parameters in the interface protocol as three-level nodes; the parameters carrying the subordinate parameters are branch nodes, and the parameters with the values of the parameters as variables are leaf nodes.
Optionally, the processing unit 902 is specifically configured to:
configuring identification information of a platform for a root node of the tree structure;
configuring a function name and an interface address for a first-level node of the tree structure;
configuring request parameters or response parameters for the secondary nodes;
configuring the positions of the parameters for the three-level nodes;
configuring the value type of the parameter for a branch node or a leaf node starting from the third-level node;
configuring the attribute of the parameter according to the value type of the parameter;
configuring mapping keywords for parameters or parameter values corresponding to each level of nodes; the mapping keywords of the parameters of the mapping relation to be established in the two interface protocols are the same.
Based on the same technical concept, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instructions stored in the memory and executing the method for converting the cloud platform interface protocol according to the obtained program.
Based on the same technical concept, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is enabled to execute the method for cloud platform interface protocol conversion.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for converting a cloud platform interface protocol is characterized by comprising the following steps:
acquiring request information of a source platform, wherein the request information comprises identification information and request content of a target platform;
determining data of request protocols of the source platform and the target platform and a mapping relation between the request protocols of the source platform and the target platform from a protocol library and a mapping relation library according to the identification information of the target platform;
converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform;
and sending the request content converted into the protocol format of the target platform to the target platform.
2. The method of claim 1, wherein the converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relationship between the request protocols of the source platform and the target platform comprises:
according to all request parameters of the functions corresponding to the request protocol of the source platform in the tree structure of the request protocol of the target platform, the request parameters corresponding to the three-level nodes are subjected to recursion downwards according to the parent-child relationship, and a cycle is established;
when circulating to a request parameter corresponding to a branch node, establishing circulation for all sub-nodes under the branch node;
when the request parameters corresponding to the leaf nodes are circulated, converting the parameter values of the source platform into the values of the request parameters corresponding to the leaf nodes according to the mapping relation between the request parameters corresponding to the leaf nodes and the parameter values of the corresponding request parameters in the source platform, and recursively assigning the values to parent nodes of the request parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining the request content converted into the protocol format of the target platform.
3. The method of claim 1, wherein after sending the requested content in a converted protocol format to the target platform, further comprising:
acquiring response information of the target platform;
converting the protocol format of the response content into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relation between the response protocols of the source platform and the target platform;
and sending the response content converted into the protocol format of the source platform to the source platform.
4. The method of claim 3, wherein the converting the protocol format of the response content into the protocol format of the source platform according to the data of the response protocols of the source platform and the target platform and the mapping relationship between the response protocols of the source platform and the target platform comprises:
for all response parameters of the functions corresponding to the response protocol of the target platform in the tree structure of the response protocol of the source platform, carrying out recursion and establishing a cycle downwards according to a parent-child relationship starting from the response parameters corresponding to the three-level nodes;
when circulating to the response parameters corresponding to the branch nodes, establishing circulation for all the sub-nodes under the branch nodes;
when the response parameters corresponding to the leaf nodes are circulated, converting the parameter values of the target platform into the values of the response parameters corresponding to the leaf nodes according to the mapping relation between the response parameters corresponding to the leaf nodes and the parameter values of the response parameters corresponding to the target platform, and recursively assigning the values to parent nodes of the response parameters corresponding to the leaf nodes;
and when the cycle is confirmed to be finished, obtaining response content converted into the protocol format of the source platform.
5. The method of claim 1, prior to obtaining the requested information of the source platform, further comprising:
acquiring interface protocols of two cloud platforms to be butted;
configuring the same function name for two interface protocols with the same purpose;
converting parameters of two interface protocols with the same function name into a tree structure, and configuring information for each node in the tree structure;
converting the configured tree structure into an xml format file;
analyzing the xml format file and storing the xml format file into the protocol library;
traversing the tree structures of the parameters of the two interface protocols with the same function name, establishing a mapping relation of the parameters with the same mapping keywords, and storing the mapping relation into a mapping relation library.
6. The method of claim 5, wherein translating parameters of two interface protocols having the same function name into a tree structure comprises:
determining the identification information of the platform as a root node of the tree structure;
determining a function name as a primary node of the tree structure;
determining a request parameter or a response parameter in an interface protocol as a secondary node of the tree structure;
determining parameters in the interface protocol as three-level nodes; the parameters carrying the subordinate parameters are branch nodes, and the parameters with the values of the parameters as variables are leaf nodes.
7. The method of claim 5, wherein said configuring information for each node in said tree structure comprises:
configuring identification information of a platform for a root node of the tree structure;
configuring a function name and an interface address for a first-level node of the tree structure;
configuring request parameters or response parameters for the secondary nodes;
configuring the positions of the parameters for the three-level nodes;
configuring the value type of the parameter for a branch node or a leaf node starting from the third-level node;
configuring the attribute of the parameter according to the value type of the parameter;
configuring mapping keywords for parameters or parameter values corresponding to each level of nodes; the mapping keywords of the parameters of the mapping relation to be established in the two interface protocols are the same.
8. An apparatus for cloud platform interface protocol conversion, comprising:
the system comprises a transceiving unit, a processing unit and a processing unit, wherein the transceiving unit is used for acquiring request information of a source platform, and the request information comprises identification information and request content of a target platform;
the processing unit is used for determining the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform from a protocol library and a mapping relation library according to the identification information of the target platform; converting the protocol format of the request content into the protocol format of the target platform according to the data of the request protocols of the source platform and the target platform and the mapping relation between the request protocols of the source platform and the target platform;
the transceiver unit is further configured to send the request content converted into the protocol format of the target platform to the target platform.
9. A computing device, comprising:
a memory for storing program instructions;
a processor for calling program instructions stored in said memory to perform the method of any of claims 1 to 7 in accordance with the obtained program.
10. A computer-readable non-transitory storage medium including computer-readable instructions which, when read and executed by a computer, cause the computer to perform the method of any one of claims 1 to 7.
CN202110292495.XA 2021-03-18 2021-03-18 Method and device for converting cloud platform interface protocol Active CN113079198B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110292495.XA CN113079198B (en) 2021-03-18 2021-03-18 Method and device for converting cloud platform interface protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110292495.XA CN113079198B (en) 2021-03-18 2021-03-18 Method and device for converting cloud platform interface protocol

Publications (2)

Publication Number Publication Date
CN113079198A true CN113079198A (en) 2021-07-06
CN113079198B CN113079198B (en) 2022-07-01

Family

ID=76613176

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110292495.XA Active CN113079198B (en) 2021-03-18 2021-03-18 Method and device for converting cloud platform interface protocol

Country Status (1)

Country Link
CN (1) CN113079198B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113742407A (en) * 2021-08-31 2021-12-03 浙江惠瀜网络科技有限公司 Data conversion method and device
CN114499930A (en) * 2021-12-13 2022-05-13 奇安信科技集团股份有限公司 Method and device for processing multi-protocol single sign-on request
CN114817117A (en) * 2022-06-23 2022-07-29 浙江大华技术股份有限公司 Protocol compatible method, electronic device and computer readable storage device
CN117573762A (en) * 2024-01-15 2024-02-20 杭州数云信息技术有限公司 Data processing method and device of data connection platform, storage medium and server
CN118474213A (en) * 2024-06-06 2024-08-09 上海博昂电气有限公司 Protocol converter and conversion system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107948135A (en) * 2017-10-31 2018-04-20 贵州白山云科技有限公司 A kind of data processing method and device for supporting a variety of API protocols
CN108200077A (en) * 2018-01-18 2018-06-22 北京网信云服信息科技有限公司 A kind of method and device of calling interface
CN108696381A (en) * 2017-04-12 2018-10-23 腾讯科技(深圳)有限公司 A kind of protocol configuration method and device
CN109635019A (en) * 2018-10-23 2019-04-16 平安科技(深圳)有限公司 Request processing method, device, equipment and storage medium
CN109992338A (en) * 2018-01-03 2019-07-09 甲骨文国际公司 For appearing the method and system of virtual assistant service across multiple platforms

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108696381A (en) * 2017-04-12 2018-10-23 腾讯科技(深圳)有限公司 A kind of protocol configuration method and device
CN107948135A (en) * 2017-10-31 2018-04-20 贵州白山云科技有限公司 A kind of data processing method and device for supporting a variety of API protocols
CN109992338A (en) * 2018-01-03 2019-07-09 甲骨文国际公司 For appearing the method and system of virtual assistant service across multiple platforms
CN108200077A (en) * 2018-01-18 2018-06-22 北京网信云服信息科技有限公司 A kind of method and device of calling interface
CN109635019A (en) * 2018-10-23 2019-04-16 平安科技(深圳)有限公司 Request processing method, device, equipment and storage medium

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113742407A (en) * 2021-08-31 2021-12-03 浙江惠瀜网络科技有限公司 Data conversion method and device
CN113742407B (en) * 2021-08-31 2024-04-30 浙江惠瀜网络科技有限公司 Data conversion method and device
CN114499930A (en) * 2021-12-13 2022-05-13 奇安信科技集团股份有限公司 Method and device for processing multi-protocol single sign-on request
CN114817117A (en) * 2022-06-23 2022-07-29 浙江大华技术股份有限公司 Protocol compatible method, electronic device and computer readable storage device
CN114817117B (en) * 2022-06-23 2022-10-04 浙江大华技术股份有限公司 Protocol compatibility method, electronic equipment and computer readable storage device
CN117573762A (en) * 2024-01-15 2024-02-20 杭州数云信息技术有限公司 Data processing method and device of data connection platform, storage medium and server
CN117573762B (en) * 2024-01-15 2024-04-16 杭州数云信息技术有限公司 Data processing method and device of data connection platform, storage medium and server
CN118474213A (en) * 2024-06-06 2024-08-09 上海博昂电气有限公司 Protocol converter and conversion system

Also Published As

Publication number Publication date
CN113079198B (en) 2022-07-01

Similar Documents

Publication Publication Date Title
CN113079198B (en) Method and device for converting cloud platform interface protocol
CN109213519B (en) Heterogeneous API adaptation processing method and system
CN110598280B (en) Equipment simulation system and method and computer readable storage medium
CN109635019B (en) Request processing method, device, equipment and storage medium
CN111241073B (en) Data quality inspection method and device
CN108279987A (en) The method for edition management and device of application program
US20190102465A1 (en) Api query extension
CN108363588B (en) Method for realizing interaction between web and native function, electronic device and readable storage medium
CN113238740A (en) Code generation method, code generation device, storage medium, and electronic apparatus
CN109062906B (en) Translation method and device for program language resources
CN111142849B (en) Flow processing method, device, storage medium and processor
CN114466047B (en) Method, platform, equipment and medium for conveniently accessing Internet of things equipment to Internet of things platform
CN110888672B (en) Expression engine implementation method and system based on metadata architecture
CN111078573A (en) Test message generation method and device
CN113791766B (en) Method for combining data interfaces, electronic device and readable storage medium
CN111580821B (en) Script binding method and device, electronic equipment and computer readable storage medium
CN110020243A (en) Querying method, device, Internet of Things server and the storage medium of internet of things data
CN112395339B (en) Intersystem data admission verification method, device, computer equipment and storage medium
CN112883088B (en) Data processing method, device, equipment and storage medium
CN111309319A (en) Inheritable office data dynamic page configuration method and device
CN112130860B (en) JSON object analysis method and device, electronic equipment and storage medium
CN112269351B (en) PLC-based data processing method and system, electronic device and storage medium
CN114866627A (en) Message checking method, device, processor and electronic equipment
CN113434435A (en) Test case logic automatic generation method and device
CN115836511A (en) Equipment management method and device in Internet of things, computer equipment and storage medium

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