CN109379326B - XML message rule checking method, equipment and storage medium - Google Patents

XML message rule checking method, equipment and storage medium Download PDF

Info

Publication number
CN109379326B
CN109379326B CN201810991829.0A CN201810991829A CN109379326B CN 109379326 B CN109379326 B CN 109379326B CN 201810991829 A CN201810991829 A CN 201810991829A CN 109379326 B CN109379326 B CN 109379326B
Authority
CN
China
Prior art keywords
message
verification
xml
adaptation
field
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
CN201810991829.0A
Other languages
Chinese (zh)
Other versions
CN109379326A (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.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
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 China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN201810991829.0A priority Critical patent/CN109379326B/en
Publication of CN109379326A publication Critical patent/CN109379326A/en
Application granted granted Critical
Publication of CN109379326B publication Critical patent/CN109379326B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The application provides a method for checking and processing an XML message, which comprises the following steps: reading a message adaptation configuration file in an XML format, wherein the message adaptation configuration file is arranged in an adaptation module of a java platform and comprises message adaptation configuration information and message verification configuration information; analyzing the message adaptation configuration file to obtain a message verification rule in the message verification configuration information; acquiring XML message content to be checked; and verifying the XML message content to be verified according to the analyzed verification rule. The verification method provided by the application is realized in the message adaptation function of the java platform, scattered verification logic in a plurality of application items is replaced, and unified verification of the XML message is realized.

Description

XML message rule checking method, equipment and storage medium
Technical Field
The present invention relates to a data processing method, and in particular, to a method, a device, and a storage medium for checking XML message rules.
Background
The application project needs to receive a front-end request, and when a customer uses a customer channel such as a mobile phone bank, an electronic bank and the like or a teller transacts business through an employee channel, meaningless or illegal data may be input, and the data can be sent to an application server in an XML message form, so that the load of the application server is increased, the normal operation of the application is influenced, and the safety of the application server is seriously influenced.
The application server also needs to send requests to other application servers and receive response messages returned by the other side, and meaningless or illegal data may be input in the messages, so that the same adverse effects are caused.
In order to solve the above problem, the data in the XML message must be verified according to a certain service rule by a technical means, so as to intercept the message with illegal data.
Most of the existing application projects are integrated in the business logic of the application projects according to the business characteristics of the application projects. This approach has the following disadvantages: each application has a respective implementation method, each implementation method is different, and the projects cannot be reused; the coupling degree is high and the disassembly is difficult due to the tight coupling with the project; the implementation mode is not flexible, and codes need to be continuously modified according to personalized requirements put forward by services.
Disclosure of Invention
The XML message checking and processing method provided by the embodiment of the invention forms a modular rule checking and processing framework of the XML message, and the processing framework is arranged in the message adaptation function of the java platform to replace the checking logic which is realized sporadically in each application project, thereby realizing a standard, standard and efficient processing framework for checking the XML message.
In a first aspect, an embodiment of the present invention provides a method for checking and processing an XML packet, where the method includes: reading a message adaptation configuration file in an XML format, wherein the message adaptation configuration file is arranged in an adaptation module of a java platform and comprises message adaptation configuration information and message verification configuration information; analyzing the message adaptation configuration file to obtain a message verification rule in the message verification configuration information; acquiring XML message content to be checked; and verifying the XML message content to be verified according to the analyzed verification rule.
In a second aspect, embodiments of the present invention provide a computer device, including a memory and a processor, where the memory stores computer instructions; a processor configured to execute the computer instructions to cause the computer device to perform the method of the first aspect.
In a third aspect, the present invention provides a computer readable storage medium, on which computer instructions are stored, and when executed by a processor, the computer instructions implement the method of the first aspect.
Drawings
Fig. 1 is a flowchart illustrating an XML message verification processing method according to an embodiment of the present invention.
Fig. 2 shows a screenshot of an XML message adaptation configuration file according to an embodiment of the present invention.
FIG. 3 illustrates a screenshot of an XML message according to an embodiment of the present invention.
Fig. 4 is a schematic diagram illustrating a method for checking XML messages according to an embodiment of the present invention.
Fig. 5 shows a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
Various aspects of the invention are described in detail below with reference to the figures and the detailed description. Well-known modules, units and their interconnections, links, communications or operations with each other are not shown or described in detail. Furthermore, the described features, architectures, or functions can be combined in any manner in one or more implementations. It will be understood by those skilled in the art that the various embodiments described below are illustrative only and are not intended to limit the scope of the present invention. It will also be readily understood that the modules or units or processes of the embodiments described herein and illustrated in the figures can be combined and designed in a wide variety of different configurations.
Referring to fig. 1, fig. 1 is a flowchart illustrating an XML message verification processing method according to an embodiment of the present invention, where the method may include: step S101, step S102, step S103 and step S104, which will be described in detail with reference to specific embodiments.
Step S101, reading a message adaptation configuration file in an XML format, wherein the message adaptation configuration file is arranged in an adaptation function of a java platform and comprises message adaptation configuration information and message verification configuration information.
In the embodiment of the invention, the message adaptation configuration file can be in an XML format and is arranged in a message adaptation function module of a java platform layer, and the message adaptation is to convert an XML message into a java class object.
The XML formatted message adaptation configuration file may include message adaptation configuration information and message verification configuration information. The message adaptation configuration information comprises association information for converting an XML message into a java class, and the association information comprises a node name, an attribute name and a type. The message check configuration information includes a data category field identifying a service data category and a check field identifying a check rule.
In a specific embodiment, the message adaptation configuration file may be as shown in fig. 2, and the XML message corresponding to the configuration file is as shown in fig. 3. As shown in fig. 2, mapping indicates message adaptation configuration, id is a unique identifier, the configuration of parser and transformer indicates that xml message is converted into Java object bean, and value true indicates that message checking function is started. The content in the structure is represented by a java class structure, the node name node-name is the name of an xml tag corresponding to the class, the field is the attribute name in the class, and the type is the type of the class. The content in the value tag represents an attribute in the class, wherein the node-name represents the name of the corresponding XML tag, the field represents the name of the attribute in the class, and the type represents the type of the attribute. And (3) message checking configuration information, wherein in each value, a datatype field identifies the service data type, and a checking rule field is-null, max-length, min and max identify a checking rule.
And configuring different service data types according to different service meanings of each value field of the XML message, wherein each service data type has a corresponding check rule.
In an embodiment of the invention, the traffic data categories comprise one or more of the following: text type, numerical type and time-date type, which may correspond to text type tags, data type tags and time-date type tags.
For the numeric service data, the correspondingly configured keyword is NumericType, and the following verification rules may be included: the maximum length check of the number, the value range check and whether the field is a null check. For example, the check rule of the numeric type service data may be: max-length ═ 3 means that the maximum length of the number does not exceed 3; min-2 max-100 indicates a value greater than 2 and less than 100; is-null indicates that the field is not allowed to be empty.
For text-based business data, the corresponding configured keyword may be TextType, and may include the following check rule: a maximum length checksum field of the text is checked for being empty. For example, the verification rule for text-based service data may be: is-null indicates that the field is not allowed to be empty; max-length equals 100 indicating that the maximum length of the text is less than 100.
For time-date type service data, the correspondingly configured keyword may be DatetimeType, and may include the following check rule: a check whether the field is empty and a check of the time expression format. For example, is-null indicates that the field is not allowed to be empty; the pattern represents a format to which time and date should follow, and is configured in the form of a regular expression.
The message checking method provided by the embodiment of the invention can realize the message checking function on an enterprise-level development platform, realize the message checking function on a JAVA platform layer, and use the XML message rule checking function through simple configuration of order in a pluggable mode.
Step S102, analyzing the message adaptation configuration file to obtain the message verification rule in the message verification configuration information.
In the embodiment of the invention, the message verification configuration information in the message adaptation configuration file is analyzed through the container, so that the message verification rule for XML message verification is obtained. The container analysis message check rule is completed when the program is started, and is stored in the memory after being analyzed.
For a text-type tag, configuration is performed for each value field in the packet adaptation, for example, the form shown in table 1 below may be adopted, and the configuration file of the corresponding example may be as follows.
Figure GDA0001858471730000041
Figure GDA0001858471730000051
Figure GDA0001858471730000061
TABLE 1
Figure GDA0001858471730000062
The numeric tag is configured for each value field in the packet adaptation, for example, the form shown in table 2 below may be adopted, and the configuration file of the corresponding example may be as follows.
Figure GDA0001858471730000063
Figure GDA0001858471730000071
Figure GDA0001858471730000081
TABLE 2
Figure GDA0001858471730000082
Figure GDA0001858471730000091
For the time-of-day type tag, each value field in the message adaptation is configured, for example, the form shown in table 3 may be adopted, and the corresponding configuration file is shown as follows.
Figure GDA0001858471730000092
Figure GDA0001858471730000101
TABLE 3
Figure GDA0001858471730000102
Figure GDA0001858471730000111
Step S103, obtaining the XML message content to be checked.
In the embodiment of the present invention, the XML message to be verified may include: the method comprises the steps of accessing a message and an outbound message, wherein the accessing message is the message received by an application module or an application server, and the outbound message is the message sent from an application project or the application server to other modules. And requesting to access a message or an outbound message, obtaining the message content in a text form, and traversing by using an XML (extensive Makeup language) stream reader.
In the embodiment of the present invention, obtaining the content of the XML message to be verified includes: and acquiring the value of the tag in the XML message, and putting the value into the attribute of the corresponding class so as to generate the corresponding class object. For example, when the message adaptation analysis is performed, the label of ORDER _ COUNT is analyzed first, the value of the label is obtained to be 60, then the label is put into the attribute orderCount of the class, then the message verification is performed on the field, whether the length of the value exceeds 3 is judged, after the verification is passed, whether the value is greater than 2 and smaller than 100 is judged, after the message verification is passed, the analysis of the next field TXN _ TM is continued, and so on. For example, after the message adaptation analysis is finished, a class object is generated, and the class object has 3 attributes
class F30070001InVo{
int orderCount;
String txnTm;
String acctNo;
}
The values of the above 3 attributes are 60,1990-08-08, acctno001
And step S104, verifying the XML message content to be verified according to the analyzed verification rule.
In the embodiment of the present invention, the verification of the XML message according to the verification rule analyzed from the message adaptation configuration file may include the verification of the length of the field.
In some embodiments, the verifying the content of the XML message to be verified according to the parsed verification rule includes: the length of the value field of the tag is obtained using the getbytes method for length checking. The method adopts the getBytes, mainly aims at Chinese characters, the length of the Chinese characters is determined, and the getBytes method is used instead of the getlength method in JAVA language. For the length of the field, the number of bytes obtained after the default character of the platform is coded is taken, i.e. the length value obtained after the getBytes () method is used, for example: the default character code of the platform is UTF-8, then String is equal to "China"; the execution result of s.getbytes (). length is 6 instead of 2.
The XML message rule checking and processing method provided by the embodiment of the invention can complete the checking of the message field during message conversion, can find errors more timely and improve the overall checking and processing efficiency of the XML message rule checking.
In some embodiments of the present invention, a switch field for identifying whether message verification is performed may also be set in the message adaptation configuration file. And checking a field in the switch field configuration file, if the switch is turned on, checking the message conversion rule, otherwise, not checking the switch. The switch fields are mainly applied to a test stage, some fields may not determine specific rules in the test stage, the switch is turned off temporarily, and the switch is turned on for testing after the verification rules are determined, so that the test is convenient.
The XML message rule checking method provided by the embodiment of the invention forms the modular rule checking processing frame of the XML message, and the processing frame is arranged in the message adaptation function of the java platform to replace the checking logic which is realized sporadically in each application project, thereby realizing the standard, standard and high-efficiency processing frame for the XML message checking.
In a specific embodiment, the verification process of the XML message is as shown in fig. 4.
Step S401, reading a message adaptation configuration file, wherein the message adaptation configuration file comprises a message check rule;
step S402, the container analyzes the message check rule;
step S403, requesting message access or message outgoing call;
step S404, obtaining the message content in the text form, and traversing by using an XML stream reader;
step S405, obtaining a value field of the message, and verifying by adopting a corresponding rule;
step S406, checking whether the switch is turned on, if so, executing step S407, otherwise, executing step S408;
step S407, checking is carried out, the subsequent steps can be carried out only through checking, and otherwise, an error is reported and returned to the application item;
in step S408, no verification is performed.
The XML message verification processing method provided by the embodiment of the invention can reuse the message verification function among different application projects, avoids repeated realization of message verification among different projects, saves repeated development cost among the application projects, is convenient for unifying verification standards among multiple application projects and is convenient for verification management.
The embodiment of the invention also provides computer equipment. As shown in fig. 5, the computer device 500 may comprise a memory 501 and a processor 502, wherein the memory 501 stores computer instructions and the processor 502 is configured to execute the computer instructions to cause the computer device 500 to implement the method described above.
Embodiments of the present invention also provide a computer-readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method described above.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present invention can be implemented by combining software and a hardware platform. With this understanding in mind, all or part of the technical solutions of the present invention that contribute to the background art may be embodied in the form of a software product, which can be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, a smart phone, or a network device, etc.) to execute the methods according to the embodiments or some parts of the embodiments.
The terms and expressions used in the specification of the present invention have been set forth for illustrative purposes only and are not meant to be limiting. It will be appreciated by those skilled in the art that changes could be made to the details of the above-described embodiments without departing from the underlying principles thereof. The scope of the invention is, therefore, indicated by the appended claims, in which all terms are intended to be interpreted in their broadest reasonable sense unless otherwise indicated.

