Detailed Description
The embodiment of the invention provides a data processing method, which can realize the conversion of transmission data (such as transmission data of a first transmission format) under one protocol format (or called transmission format) in an interface (Application Programming Interface, API) gateway into transmission data (such as protocol data of a second transmission format) under another protocol format, because codes in a service server are adaptive to the second transmission format, the service server can call the format of the transmission data executed by the codes to be the second transmission format, if the service server needs to execute the transmission data of the first transmission format, the codes of the service server need to be changed, and in order to realize the condition that the codes of the service server are not changed and the transmission data of the first transmission format are responded, the invention provides a protocol conversion device for converting the protocol format of the transmission data in the service server, a developer can convert the transmission data in the protocol conversion device in advance, the protocol conversion device is used for converting the transmission data of the first transmission format in the interface gateway, the service server can obtain the transmission data of the first transmission format, the service server can be realized in the condition that the second transmission format is not converted in the gateway, the service server can be correspondingly converted in the gateway, the condition that the protocol conversion device of the second transmission format is not converted in the service server is realized, the interface can be deployed in the interface, the interface can be changed, the service can be realized, the protocol conversion device can be deployed in a service server or can be a server which is independently deployed, and in the embodiment of the invention, the detailed description is given by taking the protocol conversion device as an independent server, and in the case that the protocol conversion device is deployed in the service server or in an interface gateway, the embodiment of the invention can be seen.
In one embodiment, the interface gateway (api gateway) is a protocol conversion interface for connecting a client (or a target application running in the client, where the target application is any application running in the client), and a service server corresponding to the client, where the interface gateway is configured to receive a data access request of the target application, and convert the data access request into transmission data for transmission at a network layer according to a specified protocol format (e.g., a first transmission format), where the specified protocol format includes: XML (Extensible Markup Language, an XML-based protocol format), json (JavaScript Object Notation, a lightweight data exchange format), etc., in the embodiment of the present invention, the first transmission format is referred to as json format for details, and when the first transmission format is an XML format, reference may be made to the embodiment of the present invention. After the interface gateway converts the data access request of the target application program into the first transmission format, the transmission data of the first transmission format corresponding to the data access request can be obtained, in one embodiment, if the service server directly obtains the transmission data of the first transmission format from the interface gateway, the problem that the code in the service server and the transmission data of the first transmission format are not adapted may occur, it may be understood that if the code in the service server and the first transmission format are not adapted, the problem that the execution error will occur when the service server executes the transmission data of the first transmission format, the service server cannot execute the data access request, thereby affecting the user experience, therefore, after the interface gateway directly converts the data access request of the target application program into the transmission data of the first transmission format, the protocol conversion device may firstly convert the transmission data of the first transmission format into the transmission data of the second transmission format corresponding to the data access request, the service server may obtain the transmission data of the second transmission format corresponding to the second transmission format, and the data access request may be accessed from the conversion device, thereby obtaining the data of the data access request of the second transmission format corresponding to the data access request.
In one embodiment, if The service server is a background device implemented by c++ (The c++ Programming Language, an object-oriented programming language), the second transmission format adapted to The code of The service server should be a data transmission format supported by c++, such as a local structure defined by class (class), where in The c++ language, a global structure and a local structure may be used for data transmission, and The global structure refers to a structure to which no access descriptor is added when The structure parameters are instantiated, that is, a structure to support access by all members; the local structure refers to a structure to which an access descriptor is added before the structure parameter is instantiated, that is, a structure to which only some members are supported for access. Referring to the data processing system shown in fig. 1, the data processing system may include aclient 10 to which a target application belongs, a processing device 11 for performing data processing on a data access request of the target application, and a service server 12, wherein the processing device 11 includes aninterface gateway 110 and a protocol conversion device 111. In one embodiment, after detecting a data access request for a target application, theclient 10 to which the target application belongs may send the data access request to theinterface gateway 110 to request access to the service server, after theinterface gateway 110 receives the data access request, the data access request may be converted according to a first transmission format to obtain transmission data in the first transmission format corresponding to the data access request, further, theinterface gateway 110 may send the transmission data in the first transmission format to the protocol conversion device 111, after receiving the transmission data in the first transmission format, the protocol conversion device 111 may convert the transmission data in the first transmission format to obtain transmission data in a second transmission format corresponding to the data access request, and forward the transmission data in the second transmission format to the service server 12.
After the service server 12 receives the transmission data in the second transmission format, the code adapted to the second transmission format may be invoked to execute the transmission data in the second transmission format, the service server 12 may obtain the access data indicated by the data access request based on the analysis of the transmission data in the second transmission format, when the service server 12 feeds back the access data to theclient 10, the service server 12 also packages the access data into the feedback data in the second transmission format, and sends the feedback data in the second transmission format to the protocol conversion device 111, after receiving the feedback data in the second transmission format, the protocol conversion device 111 may perform format conversion on the feedback data in the second transmission format, to obtain the feedback data in the first transmission format, and send the feedback data in the first transmission format to theinterface gateway 110, and theinterface gateway 110 may obtain the access data indicated by the data access request from the feedback data in the first transmission format, and return the access data to theclient 10 to which the target application program belongs, so that the code in the service server is not packaged, and the service server may respond to the service request development of the target application program.
Referring to fig. 2, a schematic flow chart of a data processing method according to an embodiment of the present invention may be applied to the above-mentioned protocol conversion device, as shown in fig. 2, where the method may include:
s201, obtaining transmission data of a first transmission format from an interface gateway.
In one embodiment, after the user logs in and registers in the target application program, the target application program can access the interface gateway based on the designated interface, that is, the target application program can send the data access request of the user for the target application program to the interface gateway through the designated interface, so that the interface gateway converts the data access request of the target application program according to the first transmission format to obtain the transmission data of the first transmission format of the data access request, wherein the first transmission format is the protocol format of the designated data access request for transmission in the network. In one embodiment, a user may perform login registration in a target application program by using a Single Sign On (SSO) method, where Single Sign On refers to that after the user completes login registration On an identity authentication server, the user may obtain login registration authority for accessing other associated systems or application programs in the Single Sign On system, that is, the user may access a plurality of different application programs only by one login registration, so that the efficiency of accessing the application program by the user may be improved.
In one embodiment, after a user completes login and registration in a target application program in a single sign-on manner, the target application program can bind one identity authentication information for the data access request after detecting the data access request initiated by the user, so that the data access request and the bound identity authentication information can be pushed to an interface gateway through a request push service in the target application program. After the interface gateway receives the data access request and the bound identity authentication information, the login registration information of the user login target application program can be checked based on the identity authentication information, and according to a check result, the interface gateway can determine whether the target application program has the authority to access the service server, in one embodiment, if the interface gateway determines that the target application program has the authority to access the service server through checking the identity authentication information, the interface gateway can convert the data access request according to the designated first transmission format to obtain the transmission data of the first transmission format, so that the transmission data of the first transmission format can be sent to the protocol conversion device, and after the transmission data of the first transmission format sent by the interface gateway is received, the protocol conversion device can perform format conversion on the transmission data of the transmission data to obtain the transmission data of the second transmission format, that is, and then step S202 is executed. In one embodiment, the first transport format comprises a text data exchange format, JSON format, and the second transport format comprises: local structures, i.e. structures defined by class.
S202, performing format conversion processing on the transmission data of the first transmission format to obtain transmission data of a second transmission format.
In one embodiment, the transmission data in the first transmission format includes text data exchange format (JSON format), the transmission data in JSON format is character string data, such as "name", "reddish", "9", and the like, and the second transmission format is a local structure, i.e. a structure defined by class, or referred to as class structure, the class structure includes a class name (class name), an object in the structure, such as an instance object of age, name, and the like, and the protocol conversion device performs format conversion processing on the transmission data in the first transmission format to obtain the transmission data in the second transmission format, that is, a process of converting the character string in JSON format into the class structure and performing instantiation processing on the object in the class structure. In a specific implementation, the protocol conversion device may perform transmission format conversion on the transmission data in the first transmission format based on a configuration file preset in the protocol conversion device, in one embodiment, a class structure body corresponding to and converted from transmission data of different json types is preset in the configuration file, and it is understood that the differences in json types are caused by differences in interface gateways, so that when the configuration file is configured, interface identifiers of the interface gateways and different class structures can be associated. Because the target application program supports multiple service types of data access of the user, the user can initiate data access requests of different service types in the target application program, when the target application program forwards the data access requests, the data access requests are forwarded to different interface gateways based on the service types corresponding to the data access requests, and the types of the transmission data in the json format generated by the different interface gateways are different, so that when the protocol conversion device converts the transmission data in the first transmission format (json format) into the transmission data in the second transmission format, the interface gateway for generating the transmission data in the first transmission format needs to be determined first, and the json type of the first transmission format can be determined based on the interface gateway.
In one embodiment, the protocol conversion device may obtain an interface identifier of an interface gateway, so as to determine which interface gateway converts the transmission data in the first transmission format, and further, the protocol conversion device may obtain, from the configuration file, a target structure type associated with the interface identifier based on the interface identifier, so that a character string in json format may be transferred into a target structure of the target structure type, so as to obtain the transmission data in the second transmission format. In a specific implementation, the protocol conversion device can introduce a C++ reflection library rttr (a reflective programming database) to realize a reflection mechanism, so that the mutual conversion between a character string of a JSON structure and a structural body of a class structure can be realized, wherein the character string of the JSON structure is stored in a JSON data packet, and the suffix name of the character string is a JSON suffix; the class structure is stored in the qza packet with its suffix name jce suffix (an encrypted file suffix) and therefore can be implemented by the code shown in fig. 3a when performing the conversion of json and jce. The code shown in fig. 3a is a json and jce conversion tool in a jce2cpp (a database for reading and writing json files) tool, where two conversion parameters are provided in jce2 cpp: when the json and rapidjson and jce2cpp tools generate jce header files, one of the two parameters is carried, so that the generated header files have a unpacking function for the json corresponding to the jce structure bodies to be mutually converted into jce, the format conversion of json-jce of corresponding request packets can be realized by the corresponding unpacking function, the format conversion of json-jce can be particularly realized by adopting codes shown in fig. 3b, and character strings in the json format can be written into class structures according to the codes shown in fig. 3b, thereby realizing the conversion of transmission data in the first transmission format into transmission data in the second transmission format. After the protocol conversion device finishes converting the first transmission format into the second transmission format, the transmission data of the second transmission format may be sent to the service access, that is, step S203 and step S204 are performed instead.
And S203, transmitting the transmission data in the second transmission format to a service server.
S204, receiving the access data indicated by the data access request obtained by the service server executing the transmission data in the second transmission format, and sending the access data to the target application program through the interface gateway.
In step S203 and step S204, after the protocol conversion device converts the transmission data of the first transmission format into the transmission data of the second transmission format, the transmission data of the second transmission format may be sent to the service server, and after receiving the transmission data of the second transmission format, the service server may call the code adapted to the second transmission format to execute the transmission data of the second transmission format, where, because the second transmission format is a local structure, the code adapted to the second transmission format includes a c++ code, and after receiving the transmission data of the second transmission format, the service server may call the c++ code to parse the transmission data of the second transmission format, so as to obtain a data access request initiated by the user in the target application program. In one embodiment, the service server may invoke the code shown in fig. 3c to read the transmission data in the second transmission format, where, since the transmission data in the second transmission format is the data stored in the local structure, the process of reading the transmission data in the second transmission format by the service server is the process of reading the instantiation object from the local structure. After the service server obtains the access data indicated by the data access request, the access data can be returned to the target application program. Based on the configuration of the configuration file in the protocol conversion device, the developer can instantiate the character string into a corresponding local structure body and an instantiated object in the local structure body, that is, based on the configuration file, the protocol conversion device can complete json to jce serialization and serialization operation, complete code work such as fig. 3 a-3 c, and no matter how many command words (character strings) are newly added, complicated code development work such as jce instantiation, json deserialization and the like are not needed any more, only the configuration file needs to be changed, and development efficiency can be improved.
In one embodiment, when the protocol conversion device transmits the transmission data in the second transmission format to the service server, since there are a plurality of service servers connected to the protocol conversion device and different service servers support different access service types, as shown in fig. 4, the service server connected to the protocol conversion device may be a server supporting a dress type service or a server supporting an album access service, and when the protocol conversion device transmits the transmission data in the second transmission format to the service server, the transmission data in the second transmission format may be transmitted to the service server matching the access service type based on the access service type indicated by the data access request. When the protocol conversion device sends the transmission data in the second transmission format to different service servers, based on the access service type, the transmission data in the second transmission format is encapsulated into different data packets, and the packet header information of the encapsulated different data packets is different, for example, the packet header of the data packet sent to the service server supporting lovers service is qza _jce, the packet header encapsulated to the service server supporting impersonation service is pdu_jce, and the packet header encapsulated to the service server supporting album service is webapp_jce. And when the service server sends the access data to the target application program, the service server firstly packages the access data into feedback data of the second transmission format and sends the feedback data of the second transmission format to the protocol conversion device, and after receiving the feedback data of the second transmission format, the protocol conversion device can convert the feedback data of the second transmission format into feedback data of the first transmission format and send the feedback data of the first transmission format to the interface gateway. After receiving the feedback data in the first transmission format, the interface gateway can read the access data indicated by the data access request from the feedback data in the first transmission format and send the access data to the target application program, thereby realizing the response to the data access request.
In the embodiment of the invention, the interface gateway can convert the data access request in the target application program according to the first transmission format to obtain the transmission data of the first transmission format, and because the code in the service server does not support the execution of the transmission data of the first transmission format, in order to enable the service server to respond to the data access request, after determining the transmission data of the first transmission format, the interface gateway can firstly send the transmission data of the first transmission format to the protocol conversion device for the conversion of the protocol format (or the transmission format), correspondingly, the protocol conversion device can perform the format conversion processing on the transmission data of the first transmission format after acquiring the transmission data of the first transmission format from the interface gateway, so that the service server can analyze the transmission data of the second transmission format executable by the code in the service server, obtain the access data indicated by the data access request, and after acquiring the access data, the service server can send the access data to the target application program through the interface gateway, and can realize the conversion of the protocol under the condition of not changing the logic, thereby realizing the development of the service request.
In one embodiment, the target application program may be any sub-application running in the client and not required to be installed, the user may log in the target application program through the client, it may be understood that the target application may be an applet in the client, the user may enter an interface of the applet supported by the client from the client after starting the client, as shown in fig. 5, the interface of the applet supported by the client includes one or more target application programs, and the client may associate different interface gateways with different target application programs based on the type of access service supported by each target application program in the applet interface, and add a protocol conversion device to the target application programs to implement conversion of the protocol format of the transmission data sent by the target application program to the interface gateway. In one embodiment, if the client is qq (an instant messaging software), the target application is an a program in the client, the a program may be, for example, a lover space as shown in fig. 5, please refer to a flowchart shown in fig. 6, and the process of accessing data by the a program to the service server is described in detail by taking the a program as an example, specifically, after logging in qq, the user may complete login registration of the a program by using a corresponding login service, where the login service may be, for example, a qq login service, such as qq.log () service, and after logging in the a program, the user may initiate a data access request through a data access interface of an internal applet, where the data access interface may be a service interface implemented based on the wnsRequest () service.
The data access request of the program A is required to be sent to a program login platform firstly, the program login platform is an SSO single sign-on software development kit (Software Development Kit, SDK) platform, after the program login platform receives the data request, an identity authentication identifier, such as an a2key identifier, can be added to the data access request firstly, and further can acquire other identity authentication identifiers, such as a skey/pskey identifier, cached in qq according to a domain name, the program login platform can generate an identity authentication sequence (a 2 key/skey/pskey) associated with the data access request based on the identity authentication identifier added to the data access request, after the program login platform generates the identity authentication sequence, the identity authentication sequence can be sent to a login channel (or SSO login background) through a sending server provided by the SSO platform, the identity authentication sequence can be sent to an interface gateway (or called a lover) corresponding to the program A through wns _pitch service after the identity authentication sequence sent by the program login platform is received, and the bag body can be checked and the data is acquired by a bag body gateway corresponding to the program A, namely, after the program login request is checked, the data is transmitted to a json the basis of a request, and a transmission format is checked.
After the interface gateway obtains the json inclusion (the transmission data in the first transmission format), the json inclusion may be forwarded to a protocol conversion device (such as protocol conversion svr), where the protocol conversion device may first convert, based on the configuration file, the digital identity identifier in the json inclusion (such as openid centered on the user) into an account uin (such as qq account) of the login client, and further may convert the json inclusion into qza packets, where the data format in the qza packets is the second transmission format, and send the qza packets (i.e. the transmission packets in the second transmission format) to the service server. After receiving the qza packet, the service server may invoke a code to parse the transmission data in the second transmission format and send qza a packet back to the protocol conversion device, where the qza packet back includes access data indicated by the data access request, after the protocol conversion device receives the qza packet back, the service server may convert the uin in the qza packet back into an openid according to the configuration file and convert the qza packet back into a json packet back, and after the protocol conversion device obtains the json packet back, the service server may forward the json packet back to the program a through the interface gateway, so that the program a receives the access data indicated by the data access request.
Referring to fig. 7, a schematic flowchart of a data processing method according to an embodiment of the present invention may also be applied to the above-mentioned protocol conversion device, as shown in fig. 7, where the method may include:
S701, obtaining transmission data in a first transmission format from an interface gateway, wherein the transmission data in the first transmission format is obtained after the interface gateway converts a data access request of a target application program according to the first transmission format.
In an embodiment, the specific real-time manner of step S701 can be referred to the specific implementation of step S201 in the above embodiment, which is not described herein.
S702, performing format conversion processing on the transmission data in the first transmission format to obtain transmission data in a second transmission format.
And S703, transmitting the transmission data of the second transmission format to a service server.
In step S702 and step S703, the protocol conversion device needs to determine whether the target application program has the right to access the service server before performing the format conversion processing on the transmission data in the first transmission format, and perform the transmission format conversion when determining that the target application program has the right to access the service server, so as to avoid performing unnecessary transmission format conversion operation. In a specific implementation, the protocol conversion device may first obtain a target user identifier, where the target user identifier is an identifier for logging in a client corresponding to the target application program, for example, the target user identifier may be a login account of the client, etc. after the protocol conversion device obtains the target user identifier, authorization information may be obtained according to the target user identifier, where the authorization information is generated when the service server determines that the service server responds to a data access request sent by the target application program, and it may be understood that the service server may preset access rights of different user identifiers to the service server, and send authorization information to a user identifier having access to the service server, where after obtaining transmission data in a first transmission format, the protocol conversion device may perform processing of the transmission data in the first transmission format only when obtaining the authorization information, in order to avoid that after the service server does not support a response to the access data and the protocol conversion device cannot send the transmission data in the second transmission format to the service server. In one embodiment, when the protocol conversion device obtains the target user identifier, since the digital identifier (such as openid) when the user logs in to the target application program is stored in the transmission data in the first transmission format, that is, the protocol conversion device may first obtain the digital identifier logged in to the target application program from the transmission data in the first transmission format, so that the identifier conversion rule indicated by the configuration file may be adopted to convert the digital identifier into the target user identifier. The transmission data in the first transmission format is obtained after the interface gateway passes the login authentication information of the target application program, and the login authentication information is sent after the target user logs in the target application program.
In one embodiment, the target application program comprises any sub-application which runs in the target client and does not need to be installed, the number of the sub-applications running in the target client is a plurality, and any sub-application running in the target client is associated with different interface gateways; the target application program is associated with the interface identifier of the corresponding interface gateway based on the type of business service supported by the target application program. When the transmission data in the first transmission format is processed by the protocol conversion device to obtain the transmission data in the second transmission format, the protocol conversion device can firstly obtain the interface identifier of the interface gateway corresponding to the target application program and obtain the target structure body type associated with the interface identifier from the conversion configuration file because the target application program is provided with the corresponding interface gateway, and further, the protocol conversion device can call the reflection mechanism to obtain the target structure body indicated by the target structure body type and transmit the transmission data in the text data exchange format into the target structure body to obtain the transmission data in the second transmission format, wherein the protocol conversion device is based on the reflection mechanism realized by the reflection database, such as a runtime type reflection database (Run Time Type Reflection, rttr database). In one embodiment, the target structure type includes a local structure, where the local structure includes one or more instance object parameters, when transmitting transmission data in a text data exchange format to the target structure to obtain transmission data of a second transmission event, the protocol conversion device may first read character string data from the transmission data in the text data exchange format (i.e., json format), determine a target instance object parameter corresponding to the character string data from the local structure (class structure), and thus may perform a serialization encoding process on the character string data, and use the encoded character string data as a value of the target instance object parameter to obtain transmission data in the second transmission format.
In one embodiment, if the character string in json format, that is, the transmission data in the first transmission format is { "int9", "name Zhang san" }, when the character string in json format is converted into the class structure for transmission, the class name (that is, class name) of the class structure may be generated based on the configuration file, and the class name may be, for example, the identity of Zhang san, so that the character string data "int9" and "name Zhang san" may be transmitted into the class structure with the identity Zhang san based on the configuration file, to obtain the transmission data in the second transmission format:
identity of Class Zhang III
{age=9;
name=Zhang san }.
After the protocol conversion device obtains the transmission data of the second transmission format, the transmission data of the second transmission format can be sent to the service server. Before the protocol conversion device sends the transmission data in the second transmission format to the service server, the access service type indicated by the data access request can be obtained from the target field of the transmission data in the first transmission, so that the transmission data in the second transmission format can be sent to the service server matched with the access service type, and the service server can process the transmission data in the second transmission format to obtain the access data corresponding to the access data request.
S704, obtaining the feedback data of the second transmission format from the service server, and performing format conversion processing on the feedback data of the second transmission format to obtain the feedback data of the first transmission format.
And S705, sending the feedback data of the first transmission format to the interface gateway, so that the interface gateway analyzes the feedback data of the first transmission format to obtain the access data, and sending the access data to the target application program.
In step S704 and step S705, after obtaining the transmission data of the second transmission format, the service server may add the access data to the transmission data of the second transmission format according to the second transmission format after obtaining the access data indicated by the data access request, to obtain feedback data of the second transmission format (i.e. the above qza packet is obtained, i.e. the service server processes the transmission data of the second transmission format, and obtains the access data indicated by the data access request, and then returns the access data in the second transmission format), further, may perform format conversion processing on the transmission data of the second transmission format to obtain feedback data of the first transmission format, and in a specific implementation, the second transmission format includes a local structure (i.e. a class structure), and when performing format conversion processing on the feedback data of the second transmission format, the protocol conversion device may obtain the value of each instance object parameter from the local structure, so as to perform inverse sequence processing on the value of each instance parameter, and then send the feedback data string as the feedback data of the target access data to the target application, so as to obtain the feedback data string of the target access data.
In the embodiment of the invention, after the protocol conversion device obtains the transmission data of the first transmission format corresponding to the data access request from the interface gateway, the format conversion processing can be performed on the transmission data of the first transmission format to obtain the transmission data of the second transmission format, so that the transmission data of the second transmission format can be sent to the service server, the service server can read the transmission data of the second transmission format to obtain the access data indicated by the data access request, the access data is encapsulated into the feedback data of the second transmission format and sent to the protocol conversion device, the protocol conversion device can convert the feedback data of the second transmission format into the feedback data of the first transmission format and send the feedback data of the first transmission format to the interface gateway, the target application program can obtain the access data indicated by the data access request from the interface gateway, the conversion of the transmission data protocol format can be realized, the conversion of different protocol formats can be realized by changing the mode of the configuration file in the protocol conversion device, and the development efficiency of the protocol conversion device is improved.
Based on the above description of the embodiments of the data processing method, the embodiments of the present invention also provide a data processing apparatus, which may be a computer program (including program code) running in the above server. The data processing apparatus may be used to perform the data processing method as described in fig. 2 and 7, referring to fig. 8, the data processing apparatus includes: anacquisition unit 801, aconversion unit 802, and atransmission unit 803.
An obtainingunit 801, configured to obtain, from an interface gateway, transmission data in a first transmission format, where the transmission data in the first transmission format is obtained by converting, by the interface gateway, a data access request of a target application program according to the first transmission format;
aconversion unit 802, configured to perform format conversion processing on the transmission data in the first transmission format, so as to obtain transmission data in a second transmission format;
a sendingunit 803, configured to send the transmission data in the second transmission format to a service server;
the obtainingunit 801 is further configured to receive access data indicated by the data access request obtained by the service server executing the transmission data in the second transmission format, and send the access data to the target application program through the interface gateway.
In one embodiment, the first transmission format includes: a text data exchange format; theconversion unit 802 is specifically configured to:
acquiring an interface identifier of the interface gateway, and acquiring a target structure type associated with the interface identifier from a conversion configuration file;
and calling a reflection mechanism to acquire a target structure body indicated by the type of the target structure body, and transmitting the transmission data in the text data exchange format into the target structure body to acquire the transmission data in a second transmission format.
In one embodiment, the target structure type includes a local structure including one or more instance object parameters; theconversion unit 802 is specifically configured to:
reading character string data from the transmission data in the text data exchange format, and determining target instance object parameters corresponding to the character string data from the local structure body;
and carrying out serialization coding processing on the character string data, and taking the character string data subjected to coding processing as the value of the object parameter of the target instance to obtain transmission data in a second transmission format.
In one embodiment, the target application includes any sub-application that runs in the target client and does not need to be installed;
the number of the sub-applications running in the target client is a plurality of, and any one of the sub-applications running in the target client is associated with different interface gateways;
the target application program is associated with the interface identifier of the corresponding interface gateway based on the type of business service supported by the target application program.
In one embodiment, the apparatus further comprises: and anexecution unit 804.
The obtainingunit 801 is further configured to obtain a target user identifier, and obtain authorization information according to the target user identifier, where the authorization information is generated when the service server determines to respond to a data access request sent by the target application program;
And anexecution unit 804, configured to execute the step of performing format conversion processing on the transmission data in the first transmission format when the authorization information is successfully acquired.
In one embodiment, the obtainingunit 801 is specifically configured to:
acquiring a digital identity when logging in the target application program;
and converting the digital identity into a target user identity by adopting an identity conversion rule indicated by a configuration file, wherein the target user identity is used for logging in a target client to which the target application program belongs.
In one embodiment, the obtainingunit 801 is further configured to obtain, from a target field of the transmission data in the first transmission format, an access service type indicated by the data access request;
the sendingunit 803 is specifically configured to:
and transmitting the transmission data of the second transmission format to a business server matched with the access service type.
In one embodiment, the service server adds the access data to the transmission data of the second transmission format according to the second transmission format to obtain feedback data of the second transmission format; the sendingunit 803 is specifically configured to:
Acquiring feedback data of the second transmission format from the service server, and performing format conversion processing on the feedback data of the second transmission format to obtain feedback data of the first transmission format;
and sending the feedback data of the first transmission format to the interface gateway, so that the interface gateway analyzes the feedback data of the first transmission format to obtain the access data, and sending the access data to the target application program.
In one embodiment, the second transmission format includes: a local structure; theconversion unit 802 is specifically configured to:
obtaining a value of each instance object parameter from the local structure;
and performing inverse serialization decoding processing on the value of each instance object parameter to obtain corresponding character string data, and taking the character string data as feedback data of the first transmission format.
In one embodiment, the transmission data in the first transmission format is that the interface gateway obtains login information from the target application program and authenticates the login information;
the login information is sent to the interface gateway after the target user logs in the target application program.
In one embodiment, the access data is obtained by the service server invoking execution of the transmission data with the second transport format adaptation code.
In the embodiment of the present invention, the interface gateway may convert the data access request in the target application according to the first transmission format to obtain the transmission data in the first transmission format, because the code in the service server does not support the execution of the transmission data in the first transmission format, in order to enable the service server to respond to the data access request, after determining the transmission data in the first transmission format, the interface gateway may first send the transmission data in the first transmission format to the protocol conversion device to perform protocol format (or transmission format) conversion, correspondingly, the obtainingunit 801 may perform format conversion processing on the transmission data in the first transmission format after obtaining the transmission data in the first transmission format from the interface gateway, so as to obtain the transmission data in the second transmission format executable by the code in the service server, and after obtaining the access data, the service server may send the access data in the first transmission format to the target application through the interface gateway, so as to implement the conversion of the protocol under the condition of not changing the service server, thereby implementing the service request development of the service efficiency.
Referring to fig. 9, a schematic block diagram of a protocol conversion device provided by the embodiment of the present invention may be disposed in a gateway server corresponding to an interface gateway, or may be disposed in a service server, or the protocol conversion device may be an independent server, in an embodiment, the server may be an independent physical server, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, middleware service, a domain name service, a security service, a CDN, and a big data and artificial intelligent platform. The protocol conversion device in the present embodiment as shown in fig. 9 may include: one or more processors 121; one or more input devices 122, one or more output devices 123, and a memory 124. The processor 121, the input device 122, the output device 123, and the memory 124 are connected by a bus 125. The memory 124 is used for storing a computer program comprising program instructions and the processor 121 is used for executing the program instructions stored by the memory 124.
The memory 124 may include volatile memory (RAM), such as random-access memory (RAM); the memory 124 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a Solid State Drive (SSD), etc.; memory 124 may also include a combination of the types of memory described above.
The processor 121 may be a central processing unit (central processing unit, CPU). The processor 121 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (programmable logic device, PLD), or the like. The PLD may be a field-programmable gate array (field-programmable gate array, FPGA), general-purpose array logic (generic array logic, GAL), or the like. The processor 121 may be a combination of the above structures.
In an embodiment of the present invention, the memory 124 is configured to store a computer program, where the computer program includes program instructions, and the processor 121 is configured to execute the program instructions stored in the memory 124, to implement the steps of the corresponding methods shown in fig. 2 and 7.
In one embodiment, the processor 121 is configured to call the program instructions for executing:
acquiring transmission data in a first transmission format from an interface gateway, wherein the transmission data in the first transmission format is obtained by converting a data access request of a target application program by the interface gateway according to the first transmission format;
performing format conversion processing on the transmission data of the first transmission format to obtain transmission data of a second transmission format, and sending the transmission data of the second transmission format to a service server;
and receiving access data indicated by the data access request obtained by the service server executing the transmission data in the second transmission format, and sending the access data to the target application program through the interface gateway.
In one embodiment, the first transmission format includes: a text data exchange format; the processor 121 is configured to call the program instructions for executing:
acquiring an interface identifier of the interface gateway, and acquiring a target structure type associated with the interface identifier from a conversion configuration file;
and calling a reflection mechanism to acquire a target structure body indicated by the type of the target structure body, and transmitting the transmission data in the text data exchange format into the target structure body to acquire the transmission data in a second transmission format.
In one embodiment, the target structure type includes a local structure including one or more instance object parameters; the processor 121 is configured to call the program instructions for executing:
reading character string data from the transmission data in the text data exchange format, and determining target instance object parameters corresponding to the character string data from the local structure body;
and carrying out serialization coding processing on the character string data, and taking the character string data subjected to coding processing as the value of the object parameter of the target instance to obtain transmission data in a second transmission format.
In one embodiment, the target application includes any sub-application that runs in the target client and does not need to be installed;
the number of the sub-applications running in the target client is a plurality of, and any one of the sub-applications running in the target client is associated with different interface gateways;
the target application program is associated with the interface identifier of the corresponding interface gateway based on the type of business service supported by the target application program.
In one embodiment, the processor 121 is configured to call the program instructions for executing:
Acquiring a target user identifier, and acquiring authorization information according to the target user identifier, wherein the authorization information is generated when the service server determines to respond to a data access request sent by the target application program;
and executing the step of performing format conversion processing on the transmission data of the first transmission format when the authorization information is successfully acquired.
In one embodiment, the processor 121 is configured to call the program instructions for executing:
acquiring a digital identity when logging in the target application program;
and converting the digital identity into a target user identity by adopting an identity conversion rule indicated by a configuration file, wherein the target user identity is used for logging in a target client to which the target application program belongs.
In one embodiment, the processor 121 is configured to call the program instructions for executing:
acquiring an access service type indicated by the data access request from a target field of transmission data of the first transmission format;
the sending the transmission data in the second transmission format to a service server includes:
and transmitting the transmission data of the second transmission format to a business server matched with the access service type.
In one embodiment, the service server adds the access data to the transmission data of the second transmission format according to the second transmission format to obtain feedback data of the second transmission format; the processor 121 is configured to call the program instructions for executing:
acquiring feedback data of the second transmission format from the service server, and performing format conversion processing on the feedback data of the second transmission format to obtain feedback data of the first transmission format;
and sending the feedback data of the first transmission format to the interface gateway, so that the interface gateway analyzes the feedback data of the first transmission format to obtain the access data, and sending the access data to the target application program.
In one embodiment, the second transmission format includes: a local structure; the processor 121 is configured to call the program instructions for executing:
obtaining a value of each instance object parameter from the local structure;
and performing inverse serialization decoding processing on the value of each instance object parameter to obtain corresponding character string data, and taking the character string data as feedback data of the first transmission format.
In one embodiment, the transmission data in the first transmission format is that the interface gateway obtains login information from the target application program and authenticates the login information;
the login information is sent to the interface gateway after the target user logs in the target application program.
In one embodiment, the access data is obtained by the service server invoking execution of the transmission data with the second transport format adaptation code.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like.
The foregoing disclosure is merely illustrative of some embodiments of the present invention and it is not to be construed as limiting the scope of the invention, as a person of ordinary skill in the art will appreciate that all or part of the above-described embodiments may be practiced with equivalent variations which fall within the scope of the invention as defined in the appended claims.