CN115589440B - Message annotation configuration method, packet packing method and parsing method - Google Patents

Message annotation configuration method, packet packing method and parsing method Download PDF

Info

Publication number
CN115589440B
CN115589440B CN202211588532.2A CN202211588532A CN115589440B CN 115589440 B CN115589440 B CN 115589440B CN 202211588532 A CN202211588532 A CN 202211588532A CN 115589440 B CN115589440 B CN 115589440B
Authority
CN
China
Prior art keywords
message
annotation
type
data
length
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211588532.2A
Other languages
Chinese (zh)
Other versions
CN115589440A (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.)
Beijing Murong Information Technology Co ltd
Original Assignee
Beijing Murong Information 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 Beijing Murong Information Technology Co ltd filed Critical Beijing Murong Information Technology Co ltd
Priority to CN202211588532.2A priority Critical patent/CN115589440B/en
Publication of CN115589440A publication Critical patent/CN115589440A/en
Application granted granted Critical
Publication of CN115589440B publication Critical patent/CN115589440B/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/22Parsing or analysis of headers
    • 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/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application relates to a message annotation configuration method, a packet packing method and an analysis method. Marking the message annotation on the attribute of a target entity class Javabean corresponding to the message type to be annotated to realize the configuration of the message annotation; the message annotation comprises a message prefix length annotation, a message header annotation and an application data annotation. By adopting the scheme, the analysis/coding rule does not need to be configured by independently using the xml file, and other files do not need to be configured independently; the configuration of the analysis/coding rules can be realized without departing from the programming source code, so that the development efficiency can be improved to a certain extent.

Description