Claims (9)

1. A method for checking XML message rules is characterized in that the method comprises the following steps:
reading a message adaptation configuration file in an XML format, wherein the message adaptation configuration file is arranged in an adaptation module of a java platform and comprises message adaptation configuration information and message verification configuration information, the message adaptation configuration information comprises associated information for converting an XML message into a java class, the associated information comprises a node name, an attribute name and a type, and the message verification configuration information comprises a data class field for identifying a service data class and a verification field for identifying a verification rule;
analyzing the message adaptation configuration file to obtain a message verification rule in the message verification configuration information;
acquiring XML message content to be checked;
and verifying the XML message content to be verified according to the analyzed verification rule.
2. The method of claim 1, wherein the traffic data categories include one or more of: text type, numerical type, and time-date type.
3. The method of claim 2, wherein the numerical traffic data comprises the following checking rules: the maximum length check of the number, the value range check and whether the field is a null check.
4. The method according to claim 2, wherein the textual service data includes the following verification rules: a maximum length checksum field of the text is checked for being empty.
5. The method of claim 2, wherein the time-date type service data comprises the following verification rules: a check whether the field is empty and a check of the time expression format.
6. The method according to claim 1, wherein the obtaining the XML message content to be verified comprises:
and acquiring the value of the tag in the XML message, and putting the value into the attribute of the corresponding class so as to generate the corresponding class object.
7. The method according to claim 6, wherein the verifying the XML packet contents to be verified according to the parsed verification rule comprises:
the length of the value field of the tag is obtained using the getbytes method for length checking.
8. A computer device comprising a memory and a processor, wherein the memory stores computer instructions; a processor configured to execute the computer instructions to cause the computer device to perform the method of any one of claims 1 to 7.
9. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of any one of claims 1 to 7.
CN201810991829.0A 2018-08-29 2018-08-29 XML message rule checking method, equipment and storage medium Active CN109379326B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810991829.0A CN109379326B (en) 2018-08-29 2018-08-29 XML message rule checking method, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810991829.0A CN109379326B (en) 2018-08-29 2018-08-29 XML message rule checking method, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109379326A CN109379326A (en) 2019-02-22
CN109379326B true CN109379326B (en) 2021-07-06

