Message generation method and device, medium and program product
By loading configuration information and rule constraint files and building the document structure of ISO20022 messages, the problem of automatically generating ISO20022 messages in the existing technology is solved, multi-mode message generation is realized, and efficiency and security are improved.
Patent Information
- Application Number
- CN202510920840.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-09-05
AI Technical Summary
Existing technologies lack the ability to automatically generate ISO20022 messages, which requires users to manually provide business elements, increasing complexity and inefficiency. In addition, the message generation mode is single and cannot meet the diverse needs of users.
Provided are a message generation method and device that loads configuration information, constructs the document structure of the message header and body, generates node content, and performs verification and merging based on rule constraint files, supporting message generation in basic, complex, and user-defined modes.
It realizes the automatic generation of messages that comply with the ISO20022 standard, improves generation efficiency and security, supports multiple generation modes, adapts to different needs, and simplifies the message generation process.
Smart Images

Figure CN120602564A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of message generation technology, and in particular to a message generation method, device, medium and program product. Background Art
[0002] ISO20022 is an XML-based messaging standard spearheaded by the International Organization for Standardization (ISO). It is dedicated to establishing and promoting the integration and development of industry financial standards, including methodologies, standard-setting processes, and standards maintenance entities. Through ISO20022, entities or users interacting with financial institutions can transact with their information systems through a single standard, achieving the ideal of cross-industry collaboration. This provides a solution for the close integration of international financial operations and IT technology, and promotes standardization across the entire financial industry. Since the SWIFT community adopted the ISO200022 messaging standard, all clearing systems worldwide have adopted it. Bank systems are required to have the capabilities to receive, parse, generate, send, display, and verify standard messages.
[0003] Current solutions lack the ability to automatically generate messages. Instead, they require the acquisition of business elements, which often require user assistance. The complexity of these elements not only requires users to possess solid and comprehensive business expertise, but also results in a significant amount of inefficient, repetitive work. Furthermore, the single message generation model fails to meet diverse user needs. Summary of the Invention
[0004] The embodiments of the present application provide a message generation method, device, medium and program product to automatically generate messages that meet standard requirements applicable to different demand models.
[0005] According to one aspect of the present application, a message generation method is provided, the method comprising:
[0006] Loading the configuration information required to generate the message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table;
[0007] Constructing the document structure of the message header and message body according to the configuration information and the selected target mode, and generating and filling the node content of the message header and message body; wherein the target mode includes a basic mode, a complex mode, and a user-defined mode;
[0008] The message header and the message body are verified based on a rule constraint file, and the verified message header and message body are merged into a message file.
[0009] According to one aspect of the present application, a message generating device is provided, the device comprising:
[0010] A configuration information loading module is used to load the configuration information required to generate the message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table;
[0011] A construction module, configured to construct a document structure of a message header and a message body according to the configuration information and a selected target mode, and to generate and fill in node contents of the message header and the message body; wherein the target mode includes a basic mode, a complex mode, and a user-defined mode;
[0012] A verification module is used to verify the message header and the message body based on a rule constraint file, and merge the verified message header and the message body into a message file.
[0013] According to another aspect of the present application, an electronic device is provided, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by at least one processor, and the computer program is executed by at least one processor so that the at least one processor can execute the message generation method of any embodiment of the present application.
[0017] According to another aspect of the present application, a computer-readable storage medium is provided, which stores computer instructions, and the computer instructions are used to enable a processor to implement the message generation method of any embodiment of the present application when executed.
[0018] According to another aspect of the present application, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the message generation method of any embodiment of the present application is implemented.
[0019] The technical solution of the embodiment of the present application is to load the configuration information required for generating a message; wherein, the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table; by loading the configuration information required for generating a message, it is possible to determine the message-related standards based on the configuration information, so as to subsequently generate the message based on the message-related standards. The document structure of the message header and the message body is constructed according to the configuration information and the selected target mode, and the node content of the message header and the message body is generated and filled; wherein, the target mode includes a basic mode, a complex mode, and a user-defined mode, so as to satisfy the message generation in different modes, and provide a rich and convenient message generation form. The message header and the message body are verified based on the rule constraint file, and the verified message header and the message body are merged into a message file, thereby improving the security of message generation.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0022] Figure 1 A flowchart of a message generation method provided in an embodiment of the present application;
[0023] Figure 2 This is a schematic diagram of the path data configuration provided in the embodiment of the present application;
[0024] Figure 3 Schematic representation of element type constraints provided in the embodiments of this application;
[0025] Figure 4 This is a schematic diagram of the namespace configuration provided in the embodiment of the present application;
[0026] Figure 5 This is a schematic diagram of the assembly message configuration provided in the embodiment of the present application;
[0027] Figure 6 A flowchart of a message generation method provided in another embodiment of the present application;
[0028] Figure 7 A flowchart of a message generation method provided in another embodiment of the present application;
[0029] Figure 8 A first flow chart diagram is generated for a node provided in yet another embodiment of the present application;
[0030] Figure 9 A second flow chart diagram is generated for a node provided in yet another embodiment of the present application;
[0031] Figure 10 A third flow chart diagram of node generation provided by another embodiment of the present application;
[0032] Figure 11 This is an overall flow chart of message generation provided in another embodiment of the present application;
[0033] Figure 12 A schematic diagram of generating message node content provided in another embodiment of the present application;
[0034] Figure 13 A schematic diagram of the structure of a message generating device provided in an embodiment of the present application;
[0035] Figure 14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0037] It should be noted that the terms "first", "second", "third", "fourth", "actual", "preset", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] Figure 1This is a flow chart of a message generation method provided in an embodiment of the present application. The embodiment of the present application is applicable to the case of automatically generating messages. The method can be executed by a message generation device, which can be implemented in the form of hardware and / or software, and the message generation device can be configured in an electronic device. Figure 1 As shown, the method includes:
[0039] S110, loading configuration information required for generating a message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table;
[0040] The configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table. In standardized messages (such as the XML hierarchical nodes of ISO 20022 and the domain numbers of ISO 8583), the path acts as a coordinate navigation to identify the location of data in the message structure. The path data configuration table is a mapping rule table used to define the location and attributes of data elements in the message structure. The mapping rule table is a mapping rule table used to define the location and attributes of data elements in the message structure. A specific example of a path data configuration table is Figure 2 As shown, the identifiers have the following meanings:
[0041] id: is the auto-increment unique primary key of the table.
[0042] business_service: business service type.
[0043] msg_type: message type.
[0044] leaf_flag: Leaf node identifier, Y indicates a leaf node, and N indicates a non-leaf node.
[0045] type: path type. A indicates the packet header path, and D indicates the packet header path.
[0046] element_type: element type, which represents the value of the path Type in XML Schema.
[0047] min_occurs: The minimum number of occurrences of the path when the current parent node appears.
[0048] max_occurs: The maximum number of times the path appears when the current parent node appears.
[0049] mandatory: indicates whether the node must appear when its parent node appears. Y indicates mandatory, and N indicates optional.
[0050] _index: The index of the path, represented by eight digits (0-9) in the format of XYYYYZZZ.
[0051] _lvl: path level, equivalent to the number of / in the path.
[0052] _name: node name.
[0053] _xmltag: relative path.
[0054] _path: path, that is, absolute path.
[0055] _definition: Node definition.
[0056] The element type constraint table is a mapping table used to define the format rules and legal value ranges of each data field in the message. For example, Figure 3 As shown, the meanings of the symbols are as follows:
[0057] restriction: constraint type, the values include string, date, time, datetime, boolean, decimal, sequence, choice, etc.
[0058] pattern: regular expression.
[0059] min_length: minimum length.
[0060] max_length: Maximum length.
[0061] name: name.
[0062] value: enumeration value.
[0063] definition: definition.
[0064] fraction_digits: The length of the decimal part.
[0065] total_digits: The maximum total length.
[0066] min_inclusive: minimum value.
[0067] For ISO20022 standard messages, whether it is the envelope, message header or message body, they are all in different namespaces. At the same time, different message types have different namespaces. For example, the message body namespace of the camt.054 message is camt, while the message body namespace of the pacs.008 message is pacs. In view of the above situation, the above information can be stored in the namespace configuration table, which can avoid hard coding and provide the convenience of configuration upgrade for the continuous upgrade of subsequent messages. A specific example of the namespace configuration table is Figure 4 As shown, the meanings of the symbols are as follows:
[0068] type: E indicates envelope, A indicates packet header, and D indicates packet header.
[0069] namespace_uri: Namespace URI.
[0070] attribute_uri: attribute URI.
[0071] attribute_name: attribute name.
[0072] location: location.
[0073] prefix: namespace prefix.
[0074] In the user-defined mode, the XML document structure, content generation and filling steps are determined by the user, so the message configuration table can be assembled for the user to maintain the configuration data. The data model supports multiple default values, database scripts, functions and other content generation methods. For example, Figure 5 As shown, the meanings of the symbols are as follows:
[0075] default_value: The default value. The default value is used first when generating node content.
[0076] script: Executable SQL of user data. It is retrieved and executed with the second highest priority when generating node content to generate node content.
[0077] function: The full path of the method, used to call through reflection to generate node content.
[0078] S120. Construct the document structure of the message header and message body according to the configuration information and the selected target mode, and generate and fill the node content of the message header and message body; wherein the target mode includes a basic mode, a complex mode and a user-defined mode.
[0079] Basic, complex, and user-defined modes are available as candidate modes for users to select from. The document structure of the message header and body is then constructed based on the target mode. The basic mode, BASIC, generates only all mandatory nodes. These mandatory nodes include mandatory leaf nodes and their randomly minimized leaf nodes generated to generate mandatory non-leaf nodes. Messages generated in this mode are suitable for system logic compliance testing. The complex mode, COMPLEX, builds on the BASIC mode and attempts to generate all non-mandatory nodes. It provides control over the maximum number of node generation attempts and, for situations where multiple child nodes are selected when the parent node element is constrained to choice, adds the ability to randomly generate any child node. Messages generated in this mode are suitable for robustness and performance testing of system logic. The user-defined mode, CUSTOM, gives users control over which nodes are generated. The XML document structure and content are generated based on user-maintained data in the assembled message configuration table. Messages generated in this mode are suitable for system functionality testing in specific complex business scenarios.
[0080] In an embodiment of the present application, the document structure of the message header and message body is constructed according to the configuration information and the selected target mode. In addition to meeting the requirements under a specific namespace, the generated message header and message body XML document structure must also support the processing of special scenarios such as multiple-choice node generation and repeated node generation. Depending on whether the XML document structure is complex and customized, the different implementations of generating XML document structure and node content are divided into three modes: BASIC, COMPLEX, and CUSTOM. The BASIC mode and COMPLEX mode reversely generate random content for filling based on the element type constraints of each node, and the CUSTOM mode generates content for filling based on the assembly message configuration table data configured by the customer.
[0081] S130: Verify the message header and the message body based on the rule constraint file, and merge the verified message header and message body into a message file.
[0082] In an embodiment of the present application, verification can be performed based on the message header and message body of a rule constraint file, where the rule constraint can be an XML Schema file. After verification, an object of the root node Envelope in a specific namespace is generated, and attributes are added. The message header and message body are then added to the root node Envelope object in sequence. Verified messages are then output as files.
[0083] The technical solution of the embodiment of the present application is to load the configuration information required for generating a message; wherein, the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table; by loading the configuration information required for generating a message, it is possible to determine the message-related standards based on the configuration information, so as to subsequently generate the message based on the message-related standards. The document structure of the message header and the message body is constructed according to the configuration information and the selected target mode, and the node content of the message header and the message body is generated and filled; wherein, the target mode includes a basic mode, a complex mode, and a user-defined mode, so as to satisfy the message generation in different modes, and provide a rich and convenient message generation form. The message header and the message body are verified based on the rule constraint file, and the verified message header and the message body are merged into a message file, thereby improving the security of message generation.
[0084] Figure 6 This is a flow chart of a message generation method provided by another embodiment of the present application. The present embodiment is optimized based on the above embodiment. For solutions not fully described in the present embodiment, please refer to the above embodiment. Figure 6 As shown, the method of the embodiment of the present application specifically includes the following steps:
[0085] S210. Load configuration information required for generating a message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table.
[0086] S220. If the target mode is the basic mode, generate mandatory nodes and fill the mandatory nodes with content; wherein the mandatory nodes include mandatory leaf nodes and leaf nodes that are randomly minimized in order to generate mandatory non-leaf nodes.
[0087] Among them, mandatory nodes refer to fields or element nodes that must exist and be filled with valid actual data according to the message specification. Missing, leaving blank or filling invalid content will cause the message to be automatically rejected by the system. It is a core technical constraint to ensure the legitimacy of the transaction and the integrity of the business. Such nodes usually correspond to key business information such as payment amount and account identification. Their mandatory existence not only meets the message structure verification rules at the technical level, but also serves as a risk control mechanism at the business level to prevent transaction interruption or liquidation failure. For example, if the target mode selected by the user is the basic mode, only mandatory nodes will be generated in this mode, and the generated mandatory nodes will be filled with content. The mandatory nodes include mandatory leaf nodes and leaf nodes that are randomly minimized to generate mandatory non-leaf nodes.
[0088] S230: If the target mode is a complex mode, then on the basis of generating mandatory nodes, generate the most non-mandatory nodes, and fill each node with content.
[0089] Among them, non-mandatory nodes refer to fields or element nodes that are allowed to be selectively included according to the message specification. Such nodes can be flexibly selected based on the actual business scenario - if they exist, they must comply with the format rules, and if they are missing, it will not affect the overall validity of the message. They are usually used to carry additional information (such as transaction remarks, reference numbers, etc.), which not only reserves space for business expansion but also avoids the redundancy caused by forced filling of invalid data. It is a design embodiment of balancing the rigor and flexibility of the message. If the target mode selected by the user is complex mode, then on the basis of generating mandatory nodes, as many non-mandatory nodes as possible are generated and the content of each node is filled.
[0090] S240: If the target mode is a user-defined mode, determine the nodes that need to be generated according to the assembly message configuration table maintained by the user.
[0091] For example, if the user selects the user-defined mode, that is, which nodes need to be generated and which nodes do not need to be generated according to the user-defined rules, the nodes that need to be generated can be determined according to the assembly message configuration table maintained by the user. The assembly message configuration table contains the user's configuration of the nodes that need to be generated.
[0092] S250: Verify the message header and the message body based on the rule constraint file, and merge the verified message header and message body into a message file.
[0093] The embodiment of the present application provides a message generation method. If the target mode is a basic mode, mandatory nodes are generated and the mandatory nodes are filled with content. The mandatory nodes include mandatory leaf nodes and randomly minimized leaf nodes generated to generate mandatory non-leaf nodes. If the target mode is a complex mode, the maximum number of non-mandatory nodes are generated on the basis of the mandatory nodes, and the content of each node is filled. If the target mode is a user-defined mode, the nodes to be generated are determined according to the assembly message configuration table maintained by the user. The above scheme is applicable to various types of ISO20022 standard messages, realizes the transformation from manual reporting to automatic reporting by the program, and effectively improves the development and testing efficiency of the financial industry during the message standard upgrade and transformation process. The provided automatic message generation method has three generation modes. The message can be generated completely randomly by the program with only the user controlling the message complexity (BASIC or COMPLEX), or the message can be generated completely by the user (CUSTOM mode), which has a high user acceptance. In addition, the CUSTOM generation mode and assembly message configuration table provided by this solution uses message leaf nodes as the granularity. This simplifies the difficulty of generating message content and improves the code reuse rate for similar leaf node processing. It also supports a configured way to group messages and has high scalability.
[0094] Figure 7 This is a flow chart of a message generation method provided by another embodiment of the present application. The present embodiment is optimized based on the above embodiment. For solutions not described in detail in the present embodiment, please refer to the above embodiment. Figure 7 As shown, the method of the embodiment of the present application specifically includes the following steps:
[0095] S310. Load configuration information required for generating a message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table.
[0096] S320 , generating each node in a loop according to an identifier indicating whether the node must be input.
[0097] Exemplarily, for each node that needs to be generated, an identifier indicating whether the node must be input can be searched in a configuration file, and the node can be generated based on the identifier indicating whether the node must be input.
[0098] In the embodiment of the present application, each node is generated cyclically according to an identifier indicating whether the node must be input, including:
[0099] For the node to be generated currently, searching from the document structure record table whether a parent node of the node exists;
[0100] If it does not exist, generate this node as the root node;
[0101] If it exists, and the node is required under the parent node, if the parent node has been generated, then the node is generated; if the parent node has not been generated, then the node is skipped;
[0102] If it exists, and the node is not required under the parent node, then determine whether to generate the node according to the rule of selecting and generating the node;
[0103] Determining whether to generate the node according to the rule for selecting and generating the node includes:
[0104] Check whether the parent node has randomly selected a child node. If the parent node has been randomly selected and the randomly selected node is the node, then generate the node. If the parent node has been randomly selected and the randomly selected node is not the node, then skip the node.
[0105] If the parent node is not randomly selected, and the parent node has generated all child nodes, then a child node is randomly selected. If the randomly selected node is the node, then the node is generated. If the randomly selected node is not the node, then the node is skipped.
[0106] If it is not randomly selected and the parent node is not generated, the node is skipped.
[0107] For example, in this scenario, when generating the XML document structure, the nodes are selected from multiple choices. When generating the XML document structure of the message header and message body, there are two scenarios where multiple nodes are generated: 1) The parent node must be input but its child nodes are not required. In this case, in order to ensure that the parent node must exist, at least one child node must be generated; 2) The constraint type of the parent node is choice. In this case, the child nodes are mutually exclusive, so only one child node can be generated. The flowchart of generating nodes in the above two scenarios is as follows. Figure 8As shown. Specifically, for the node that currently needs to be generated, the parent node of the node is retrieved to determine whether the parent node is empty, that is, to determine whether the parent node exists. If the parent node is empty, that is, the parent node does not exist, the current node needs to be generated. It serves as the root node to facilitate the generation of subsequent nodes, so the current node is not skipped. If the parent node is not empty, that is, the parent node exists, the parent node's hierarchy is obtained, and it is determined whether the node is required to be lost under the parent node. If it is required to be lost, the parent node is determined to be generated. If it is, the node is generated and the node is not skipped. If the parent node has not been generated, there is no need to generate the node at this time, and the current node is skipped. If the node is not required to be lost under the parent node, the parent node is checked to determine whether a child node has been randomly selected for generation. If it has been randomly selected, the node is checked to determine whether the randomly selected node is the current node. If so, the node is generated and the node is not skipped. If the randomly selected node is not the current node, the node is skipped. If the parent node has not randomly selected a node for generation, the parent node is checked to determine whether it has been generated and all child nodes under the parent node are not required to be lost. If the parent node has been generated and all nodes are optional, randomly select a node as a child node and determine whether the randomly selected node is the current node. If it is, generate the node and do not skip it. If the randomly selected node is not the current node, skip it. If the parent node has not been generated, skip it.
[0108] In the embodiment of the present application, each node is generated cyclically according to an identifier indicating whether the node must be input, including:
[0109] If the parent node of the node to be generated has not been generated, skip the node;
[0110] If the parent node of the node has been generated, then detect whether the constraint type of the parent node is a selective type, if not, then generate the node, if so, then detect whether the parent node has randomly selected a child node;
[0111] If the parent node has been randomly selected and the randomly selected node is this node, then generate this node; if the parent node has been randomly selected and the randomly selected node is not this node, then skip this node;
[0112] If the parent node does not randomly select a child node, then randomly select a child node. If the randomly selected node is this node, then generate this node. If the randomly selected node is not this node, then skip this node.
[0113] For example, Figure 9This is a flowchart of the node generation process. If the corresponding conditions are not met, the current node is skipped and not generated. If the corresponding conditions are met, the subsequent judgment logic continues. Whether in BASIC mode or COMPLEX mode, only one child node needs to be randomly generated. In CUSTOM mode, the user decides which child node to generate, but the message verification rules must be met in all cases.
[0114] Specifically, for the node that needs to be generated, the process also checks whether the parent node of the current node is null. If so, meaning it doesn't exist, the current node needs to be generated. This node serves as the root node to facilitate the generation of subsequent nodes, so the current node is not skipped. If the parent node is not null, meaning it exists, the process then retrieves the parent node's hierarchy and determines whether the parent node has already been generated. If the parent node has not been generated, the process then skips the current node. If the parent node has already been generated, the process then checks whether the constraint type of the parent node is selective. If so, the process then checks whether the parent node has randomly selected a child node for generation. If so, the process then checks whether the randomly selected node is the current node. If so, the node is generated without skipping. If not, the process then skips the node. If the randomly selected node is not the current node, the process then skips the node. If the parent node is not selective, the process then checks whether the node is generated without skipping.
[0115] In the embodiment of the present application, each node is generated cyclically according to an identifier indicating whether the node must be input, including:
[0116] Obtain the relative path in the path of each current node, traverse each relative path, and during the traversal process, determine whether the relative path starts with a data element tag;
[0117] If the relative path begins with a data element tag, obtain a list of parent path objects of the relative path and add attributes to each parent path object;
[0118] If the relative path does not start with a data element tag, then obtaining the absolute path of the relative path and determining whether the object of the absolute path has been generated;
[0119] If the absolute path has been generated, the absolute path is set as the parent path. If the absolute path has not been generated, the maximum number of occurrences of the absolute path is obtained, a list of parent path objects is obtained based on the parent path, an object with the maximum number of occurrences of the absolute path is added to each parent path object, and the absolute path is set as the parent path.
[0120] For example, when generating the XML document structure of the message header and message body in COMPLEX mode, there is a scenario where nodes are repeatedly generated: the parent node is a repeated node (max_occurs is greater than 1), and at least one of its child nodes or child nodes of the child node is a repeated node (max_occurs is greater than 1). In this case, in order to generate as many non-mandatory nodes as possible, it is necessary to support multi-layer repeated node generation.
[0121] For the scene that is repeatedly generated by the node, such as Figure 10 As shown, each relative path in the relative path list of the current path is processed in a loop, and the parent path is used to point to the parent path of the last processing. If the current relative path object does not exist, it is created, and before the next loop starts, the parent path is pointed to the absolute path of the relative path during this processing. Specifically, the relative path in the path of each current node is obtained, and each relative path is traversed. During the traversal process, it is determined whether the relative path starts with a data element tag, which also starts with @. If the relative path starts with a data element tag, the parent path object list of the relative path is obtained, and attributes are added to each parent path object. If the relative path does not start with a data element tag, the absolute path of the relative path is obtained, and it is determined whether the object of the absolute path has been generated. If the absolute path has been generated, the absolute path is set to the parent path. If the absolute path has not been generated, the maximum number of occurrences of the absolute path is obtained, and the parent path object list is obtained according to the parent path. The object of the maximum number of occurrences of the absolute path is added to each parent path object, and the absolute path is set to the parent path. The message generation flow chart based on the above three node generation processing logic is as follows. Figure 11 shown.
[0122] S330. Record the generated nodes in the document structure record table.
[0123] In an embodiment of the present application, the generated node is recorded in a document structure record table. In the above embodiment, when searching whether the parent node is empty, the search is performed from the document structure record table.
[0124] S340: Generate and fill the message header and the node content of the message body; wherein the target mode includes a basic mode, a complex mode and a user-defined mode.
[0125] S350: Verify the message header and the message body based on the rule constraint file, and merge the verified message header and message body into a message file.
[0126] The embodiment of the present application provides a message generation method, which loads the configuration information required for generating a message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table; each node is generated cyclically according to the identifier of whether the node must be entered; and the generated node is recorded in a document structure record table. The node content of the message header and the message body is generated and filled; wherein the target mode includes a basic mode, a complex mode, and a user-defined mode; the message header and the message body are verified based on a rule constraint file, and the verified message header and the message body are merged into a message file. The above scheme solves two key problems in the automatic generation process, namely, multiple selection of nodes and repeated generation of nodes. It has three generation modes. Messages can be generated completely randomly by the program with only the user controlling the message complexity (BASIC or COMPLEX), or messages can be generated completely by the user (CUSTOM mode). In CUSTOM mode, by assembling the message configuration table, a software asset library for message generation that meets actual business scenarios can be constructed in conjunction with the database and background application.
[0127] As a non-limiting implementation method, generating and filling the message header and the node content of the message body includes:
[0128] According to the specific constraints of the element type constraint table, reversely generate random content that meets the constraints;
[0129] The random content is replaced with actual content, and the leaf nodes and their attributes in the document structure are filled.
[0130] For example, in the ISO20022 standard message, only the leaf nodes and their attributes contain specific message elements. Therefore, based on the generation of the XML document structure, it is only necessary to assign values to the leaf nodes and attributes in the XML document structure to generate a complete ISO20022 standard message; and assigning values to the leaf nodes and their attributes means that values need to be generated first. The constraint types of leaf nodes in the ISO20022 standard message include but are not limited to string, decimal, date, dateTime, time, boolean, gYearMonth, etc. They have their own constraints. For example, the string representing text information has constraints such as regular expression, minimum length, maximum length, etc., and the decimal representing the amount has constraints such as maximum length, decimal precision, minimum value, etc. In this solution, according to the specifics of the different constraint types in the element type constraint table, random content that meets the constraint conditions is generated in reverse, and then the leaf nodes and their attributes in the XML document structure are filled to generate a complete ISO20022 standard message. The specific processing is as follows: Figure 12 As shown, first determine the generation mode. If it is BASIC or COMPLEX mode, then randomly generate the corresponding content according to the element constraint type. If it is CUSTOM mode, then get the default value, execute the script, and reflect the priority of calling the function to get the corresponding content.
[0131] Figure 13 This is a structural diagram of a message generation device provided in an embodiment of the present application. The device can execute the message generation method provided in any embodiment of the present application and has the corresponding functional modules and beneficial effects of the execution method. Figure 13 As shown, the device includes:
[0132] Configuration information loading module 410, used to load configuration information required for generating a message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table;
[0133] A construction module 420 is configured to construct a document structure of a message header and a message body according to the configuration information and the selected target mode, and to generate and fill in node content of the message header and the message body; wherein the target mode includes a basic mode, a complex mode, and a user-defined mode;
[0134] The verification module 430 is configured to verify the message header and the message body based on a rule constraint file, and merge the verified message header and message body into a message file.
[0135] In the embodiment of the present application, the construction module 420 constructs the document structure of the message header and message body according to the configuration information and the selected target mode, and generates and fills the node content of the message header and the message body, including:
[0136] If the target mode is the base mode, generating must-lose nodes and filling the must-lose nodes with content; wherein the must-lose nodes include must-lose leaf nodes and leaf nodes randomly minimized in order to generate must-lose non-leaf nodes;
[0137] If the target mode is a complex mode, then on the basis of generating mandatory nodes, the maximum number of non-mandatory nodes are generated, and each node is filled with content;
[0138] If the target mode is a user-defined mode, the nodes that need to be generated are determined according to the assembly message configuration table maintained by the user.
[0139] In the embodiment of the present application, the construction module 420 constructs the document structure of the message header and message body according to the configuration information and the selected target mode, including:
[0140] Generate each node in a loop based on whether the node must be input;
[0141] Record the generated nodes in the document structure record table.
[0142] In the embodiment of the present application, the construction module 420 generates each node cyclically according to the flag indicating whether the node must be input, including:
[0143] For the node to be generated currently, searching from the document structure record table whether a parent node of the node exists;
[0144] If it does not exist, generate this node as the root node;
[0145] If it exists, and the node is required under the parent node, if the parent node has been generated, then the node is generated; if the parent node has not been generated, then the node is skipped;
[0146] If it exists, and the node is not required under the parent node, then determine whether to generate the node according to the rule of selecting and generating the node;
[0147] Determining whether to generate the node according to the rule for selecting and generating the node includes:
[0148] Check whether the parent node has randomly selected a child node. If the parent node has been randomly selected and the randomly selected node is the node, then generate the node. If the parent node has been randomly selected and the randomly selected node is not the node, then skip the node.
[0149] If the parent node is not randomly selected, and the parent node has generated all child nodes, then a child node is randomly selected. If the randomly selected node is the node, then the node is generated. If the randomly selected node is not the node, then the node is skipped.
[0150] If it is not randomly selected and the parent node is not generated, the node is skipped.
[0151] In the embodiment of the present application, the construction module 420 generates each node cyclically according to the flag indicating whether the node must be input, including:
[0152] If the parent node of the node to be generated has not been generated, skip the node;
[0153] If the parent node of the node has been generated, then detect whether the constraint type of the parent node is a selective type, if not, then generate the node, if so, then detect whether the parent node has randomly selected a child node;
[0154] If the parent node has been randomly selected and the randomly selected node is this node, then generate this node; if the parent node has been randomly selected and the randomly selected node is not this node, then skip this node;
[0155] If the parent node does not randomly select a child node, then randomly select a child node. If the randomly selected node is this node, then generate this node. If the randomly selected node is not this node, then skip this node.
[0156] In the embodiment of the present application, the construction module 420 generates each node cyclically according to the flag indicating whether the node must be input, including:
[0157] Obtain the relative path in the path of each current node, traverse each relative path, and during the traversal process, determine whether the relative path starts with a data element tag;
[0158] If the relative path begins with a data element tag, obtain a list of parent path objects of the relative path and add attributes to each parent path object;
[0159] If the relative path does not start with a data element tag, then obtaining the absolute path of the relative path and determining whether the object of the absolute path has been generated;
[0160] If the absolute path has been generated, the absolute path is set as the parent path. If the absolute path has not been generated, the maximum number of occurrences of the absolute path is obtained, a list of parent path objects is obtained based on the parent path, an object with the maximum number of occurrences of the absolute path is added to each parent path object, and the absolute path is set as the parent path.
[0161] In the embodiment of the present application, the construction module 420 generates and fills the node content of the message header and the message body, including:
[0162] According to the specific constraints of the element type constraint table, reversely generate random content that meets the constraints;
[0163] The random content is replaced with actual content, and the leaf nodes and their attributes in the document structure are filled.
[0164] A message generation device provided in an embodiment of the present application can execute a message generation method provided in any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method.
[0165] Figure 14A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0166] like Figure 14 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0167] Multiple components in electronic device 10 are connected to I / O interface 15, including an input unit 16, such as a keyboard and mouse; an output unit 17, such as various types of displays and speakers; a storage unit 18, such as a magnetic disk and optical disk; and a communication unit 19, such as a network card, a modem, a wireless message generating transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0168] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the message generation method.
[0169] In some embodiments, the message generation method can be implemented as a computer program that is tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the message generation method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the message generation method in any other appropriate manner (e.g., by means of firmware).
[0170] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0171] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable message generating device, so that when executed by the processor, the computer programs implement the functions / operations specified in the flowcharts and / or block diagrams. The computer programs can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0172] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0173] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0174] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0175] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0176] An embodiment of the present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the message generation method provided in any embodiment of the present application.
[0177] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to write computer program code for performing the operations of the present invention, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, through the Internet using an Internet service provider).
[0178] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this application can be performed in parallel, sequentially, or in a different order, as long as the desired information of the technical solution of this application can be achieved. This document is not limited here.
[0179] The above specific embodiments do not constitute a limitation on the scope of protection of this application. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the scope of protection of this application.
Claims
1. A message generation method, characterized in that: The method comprises: Loading the configuration information required to generate the message; wherein the configuration information includes a path data configuration table, an element type constraint table, a namespace configuration table, and an assembly message configuration table; Constructing the document structure of the message header and message body according to the configuration information and the selected target mode, and generating and filling the node content of the message header and message body; wherein the target mode includes a basic mode, a complex mode, and a user-defined mode; The message header and the message body are verified based on a rule constraint file, and the verified message header and message body are merged into a message file.
2. The method according to claim 1, characterized in that Constructing the document structure of the message header and message body according to the configuration information and the selected target mode, and generating and filling the node content of the message header and the message body, including: If the target mode is the base mode, generating must-lose nodes and filling the must-lose nodes with content; wherein the must-lose nodes include must-lose leaf nodes and leaf nodes randomly minimized in order to generate must-lose non-leaf nodes; If the target mode is a complex mode, then on the basis of generating mandatory nodes, the maximum number of non-mandatory nodes are generated, and each node is filled with content; If the target mode is a user-defined mode, the nodes that need to be generated are determined according to the assembly message configuration table maintained by the user.
3. The method according to claim 1, characterized in that Constructing the document structure of the message header and message body according to the configuration information and the selected target mode, including: Generate each node in a loop based on whether the node must be input; Record the generated nodes in the document structure record table.
4. The method according to claim 3, characterized in that Generate each node cyclically based on whether the node must be input, including: For the node to be generated currently, searching from the document structure record table whether a parent node of the node exists; If it does not exist, generate this node as the root node; If it exists, and the node is required under the parent node, if the parent node has been generated, then the node is generated; if the parent node has not been generated, then the node is skipped; If it exists, and the node is not required under the parent node, then determine whether to generate the node according to the rule of selecting and generating the node; Determining whether to generate the node according to the rule for selecting and generating the node includes: Check whether the parent node has randomly selected a child node. If the parent node has been randomly selected and the randomly selected node is the node, then generate the node. If the parent node has been randomly selected and the randomly selected node is not the node, then skip the node. If the parent node is not randomly selected, and the parent node has generated all child nodes, then a child node is randomly selected. If the randomly selected node is the node, then the node is generated. If the randomly selected node is not the node, then the node is skipped. If it is not randomly selected and the parent node is not generated, the node is skipped.
5. The method according to claim 3, characterized in that Generate each node cyclically based on whether the node must be input, including: If the parent node of the node to be generated has not been generated, skip the node; If the parent node of the node has been generated, then detect whether the constraint type of the parent node is a selective type, if not, then generate the node, if so, then detect whether the parent node has randomly selected a child node; If the parent node has been randomly selected and the randomly selected node is this node, then generate this node; if the parent node has been randomly selected and the randomly selected node is not this node, then skip this node; If the parent node does not randomly select a child node, then randomly select a child node. If the randomly selected node is this node, then generate this node. If the randomly selected node is not this node, then skip this node.
6. The method according to claim 3, characterized in that Generate each node cyclically based on whether the node must be input, including: Obtain the relative path in the path of each current node, traverse each relative path, and during the traversal process, determine whether the relative path starts with a data element tag; If the relative path begins with a data element tag, obtain a list of parent path objects of the relative path and add attributes to each parent path object; If the relative path does not start with a data element tag, then obtaining the absolute path of the relative path and determining whether the object of the absolute path has been generated; If the absolute path has been generated, the absolute path is set as the parent path. If the absolute path has not been generated, the maximum number of occurrences of the absolute path is obtained, a list of parent path objects is obtained based on the parent path, an object with the maximum number of occurrences of the absolute path is added to each parent path object, and the absolute path is set as the parent path.
7. The method according to claim 1, characterized in that Generating and filling the message header and the message body node content, including: According to the specific constraints of the element type constraint table, reversely generate random content that meets the constraints; The random content is replaced with actual content, and the leaf nodes and their attributes in the document structure are filled.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the message generation method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the message generation method according to any one of claims 1 to 7 when executed.
10. A computer program product, characterized in that The method comprises a computer program, which, when executed by a processor, implements the message generation method according to any one of claims 1 to 7.