Message annotation configuration method, packet packing method and parsing method
Technical Field
The present application relates to the field of computer communications, and in particular, to a packet annotation configuration method, a packet packing method, and an parsing method.
Background
A message (message) is a unit of data exchanged and transmitted in a network, and generally consists of a message length, a message header and data content.
In order to realize information interaction, the message needs to be parsed/encoded by adopting corresponding standards or rules, and these standards/rules are currently configured by adopting xml files. When a program is developed, a programmer is required to complete source code development, and an xml file is independently used for configuring the analysis/coding rule of the message.
Disclosure of Invention
The application provides a message annotation configuration method, a package method and an analysis method, which do not need to use an xml file alone to configure analysis/coding rules and also do not need to use other files alone to configure, and belong to a brand-new configuration method, package method and analysis method; meanwhile, the development efficiency can be improved to a certain extent.
In a first aspect, the present application provides a method for configuring a message annotation, which adopts the following technical scheme:
marking the message annotation on the attribute of a target entity class Javabean corresponding to the message type to be annotated to realize the configuration of the message annotation; the message annotation comprises a message prefix length annotation, a message header annotation and an application data annotation.
By adopting the technical scheme: directly configuring the parsing/encoding rules of the messages on the attributes of target entity classes Javabeans corresponding to the types of the messages to be annotated in an annotation mode without independently using xml files to configure the parsing/encoding rules or independently using other files to configure the parsing/encoding rules; the configuration of the analysis/coding rules can be realized without separating from the programming source code, so that the development efficiency can be improved to a certain extent.
Optionally, the application data annotation includes a message type annotation, a bitmap annotation and a data content annotation; the header annotation includes a TPDU (transport protocol data unit) annotation and/or a header annotation.
By adopting the technical scheme, the message header annotation is divided into two parts of TPDU annotation and message header annotation, and the application data annotation is divided into three parts of message type annotation, bitmap annotation and data content annotation.
Optionally, the application data annotation and the header annotation both include the following attributes:
a field ID, a length type length, a data type datatype, a data length datalength, a variable length prefix type varType, an alignment mode align mode, a data conversion convert, a coded character set encoding, and a character filling manner fillAsc.
By adopting the technical scheme, the attribute types of the fields of the application data annotation and the message header annotation are determined.
Optionally, the length type length includes: a fixed length type-CONST, a two-position front length type VAR2, a three-position front length type VAR3, a four-position front length type VAR4, a five-position front length type VAR5, a six-position front length type VAR6 and an eight-position front length type VAR8;
the data type datetype includes: ASCII character type CHAR _ ASCII, ASCII digital type NUM _ ASCII, binary BIT pattern BIT, character compression type ASCBCD, digital compression type NUMBCD;
the variable-length prefix type varType includes: binary BIN, string type CHAR;
the alignment mode align mode includes: LEFT aligned LEFT, right aligned Right;
the data conversion convert includes: 16-system characters, common character strings;
the encoding character set encoding includes: ASCLL, ISO-8859-1, GB2312, GBK, GB18030, UTF-8, UTF-16, unicode;
the character filling manner fillAsc includes: BCD fills in 0 and ascii fills in spaces.
By adopting the technical scheme, the specific classification of the related attributes is determined.
Optionally, the message prefix length annotation includes: a prefix length, and a prefix length type.
Optionally, the prefix length type prelengtype includes: 16-ary character type BCD, binary type BIN, digital character type STRING.
By adopting the technical scheme, the fields corresponding to the message pre-length annotations, the attribute categories of the fields and the specific classification of the corresponding attributes are determined.
Optionally, the range of the domain ID of the data content annotation is [0,128], and the range of the domain ID of the header annotation is [300,999].
By adopting the technical scheme, the new message data structure carries out message domain segmentation on the data content and the message header, expands the length of the message structure and can improve the compatibility.
Optionally, the type of the message to be annotated includes an ISO8583 type message.
By adopting the technical scheme, the UnionPay ISO8583 type message is determined.
In a second aspect, the present application provides a packet packaging method, which adopts the following technical scheme:
obtaining an entity class Javabean to be packaged marked with a message annotation, wherein the message annotation comprises the message annotation configured by the message annotation configuration method;
acquiring a header annotation of the message and a first variable value corresponding to a header field of the message from the entity class java bean to be packaged; converting the first variable value into corresponding first message domain coding data according to the message header annotation;
acquiring application data annotation and a second variable value corresponding to an application data field from the entity class Javabean to be packaged; converting the second variable value into corresponding second message domain coding data according to the application data annotation;
after converting a first variable value corresponding to each message header field and a second variable value corresponding to each application data field to obtain corresponding message domain coded data, calculating a data total length value of each first message domain coded data and each second message domain coded data;
acquiring a message pre-length annotation from the entity class Javabean to be packaged; converting the total length value of the data into corresponding third message domain coded data according to the message pre-length annotation;
and packaging the third message domain coded data, the first message domain coded data and the second message domain coded data in sequence to obtain a message.
By adopting the technical scheme, the packet packaging process is realized.
In a third aspect, the present application provides a method for parsing a packet, which adopts the following technical scheme:
acquiring a message to be analyzed and an entity class Javabean for message analysis, wherein the entity class Javabean for message analysis is marked with a message annotation corresponding to the message to be analyzed; the message annotation comprises the message annotation configured by the message annotation configuration method;
acquiring a header annotation of the message from the entity class Javabean for message analysis; analyzing the message to be analyzed according to the message header annotation to obtain fourth message domain coded data corresponding to each field in the message header, and respectively analyzing and converting the fourth message domain coded data to obtain variable values of the corresponding fields;
acquiring application data annotation from the entity class Javabean for message analysis; analyzing the message to be analyzed according to the application data annotation to obtain fifth message domain coded data corresponding to each field in the application data, and analyzing and converting the fifth message domain coded data to obtain variable values of the corresponding fields;
respectively writing the variable values into corresponding fields of a newly created entity class Javabean;
and writing the newly created entity class Javabean corresponding to the variable value based on the corresponding field to obtain the analysis message of the message to be analyzed.
By adopting the technical scheme, the message analysis process is realized.
In summary, the present application includes at least the following advantageous technical effects:
1. directly configuring the parsing/coding rules of the messages on the attributes of the target entity class Javabeans corresponding to the message types to be annotated in an annotation mode without independently using xml files to configure the parsing/coding rules or independently using other files to configure; the configuration of the analysis/coding rules can be realized without departing from the programming source code, so that the development efficiency can be improved to a certain extent.
2. The scheme is suitable for the configuration of Unionpay ISO8583 type messages.
Drawings
Fig. 1 is a schematic flowchart of a message annotation configuration method in an embodiment of the present application;
fig. 2 is a schematic flow chart of a packet packaging method in the embodiment of the present application;
fig. 3 is a schematic flow chart of another packet packaging method in the embodiment of the present application;
fig. 4 is a schematic flow chart of a message parsing method in the embodiment of the present application;
fig. 5 is a schematic flow chart of another message parsing method in this embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to fig. 1-5 and the embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The embodiment of the application discloses a message annotation configuration method.
Referring to fig. 1, a message annotation method includes the following steps:
s101: marking the message annotation on the attribute of a target entity class Javabean corresponding to the message type to be annotated to realize the configuration of the message annotation; the message annotation comprises a message prefix length annotation, a message header annotation and an application data annotation.
According to the embodiment, the analysis/coding rule does not need to be configured by using an xml file independently, and also does not need to be configured by using other files independently; the parsing/coding rules of the message are directly configured on the attributes of the target entity class Javabean corresponding to the message type to be annotated in an annotation mode, so that the parsing/coding rules can be configured without departing from a programming source code, and the development efficiency can be improved to a certain extent.
In the optional embodiment of the application, the header annotation of the message can be divided into two parts, namely, a TPDU annotation and a header annotation, and the application data annotation is divided into three parts, namely, a message type annotation, a bitmap annotation and a data content annotation.
The TPDU annotation is mainly used to annotate fields such as routing information, for example, including a destination address and a source address.
The header annotation is used to annotate fields such as application class definitions, total version numbers, terminal states, processing requirements and division number.
Application data annotation is used for annotating fields such as message type, bitmap, and data content (body).
In an alternative embodiment of the present application, the available message structure includes the following fields: message prefix length + destination address + source address + application type definition + total version number + terminal state + processing requirement + split version number + message type + bitmap + data content.
In an alternative embodiment of the present application, the number of bitmaps may include 1 or 2, and is used to define different message domain ranges. For example, bitmap 1 defines message fields 2 through 64 and bitmap 2 defines message fields 66 through 128.
In an optional embodiment of the present application, the fields of the application data annotation and the header annotation both include the following attributes:
a field ID, a length type length, a data type datatype, a data length datalength, a variable length prefix type varType, an alignment mode align mode, a data conversion convert, a coded character set encoding, and a character filling manner fillAsc.
The length type length includes the following 7 types: a fixed length type-CONST, a two-bit pre-length type VAR2, a three-bit pre-length type VAR3, a four-bit pre-length type VAR4, a five-bit pre-length type VAR5, a six-bit pre-length type VAR6 and an eight-bit pre-length type VAR8.
The data type datetype includes 5 types as follows: ASCII character type CHAR _ ASCII, ASCII digital type NUM _ ASCII, binary BIT pattern BIT, character compression type ASCBCD, and digital compression type NUMBCD.
The variable length prefix type varType includes 2 types as follows: binary BIN, string type CHAR.
The alignment mode align mode includes the following 2 types: left alignment, right alignment.
The data conversion convert includes the following 2 types: 16-ary character, normal string.
The encoding character set encoding includes the following 8 types: ASCLL, ISO-8859-1, GB2312, GBK, GB18030, UTF-8, UTF-16, unicode.
The character filling pattern fillAsc includes the following 2 types: BCD fills in 0 and ascii fills in spaces.
Based on the above annotation about the header of the message and the annotation of the content data, the configuration of the relevant fields of the header of the message and the content data is realized.
In an optional embodiment of the present application, the message prefix length annotation includes the following attributes: a prefix length, and a prefix length type.
The prefix length type prelengtype includes the following 3 specific classifications: 16-ary character type BCD, binary type BIN, digital character type STRING.
The configuration of the message prefix length field is realized through the message prefix length annotation.
In an optional embodiment of the present application, the message domain is divided into two segments, where the domain ID [0,128] is used as the domain value range of the data content annotation, and the domain ID [300,999] is used as the domain value range of the message header annotation.
That is, in the embodiment, the data content and the message header are subjected to message domain segmentation, and meanwhile, compared with the domain value range of the existing message [1,128], the message structure length is extended, so that more data information can be carried in one message, more use scenes can be met, and the message compatibility can be improved.
The optional embodiment of the application is particularly suitable for performing annotation configuration on the Unionpay ISO8583 type message.
For ease of understanding, please see the following configuration examples:
@ISO8583(prelength=2,prelengthType=HeadPrelengthType.BIN)
Public class DefaultISO8583Data{
@ISO8583Header
DefaultISO8583Header header;
/**
* Message type
*/
@ISO8583Field(id=0,lengthType=CONST,dataType=ASCBCD,length=4)
String masgId;
/**
* Bitmap
*/
@ISO8583Field(id=1,lengthType=CONST,dataType=BIT,length=16)
Byte[] bitmap;
/**
* Account number
*/
@ISO8583Field(id=2,lengthType=VAR2,dataType=ASCBCD,length=19,alignMode=LEFT,varType=BIN)
String pan;
}
@Data
Public class DefaultISO8583Header {
@ISO8583Field(id=302,lengthType=CONST,dataType=ASCBCD,length=10)
String tpdu;
@ISO8583Field(id=303,lengthType=CONST,dataType=ASCBCD,length=12)
String head;
}
Based on the same design concept, the embodiment also discloses a packet packaging method.
Referring to fig. 2, a packet packaging method includes:
s201, obtaining an entity class Javabean to be packaged marked with message annotation, wherein the message annotation comprises the message annotation configured by the method for configuring the report annotation.
It should be understood that the entity class java bean to be packaged not only includes the message annotation, but also includes the variable values of the fields used for generating the message, and the fields and the corresponding variable values can be obtained correspondingly according to the actual requirements. For example, when the POS machine requests for transaction, the obtained corresponding transaction information is sent to a service center to request for completing the corresponding transaction; the transaction information includes, but is not limited to, transaction card number, amount, time, etc.
S202, obtaining a header annotation of the message and a first variable value corresponding to a header field of the message from the entity class javabean to be packaged.
In an optional embodiment of the present application, the header annotation includes a TPDU annotation and a header annotation. Wherein the TPDU note comprises notes on fields such as destination address and source address; the header comments include comments for fields such as application category definitions, total version number, POS terminal status, processing requirements, and division number.
The attributes of the specific annotations include: a field ID, a length type length, a data type datatype, a data length datalength, a variable length prefix type varType, an alignment mode align mode, a data conversion convert, a coded character set encoding, and a character filling manner fillAsc.
The length type length comprises: a fixed length type-CONST, a two-position front length type VAR2, a three-position front length type VAR3, a four-position front length type VAR4, a five-position front length type VAR5, a six-position front length type VAR6 and an eight-position front length type VAR8;
the data type datatype includes: ASCII character type CHAR _ ASCII, ASCII digital type NUM _ ASCII, binary BIT pattern BIT, character compression type ASCBCD, digital compression type NUMBCD;
the variable-length prefix type varType includes: binary BIN, string type CHAR;
the alignment mode align mode includes: LEFT aligned LEFT, right aligned Right;
the data conversion convert includes: 16-system characters, common character strings;
the encoding character set encoding includes: ASCLL, ISO-8859-1, GB2312, GBK, GB18030, UTF-8, UTF-16, unicode;
the character filling pattern fillAsc includes: BCD fills in 0 and ascii fills in spaces.
Taking the example that the POS terminal initiates a transaction request to the service center, the variable value of the destination address field corresponding to the TPDU is the IP address of the service center; the variable value corresponding to the source address field is the IP address of the POS terminal.
S203, converting the first variable value into corresponding first message domain coded data according to the header annotation of the message.
Because the header annotation of the message configures the relevant attributes of the destination address field and the source address field, the variable values of the destination address field and the source address field can be converted according to the configured attributes, so that corresponding encoded data is obtained, and the encoding process is realized.
S204, acquiring the application data annotation and a second variable value corresponding to the application data field from the entity class Javabean to be packaged.
In an alternative embodiment of the present application, the application data field includes, for example, a message type, a bitmap, and a content data field. The message type may include, for example, transaction type, authentication type, file update type, etc. variable values; specifically, the attribute may include a domain ID, a length type length, a data type datatype, a length, and the like. The other fields work the same.
And S205, converting the second variable value into corresponding second message domain coded data according to the application data annotation.
As above, since the application data annotation configures the relevant attribute of each field of the application data, the variable value of each field of the application data can be converted according to the configured attribute, so as to obtain the corresponding encoded data, thereby implementing the encoding process. And will not be described in detail herein.
It should be understood that steps S202 to S203, and steps S204 to S205 may be processed in parallel, or may be processed sequentially, and this may be flexibly selected.
S206, after the first variable value corresponding to each message header field and the second variable value corresponding to each application data field are converted to obtain corresponding message domain coded data, calculating the total data length value of each first message domain coded data and each second message domain coded data.
Specifically, the total length value of the data can be obtained by performing summation based on the lengths of the message domain coded data corresponding to each field.
S207, obtaining a message pre-length annotation from the entity class Javabean to be packaged.
The message prefix length annotation comprises a prefix length and a prefix length type. The prefix length type prelengtype includes 16-system character type BCD, binary type BIN and digital character type STRING.
And S208, converting the total length value of the data into corresponding third message domain coded data according to the message pre-length annotation.
As above, since the message prefix length annotation configures the relevant attribute of the message prefix length field, the message prefix length value (i.e. variable value) can be converted according to the configured attribute, so as to obtain the corresponding encoded data, thereby implementing the encoding process of the variable value of the message prefix length. And will not be described in detail herein.
S209, the third message domain coded data, the first message domain coded data and the second message domain coded data are packaged according to the sequence to obtain a message.
In the optional embodiment of the present application, the packet domain coded data corresponding to each field is combined according to the domain ID sequence to obtain the corresponding packet, so as to implement the packet packaging process.
Referring to fig. 3, for better understanding of the grouping process, the following is specifically described in conjunction with the above configuration example:
a. and calling an encoding interface encode of the analyzer by taking the entity class Javabean to be packaged marked with the message annotation as an input parameter.
b. And acquiring whether the entity class Javabean to be packaged is configured with ISO8583 annotation from the cache 1, and returning a result according to the cache information in the cache 1. If yes, directly performing the step c; if not, judging whether the entity class Javabean to be packaged is configured with ISO8583 annotation or not, and putting the judgment result in the cache 1, thereby accelerating the next judgment efficiency. If it is decided that the ISO8583 annotation is configured, continue with step c below; and if the to-be-packaged entity class Javabean is judged to be unconfigured or not configured correctly, determining that the to-be-packaged entity class Javabean is abnormal.
c. And acquiring ISO8583 annotation configuration information of all fields of the entity class Javabean to be packaged.
c1. Acquiring ISO8583 comment configuration information of all fields of the to-be-packaged entity class Javabean from a cache 2 (namely another cache different from the cache 1); if the acquisition is successful, the direct use goes to step d, otherwise the following step c2 is continued.
c2. All fields containing ISO8583Field and ISO8583Header notes of the entity class to be packaged, namely Javabean, are obtained by using a Java reflection interface, and the information of the fields is cached in the cache 2. For the fields with ISO8583Header notes, the reflection interface is used again to analyze all the fields containing ISO8583Field notes in the Header notes, and the configuration information is put into the cache 2 as the information of the message Header fields.
d. According to the configuration of the 0 th Field in the annotation configuration information (namely, the Field annotated by using ISO8583Field, and the id value in the annotation is 0), the variable value of the 0 th Field (namely, the message type) is obtained from the entity class Javabean to be packaged, and the Field value is converted into binary data (namely, encoded data) according to the corresponding annotation configuration information.
e. Looping through all fields of the ISO8583Field annotation configuration, converting all fields of the content data into encoded data (i.e., encoded data), and returning a variable value of whether a message type exists in the bitmap Field.
f. And if the entity class Javabean to be packaged is configured with a message Header reader annotation, packaging all fields of the message Header.
f1. And judging whether the entity class Javabean to be packaged contains a Header annotation, and if not, returning null data with the length of 0.
f2. If the Header annotation is contained, all configuration fields annotated with ISO8583 fields in the Header are obtained, and variable values of the corresponding fields are converted to obtain corresponding coded data.
f3. The encoded data of each field generated by f2 are combined into one header encoded data (assumed to be encoded data 1) in the order of the field IDs of the configuration notes from small to large.
g. And converting the bitmap field message type variable value returned in the e step into bitmap coded data (message type coded data + bitmap coded data + content coded data, assumed as coded data 2) according to the annotation configuration.
h. Merging the data of the encoded data 1 and encoded data 2 groups into one large data (assumed to be encoded data 3);
i. judging 8583 whether the annotation configuration sets the message prefix length, if so, calculating the data total length value of the coded data 3, and generating the prefix length (assumed as coded data 4) of the data type required by the annotation configuration according to the message prefix length annotation conversion;
j. and combining the coded data 4 and the coded data 3 to form final return data to obtain a message packet.
Based on the same design concept, the embodiment also discloses a message analysis method.
Referring to fig. 4, a method for parsing a packet includes:
s401, obtaining a message to be analyzed and an entity Javabean for message analysis, wherein the entity Javabean for message analysis is marked with a message annotation corresponding to the message to be analyzed; the message annotation includes the message annotation configured by the message annotation configuration method.
For the configured message annotation, reference may be specifically made to the above description, and details are not described herein again.
S402, obtaining a header annotation of the message from an entity class Javabean for message analysis.
For specific configured header annotation, reference may be made to the above description, and details are not described herein again.
And S403, according to the header annotation of the message, analyzing the message to be analyzed to obtain fourth message domain encoded data corresponding to each field in the message header, and respectively analyzing and converting the fourth message domain encoded data to obtain variable values of the corresponding fields.
Because the header annotation of the packet is configured with the relevant attributes of the corresponding header field of the packet, such as the attributes of the field ID, the length type length, the data type data, and the data length, the header annotation of the packet to be parsed can be parsed based on the header annotation of the packet, so as to extract the packet domain encoded data (i.e., the fourth packet domain encoded data) corresponding to each field. It should be understood that each field corresponds to a message domain encoded data.
After the message domain encoded data of each field in the message header is obtained, the message domain encoded data also needs to be converted into a corresponding variable value, so as to realize decoding of the encoded data. Decoding can be performed according to the related attribute of the message header annotation configuration.
For example, the encoded data is converted into corresponding variable values according to the attribute configuration such as "alignment mode align mode", "data conversion convert", "encoding character set encoding", "character filling manner fillazc" configured by the header annotation of the packet. The specific conversion process may adopt any existing manner, and is not described herein again.
S404, obtaining application data annotation from the entity class Javabean for message analysis.
S405, according to the application data annotation, analyzing the message to be analyzed to obtain fifth message domain coded data corresponding to each field in the application data, and respectively analyzing and converting the fifth message domain coded data to obtain variable values of the corresponding fields.
It should be understood that steps S402-S403, and steps S404-S405 may be processed in parallel, or may be processed in series according to actual requirements, which is not limited.
The steps S404 to S405 implement the parsing of the application data in the message to be parsed based on the obtained application data annotation, which is similar to the parsing principle of the steps S402 to S403, and since the application data annotation is configured with the attribute configuration information of the relevant field related to the application data, the parsing of the application data in the message to be parsed can be implemented according to the application data annotation, so as to convert the message domain encoded data of each sub-segment in the application data into variable values, thereby implementing the parsing process. Details are not repeated.
S406, writing the variable values into corresponding fields of the newly created entity class Javabean.
In the embodiment of the application, an entity class Java bean can be newly established through a class new instance () method in Java, and the entity class Java bean is used for storing variable values of each field obtained through analysis.
S407, writing a newly created entity class Javabean with a corresponding variable value based on the corresponding fields (including all fields corresponding to the message header and each field corresponding to the application data), and obtaining an analysis message of the message to be analyzed.
It should be understood that the newly created entity class java bean has the variable values of each field obtained by parsing written in the message to be parsed, so that the parsed message of the message to be parsed can be obtained based on the newly created entity class java bean in which the corresponding variable values are written. Thereby realizing the message analysis process.
Referring to fig. 5, in order to better understand the message parsing process, the following description is made in detail with reference to the above configuration example:
a. and calling a decoding interface decode of the analyzer by taking the message to be analyzed and the entity class Javabean for message analysis as input parameters.
b. And acquiring whether the entity class Javabean is configured with ISO8583 annotation from the cache 3, and returning a result according to the cache information in the cache 3. If the returned result is that ISO8583 annotation is configured, directly performing the step c; otherwise, it needs to additionally determine whether the entity class Javabean is configured with ISO8583 annotation, and place the determination result in the cache 3 to accelerate the next determination efficiency. If the ISO8583 annotation is judged to be configured, continuing the step c; if the entity class is not configured or not configured correctly, otherwise, the exception of the entity class Javabean is thrown out.
c. And acquiring ISO8583 annotation configuration information of all fields of the entity class Javabean.
c1. Firstly, obtaining ISO8583 annotation configuration information of all fields of the entity class Javabean from a cache 4; if the obtaining is successful, directly using the cached annotation configuration information to execute the step d; if the annotation configuration information cannot be acquired, performing the following step c 2;
c2. using a Java reflection interface to acquire all fields containing ISO8583Field and ISO8583Header notes of the entity class Javabean, and caching the note configuration information of the fields into a cache 4; for the fields with ISO8583Header notes, a reflection interface is used again to analyze all the fields containing ISO8583Field notes in the Header notes, and the annotation configuration information is put into the cache 4 as message Header Field configuration information.
d. Judging whether a front length is configured in ISO8583 annotation configuration; if yes, the message to be analyzed has a prefix length, and the analyzer can skip or ignore message domain coded data corresponding to the prefix length in the message to be analyzed. This does not have a large effect on message parsing. Of course, in an alternative embodiment of the present application, the message domain encoded data corresponding to the pre-strength prelength may also be analyzed. It should be understood that if the pre-length is not configured in the ISO8583 annotation configuration, no processing may be done.
e. And (3) creating an instance which is the same as the Javabean type of the entity class by using a class New instance () method in Java.
f. Judging whether an ISO8583Header annotation is configured according to the ISO8583 annotation configuration information acquired in the step c; if yes, analyzing the message header data of the input message to be analyzed.
f1. Acquiring field configuration information in the annotation configuration information from the cache 4;
f2. generating the message header instance by using a class.
f3. Traversing and analyzing each field in a message header of the message to be analyzed according to the domain ID sequence of each field in the annotation configuration information, converting the message domain coded data of each field into variable values meeting the configuration requirements of relevant attributes according to the relevant attribute configuration in the annotation configuration information, and setting the variable values obtained by conversion into member variables of the corresponding fields of the message header example;
f4. and after all fields of the message header are analyzed, setting the message header instance into the message header field of the newly created entity class Javabean.
g. And c, analyzing the content data information in the message to be analyzed according to the 8583Field annotation configuration information acquired in the step c.
g1. Firstly, analyzing application data of a 0 th domain in a message to be analyzed according to annotation configuration information of the 0 th domain in the annotation configuration information; the 0 th field in the configuration example, namely the message type data field, converts the coded data of the field into a corresponding variable value and sets the variable value into a corresponding field of the newly created entity class Javabean.
g2. Analyzing the application data of the 1 st domain in the message to be analyzed according to the configuration information of the 1 st domain in the annotation configuration information; the 1 st field in the configuration example, namely the bitmap field, converts the coded data of the field into a corresponding variable value and sets the variable value into the corresponding field of the configuration class example.
g3. And judging all bitmap bits, if the value of the bitmap bit is 1, acquiring the coded data of corresponding content from the message content data field to be analyzed, analyzing the coded data of the field to convert the coded data into a corresponding variable value, and setting the variable value of the field into a corresponding field of the newly created entity class Javabean. It should be understood that if the bitmap bit value is 0, the corresponding encoded data does not have to be obtained. In addition, a specific manner of acquiring the encoded data of the corresponding content according to the bitmap field is specified in the union pay specification, and the content encoded data can be specifically acquired according to the specification.
h. And returning to the newly created entity class Javabean to obtain the analysis message.
In the embodiments provided in the present application, it should be understood that the disclosed method can be implemented in other ways.
The technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be implemented in a software product stored in a storage medium, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the storage medium includes: u disk, removable hard disk, read only memory, random access memory, magnetic or optical disk, etc. for storing program codes.
The above embodiments are only used to describe the technical solutions of the present application in detail, but the above embodiments are only used to help understanding the method and the core idea of the present application, and should not be construed as limiting the present application. Those skilled in the art should also appreciate that various modifications and substitutions can be made without departing from the scope of the present disclosure.