Family

ID=65404812

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810991829.0A Active CN109379326B (en) 2018-08-29 2018-08-29 XML message rule checking method, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109379326B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110336814A (en) * 2019-07-03 2019-10-15 中国银行股份有限公司 A kind of analytic method, equipment and the system of SWIFT message
CN110597712B (en) * 2019-08-27 2023-09-05 北京奇艺世纪科技有限公司 Component attribute verification method, device, terminal and storage medium
CN110430103B (en) * 2019-09-18 2020-06-05 光大兴陇信托有限责任公司 Message monitoring method
CN110688823B (en) * 2019-09-20 2023-08-22 中国银行股份有限公司 XML file verification method and device
CN113761879B (en) * 2020-06-01 2024-02-20 中国电信股份有限公司 Message format verification method, device and storage medium
CN112039975A (en) * 2020-08-26 2020-12-04 中国建设银行股份有限公司 Method, device, equipment and storage medium for processing message field
CN112784112B (en) * 2021-01-29 2023-06-27 银清科技有限公司 Message verification method and device
CN115085867B (en) * 2022-06-15 2024-01-19 北斗星通智联科技有限责任公司 E2E verification method and device for CAN bus message

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7370091B1 (en) * 2000-05-09 2008-05-06 Sun Microsystems, Inc. Method and apparatus for obtaining space advertisements
US7346889B1 (en) * 2003-01-16 2008-03-18 Oracle International Corporation Method and system for building message instances
CN1299200C (en) * 2003-12-26 2007-02-07 中兴通讯股份有限公司 Unified converting method for interface data in telecommunication network management system and its system
CN101339500B (en) * 2008-05-22 2010-06-09 清华大学 Data binding application program interface creation method based on XML mode
CN102123099B (en) * 2011-03-18 2013-07-24 中国工商银行股份有限公司 Message processing system and method
CN102426549B (en) * 2011-09-08 2013-06-26 新一站保险代理有限公司 Efficient Web form validation method and framework thereof
CN103870274A (en) * 2014-03-14 2014-06-18 浪潮集团山东通用软件有限公司 Visual development assembly for realizing data interaction between heterogeneous systems based on web service technology
CN105138613A (en) * 2015-08-07 2015-12-09 北京思特奇信息技术股份有限公司 Business object and xml message mutual conversion method and system
CN105607923A (en) * 2015-12-10 2016-05-25 中国航空工业集团公司西安航空计算技术研究所 Cross-platform avionics system configuration data generation and recovery method
CN107733556B (en) * 2016-08-12 2021-09-07 北京小米移动软件有限公司 Message checking method and device
CN107194853A (en) * 2017-04-26 2017-09-22 北京零科技有限公司 The integration method and system of a kind of public business data
CN107483467A (en) * 2017-08-31 2017-12-15 四川长虹电器股份有限公司 The JSON message checking methods of Internet interface service

