Summary of the invention
For solving the problem, the invention provides a kind of WEB service system based on XML, comprise WEB client side, WEB server, data interaction is completed by XML file between WEB client side and WEB server, described WEB server comprises XML processing module, data processing module, data source, data-interface, memory module, wherein
Memory module is used for memory page configuration file and predefined XML file template;
XML processing module is used for the page script of load page configuration file, receives the XML request of WEB client side, be script request and request of data by XML request analysis, complete script request response, and request of data is sent to data processing module, receive data processing module feedback data, adaptive XML template, complete XML file encapsulation, send packaged XML file to WEB client side;
Data processing module is used for the data item of load page configuration file, according to the related data in request of data linked database, and related data is fed back to XML processing module;
Data source is this locality or the far-end server that store data, gives WEB client side and provides Data support;
Data-interface is used for the data of operating database;
Page configuration file module comprises page script file and page data configuration file, and page script file, for constructing WEB page, comprises page index, support equipment model, data item information in page data configuration file; All kinds of key words involved by each WEB page all present with the form of page configuration file.
Further, the data item of described data processing module load page configuration file sets up data directory tree, the data-interface that the data item association in data directory tree is corresponding.
Further, described data-interface is mib node or api interface.
Further, data source adopts mib node or api interface or database.
Further, the data item of page data configuration file comprises the index of each data, type, oid and/or database index.
Further, all kinds of key words involved by WEB page all present with the form of configuration file.
Further, the laggard row cache of XML processing module load page script file, utilizes the data of the page script of buffer memory and data processing module feedback to carry out XML file encapsulation.
The method of work of the above-mentioned WEB service system based on XML, comprises following steps: step one: WEB client side sends XML and asks WEB server;
XML request analysis is script request and request of data by step 2: the XML processing module of WEB server carries out XML request analysis;
Step 3: desired page script is loaded in buffer memory according to page configuration file by XML processing module, and send data request processing to data processing module;
Step 4: data processing module extracts the page data of page configuration file, generates data directory tree;
Step 6: locator data node, is mapped to associated data interface, and is associated with data source;
Step 7: data source by data-interface by data feedback to XML processing module;
Step 8: XML processing module carries out XML template adaptation according to the data of feedback;
Step 9: utilize the page script of buffer memory and the data of feedback to fill XML template, completes XML encapsulation;
Step 10: packaged XML file is transferred to WEB client side, completes XML request response.
Beneficial effect of the present invention is:
The present invention by XML being made a general module, unified treatment scheme.The mode of XML template is used to meet the XML request of various pattern.Isolate the Data Node of each page, make a database, the general-purpose interface of service data is provided.Additionally by page configuration file by Data import in need for institute to WEB server, to promote the handling property of WEB server.The WEB page of planning, involved all kinds of key words all present with the form of configuration file, and this configuration file derives the data needed for WEB server again, carrys out constructs database.The development of WEB client side and server so, does bridge with a common page configuration file, meets the synchronous of information, greatly reduce mutual constraint, can realize concurrent product development.
embodiment:
In the development mode of common WEB server, each page needs process separately, and it flips the signal of its processing mode as shown in Figure 2.The keyword definition of request msg and content need to reach unification with WEB client side exploitation in advance.Be limited to WEB client side in Server development process more, and along with the revision of WEB page, the realization of WEB server also can be inconjunction with revision, and the handling property of WEB server also exists certain hidden danger.
In order to solve the problem, the present invention changes conventional thought, and WEB server treatment scheme and development mode are all improved, and proposes a kind of WEB service system based on XML newly itself and method of work thereof.Be introduced respectively below.
WEB service system based on XML comprises WEB client side, WEB server, completes data interaction between WEB client side and WEB server by XML file.The present invention, when developing WEB server, according to the feature of all kinds XML, defines different XML templates, to unify treatment scheme.The mode of XML template is used to meet the XML request of various pattern.Each XML template only needs to carry out corresponding data and script is filled.
In the present invention, the treatment scheme of WEB server all has unified flow process, and its flow process as shown in Figure 3.Treatment scheme has been come by following XML processing module and data processing module, and therefore in WEB server performance history, groundwork concentrates on page configuration file, once configuration file housekeeping is complete, can generate corresponding data item.Therefore can reduce the resource input of exploitation to a great extent, be applicable to development mode rapidly and efficiently.
Understand the present invention for convenience, first page configuration file is described below.All kinds of key words involved by each WEB page all present with the form of page configuration file.Described page configuration file comprises: page script file and page data configuration file.
Described page script file is for constructing WEB page, and content for script is directly encapsulated in the XML file that WED server responds to WEB client side.Page script only need from page configuration file take out and stored in buffer memory, the treatment effeciency of raising server that can be larger.
Comprise the information such as page index, support equipment model, data item in page data configuration file, wherein data item comprises index, the oid(object identifier of each data), type, data source index.
Oid and data source index all as getting data, can adapt to diversified data processing.Oid needs snmp server and supports, the oid uniquely indicated by data is processed.Data source index, directly according to the parameter of specifying, navigates to corresponding business datum node, re-uses api interface to process.
Page data configuration file is schematically as follows:
<DataItem id="dimenid1">
<oidconfig devtype="devtype1">
<dataOid key="key1" oid=".1.1.1.1.1. " type="type1" value=”module1.key1 “/>
<dataOid key="key2" oid=".1.1.1.1.2. " type="type2" value=”module1.key2 “/>
<dataOid key="key3" oid=".1.1.1.1.3. " type="type3" value=”module1.key3 “/>
</oidconfig>
</DataItem>。
File content illustrates, as table 1.
Type |
Key word |
Function |
Citing |
Page index |
id |
Determine the unique identification of a page |
dimenid1 |
Device type |
devtype |
Adapt to distinct device type |
devtype1 |
Data directory |
key |
Determine a data item |
key1 |
Data oid |
oid |
Determine data mib node |
.1.1.1.1.1. |
Data type |
type |
Data content form |
type1 |
Data source indicates |
value |
Locator data is carried out according to the level of business |
module1.key1 |
Table 1
Below WEB server is introduced.
Described WEB server, except the working procedure of necessity and related hardware, also comprises XML processing module, data processing module, data source, data-interface, memory module.
Memory module is used for memory page configuration file and XML file template.
The effect of XML processing module is as follows:
1. the page script of the page configuration file required for loading is in buffer memory.
2. receive the XML request of WEB client side, in conjunction with the feature of XML language, decompositing corresponding data, is script request and request of data by XML request analysis, completes script request response, and request of data is sent to data processing module.
3. receive the data of data processing module feedback, adaptive XML template.
The present invention, according to the feature of all kinds XML, defines different XML templates, then fills corresponding template data according to the type of actual request, to adapt to all kinds XML request, reaches the object of unified process.
4. will XML data, page script, the result of feedback, and the information such as data encoding, language, is assembled into a complete XML file.
5. send packaged XML file to WEB client side.
Data processing module effect is as follows:
1. extracted by all page datas according to page configuration file, the data item required for it is loaded previously in data directory tree, so that rapidly locating node.
2. be associated with the data source of corresponding business module according to the configuration parameter of page data, and related data is fed back to XML processing module.
Data source is this locality or the far-end server that store data, gives clients providing data support.The network environment at data source place and position may there are differences, and this uses different modes to visit data with regard to needing.Wherein api interface mode is applicable to the data source that directly access is local, and mib and database are applicable to access this locality or far-end server data of specifying.
Data-interface is used for the data of operating database.Data-interface can adopt the mode such as mib node or business api interface, or can adopt according to the needs of embedded device reality.The data-interface that data item in index tree needs association corresponding, carrys out processes data requests.
Below in conjunction with Fig. 4, the workflow of native system is described.
Step one: WEB client side sends XML and asks WEB server;
XML request analysis is script request and request of data by step 2: the XML processing module of WEB server carries out XML request analysis;
Step 3: desired page script is loaded in buffer memory according to page configuration file by XML processing module, and send data request processing to data processing module;
Step 4: data processing module extracts the page data of page configuration file, generates data directory tree;
Step 6: locator data node, is mapped to associated data interface, and is associated with data source;
Step 7: data source by data-interface by data feedback to XML processing module;
Step 8: XML processing module carries out XML template adaptation according to the data of feedback;
Step 9: utilize the page script of buffer memory and the data of feedback to fill XML template, completes XML encapsulation;
Step 10: packaged XML file is transferred to WEB client side, completes XML request response.
Beneficial effect of the present invention is:
The present invention by XML being made a general module, unified treatment scheme.The mode of XML template is used to meet the XML request of various pattern.Isolate the Data Node of each page, make a database, the general-purpose interface of service data is provided.Additionally by page configuration file by Data import in need for institute to WEB server, to promote the handling property of WEB server.The WEB page of planning, involved all kinds of key words all present with the form of configuration file, and this configuration file derives the data needed for WEB server again, carrys out constructs database.The development of WEB client side and server so, does bridge with a common page configuration file, meets the synchronous of information, greatly reduce mutual constraint, can realize concurrent product development.