Claims (8)

1. A packet packaging method is characterized in that the packet packaging method comprises the following steps:
acquiring an entity class Javabean to be packaged marked with a message annotation, wherein the message annotation is marked on the attribute of the entity class Javabean to be packaged, and comprises a message front length annotation, a message header annotation and an application data annotation;
acquiring a header annotation of the message and a first variable value corresponding to a header field of the message from the entity class java bean to be packaged; converting the first variable value into corresponding first message domain coding data according to the message header annotation;
acquiring application data annotation and a second variable value corresponding to an application data field from the entity class Javabean to be packaged; converting the second variable value into corresponding second message domain coding data according to the application data annotation;
after the variable values of the fields corresponding to the message header and the variable values of the fields corresponding to the application data are converted to obtain corresponding message domain coded data, calculating the total data length values of the first message domain coded data and the second message domain coded data;
acquiring a message prefix length annotation from the entity class Javabean to be packaged; converting the total length value of the data into corresponding third message domain coded data according to the message pre-length annotation;
and packaging the third message domain coded data, the first message domain coded data and the second message domain coded data in sequence to obtain a message.
2. The method of claim 1, wherein the header annotation comprises a Transport Protocol Data Unit (TPDU) annotation and/or a header annotation; the application data annotation comprises a message type annotation, a bitmap annotation and a data content annotation.
3. The packet assembly method according to claim 2, wherein the message prefix length annotation includes a prefix length, a prefix length type; the application data annotation and the header annotation both include the following attributes:
the field ID, length type length, data type datatype, data length datalength, variable length prefix type varType, alignment mode align mode, data conversion convert, encoding character set encoding and character filling mode fillAsc.
4. The packet packaging method according to claim 3, wherein the length type length includes: a fixed length type-CONST, a two-position front length type VAR2, a three-position front length type VAR3, a four-position front length type VAR4, a five-position front length type VAR5, a six-position front length type VAR6 and an eight-position front length type VAR8;
the data type datetype includes: ASCII character type CHAR _ ASCII, ASCII digital type NUM _ ASCII, binary BIT pattern BIT, character compression type ASCBCD, digital compression type NUMBCD;
the variable-length prefix type varType includes: binary BIN, character string type CHAR;
the alignment mode align mode includes: left alignment and right alignment;
the data conversion convert includes: 16-system characters, common character strings;
the encoding character set encoding includes: ASCLL, ISO-8859-1, GB2312, GBK, GB18030, UTF-8, UTF-16, unicode;
the character filling manner fillAsc includes: BCD is filled with 0, and ASCII is filled with blank spaces;
the prefix length type prelengtype includes: 16-ary character type BCD, binary type BIN, digital character type STRING.
5. A message parsing method is characterized in that the message parsing method comprises the following steps:
acquiring a message to be analyzed and an entity class Javabean for message analysis, wherein a message annotation corresponding to the message to be analyzed is marked on the attribute of the entity class Javabean for message analysis; the message annotation comprises a message header annotation and an application data annotation;
acquiring a header annotation of the message from the entity class Javabean for message analysis; analyzing the message to be analyzed according to the message header annotation to obtain fourth message domain coded data corresponding to each field in the message header, and respectively analyzing and converting the fourth message domain coded data to obtain variable values of the corresponding fields;
acquiring application data annotation from the entity class Javabean for message analysis; analyzing the message to be analyzed according to the application data annotation to obtain fifth message domain coded data corresponding to each field in the application data, and analyzing and converting the fifth message domain coded data to obtain variable values of the corresponding fields;
respectively writing the variable values into corresponding fields of a newly created entity class Javabean;
and writing the newly created entity class Javabean corresponding to the variable value based on the corresponding field to obtain the analysis message of the message to be analyzed.
6. The message parsing method according to claim 5, wherein the message header annotation comprises a Transport Protocol Data Unit (TPDU) annotation and/or a message header annotation; the application data annotation comprises a message type annotation, a bitmap annotation and a data content annotation.
7. The message parsing method according to claim 6, wherein the application data annotation and the header annotation both include the following attributes:
a field ID, a length type length, a data type datatype, a data length datalength, a variable length prefix type varType, an alignment mode align mode, a data conversion convert, a coded character set encoding, and a character filling manner fillAsc.
8. The message parsing method according to claim 7, wherein the length type length comprises: a fixed length type-CONST, a two-position front length type VAR2, a three-position front length type VAR3, a four-position front length type VAR4, a five-position front length type VAR5, a six-position front length type VAR6 and an eight-position front length type VAR8;
the data type datetype includes: ASCII character type CHAR _ ASCII, ASCII digital type NUM _ ASCII, binary BIT pattern BIT, character compression type ASCBCD, digital compression type NUMBCD;
the variable-length prefix type varType includes: binary BIN, string type CHAR;
the alignment mode align mode includes: left alignment and right alignment;
the data conversion convert includes: 16-system characters, common character strings;
the encoding character set encoding includes: ASCLL, ISO-8859-1, GB2312, GBK, GB18030, UTF-8, UTF-16, unicode;
the character filling manner fillAsc includes: BCD is filled with 0, and ASCII is filled with blank spaces;
the prefix length type prelengtype includes: 16-ary character type BCD, binary type BIN, digital character type STRING.
CN202211588532.2A 2022-12-12 2022-12-12 Message annotation configuration method, packet packing method and parsing method Active CN115589440B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211588532.2A CN115589440B (en) 2022-12-12 2022-12-12 Message annotation configuration method, packet packing method and parsing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211588532.2A CN115589440B (en) 2022-12-12 2022-12-12 Message annotation configuration method, packet packing method and parsing method

Publications (2)

Publication Number Publication Date
CN115589440A CN115589440A (en) 2023-01-10
CN115589440B true CN115589440B (en) 2023-03-21

Family

ID=84783322

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211588532.2A Active CN115589440B (en) 2022-12-12 2022-12-12 Message annotation configuration method, packet packing method and parsing method

Country Status (1)

Country Link
CN (1) CN115589440B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676133A (en) * 2022-03-16 2022-06-28 咪咕文化科技有限公司 Index creating method, device, equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2350911B (en) * 1999-06-10 2004-06-09 Ibm Form data files generator
US7844957B2 (en) * 2005-08-19 2010-11-30 Sybase, Inc. Development system with methodology providing optimized message parsing and handling
CN105279032B (en) * 2015-11-24 2019-06-28 浪潮(北京)电子信息产业有限公司 A kind of method and device of sync cap message and javaBean
CN111767057B (en) * 2020-06-29 2024-05-17 京东城市(北京)数字科技有限公司 Data processing method and device
CN114253516A (en) * 2021-12-20 2022-03-29 航天信息股份有限公司 UI (user interface) development method and device for data filling system and storage medium
CN114331416A (en) * 2021-12-30 2022-04-12 深圳市兆珑科技有限公司 Data processing method and device, electronic equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676133A (en) * 2022-03-16 2022-06-28 咪咕文化科技有限公司 Index creating method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN115589440A (en) 2023-01-10

Similar Documents

Publication Publication Date Title
US7391735B2 (en) Parsing messages with multiple data formats
US7020666B2 (en) System and method for unknown type serialization
TW202109428A (en) Method and device for deploying and executing intelligent contracts
US8078640B1 (en) High efficiency binary encoding
CN111191422B (en) File format conversion method, device and computer readable storage medium
EP2124419B1 (en) An object oriented management device for asn.1 message
CN113691651B (en) Top-level planning visualization management method, system and storage medium based on IPv6 network
WO2020259417A1 (en) Data analysis method and device for block chain
CN114500690A (en) Interface data processing method and device, electronic equipment and storage medium
CN114020272A (en) Serialized encoding and decoding methods and devices and electronic equipment
CN115242896A (en) Dynamic message analysis method and device, electronic equipment and computer readable storage medium
US20080077601A1 (en) Method, Apparatus and System for Transforming, Converting and Processing Messages Between Multiple Systems
KR20060094851A (en) System and method for testing a data format using targeted variant input
CN101202736A (en) Method for realizing encoding-decoding in communication network
CN115589440B (en) Message annotation configuration method, packet packing method and parsing method
CN111049813B (en) Message assembling method, message analyzing method, message assembling device, message analyzing device and storage medium
CN111782882A (en) TCP message conversion method, device, system and computer storage medium
CN110839022A (en) Vehicle-mounted control software communication protocol analysis method based on xml language
CN113742294A (en) Method, system, device and medium for decoding ASN.1-PER signaling message
CN113849781B (en) Go language source code confusion method, system, terminal and storage medium
CN105793842B (en) Conversion method and device between serialized message
CN113949749B (en) XML message processing method and device
US20070226366A1 (en) Method, apparatus and system for dispatching messages within a system
CN113420569A (en) Code translation method, device, equipment and storage medium
CN108959411A (en) Processing method, device and the equipment of ETL task

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