Also Published As

Publication number Publication date
CN109379326A (en) 2019-02-22

Similar Documents

Publication Publication Date Title
CN109379326B (en) XML message rule checking method, equipment and storage medium
CN113269547B (en) Data processing method, device, electronic equipment and storage medium
CN107480053A (en) A kind of Software Test Data Generation Method and device
CN104331366A (en) Test case design efficiency promotion method and system
CN107862425B (en) Wind control data acquisition method, device and system and readable storage medium
CN110427188B (en) Configuration method, device, equipment and storage medium of single-test assertion program
CN112383533A (en) Message format conversion method and device
CN112541002A (en) Program language conversion method, device, electronic equipment and storage medium
CN106844471A (en) A kind of electronic operation and maintenance system form data processing method and server
CN113489593B (en) JSON message checking method and JSON message checking device
CN109861998B (en) Plug-in type dynamic analysis system and method based on Beidou short message protocol
CN114553784A (en) Current limiting processing method and device
CN109145027A (en) Data statistical approach, device, equipment and computer readable storage medium
CN109871229A (en) Management method, device, storage medium and the terminal device of code text
CN107040613A (en) A kind of message transmitting method and system
CN112785124A (en) Method and system for auditing compliance of telecommunication service
CN115982012A (en) Evaluation model and method for interface management capability maturity
CN115269220A (en) Business processing method and rule service interface
CN111400187B (en) Parameter dynamic verification system and method based on customized data source
CN110516258B (en) Data verification method and device, storage medium and electronic device
CN117389700A (en) Method, device, system and storage medium for processing data of integrated stream and batch
CN112541688A (en) Service data checking method and device, electronic equipment and computer storage medium
CN112100260A (en) Interface engine-based multi-application data fusion method and system
CN115357286B (en) Program file comparison method and device, electronic equipment and storage medium
CN111355709A (en) Data verification method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant