XML and Web Services with Java
Theory
- Session 1: Introduction to Web Services
- Session 2: Web Services Description Language (WSDL)
- Session 3: Introduction to SOAP (Simple Object Access Protocol)
- Session 4: Introduction to UDDI (Universal Description, Discovery, and Intergration)
Lab
Chuẩn bị phần mềm:
- NetBeans (http://www.netbeans.org)
- Hiểu được khái niệm đối số (argument) và cách thao tác trong NetBeans
- Một số thư viện hỗ trợ: xmlRPC, AXIS,…
- Tạo tệp “Employee.xml” lưu thông tin về nhân viên như sau, element “Company” là root element:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : Employee.xml
Description: Stores the Employee details.
-->
<Company>
<Employee>
<EmployeeName> John D'souza </EmployeeName>
<Department> Human Resource </Department>
<Designation> Manager </Designation>
<Salary> 10000 </Salary>
</Employee>
<Employee>
<EmployeeName> Anna Thomas </EmployeeName>
<Department> Operations </Department>
<Designation> Executive </Designation>
<Salary> 8000 </Salary>
</Employee>
<Employee>
<EmployeeName> Martin John </EmployeeName>
<Department> Accounts </Department>
<Designation> Senior Manager </Designation>
<Salary> 20000 </Salary>
</Employee>
</Company>
-
Tạo một lớp Bean “EmployeeBean.java” có các biến kiểu… và tạo các phương thức… cho Bean này. Sau đó tạo lớp “EmployeeClass.java” để tương tác với tệp tin XML (các chỗ … là sinh viên tự làm, GV sẽ chữa trên lớp) .
-
Retrieve DOM Tree nodes: Vẫn lớp “EmployeeClass.java” ở trên, tạo một phương thức createBeanContent(Node node, String indent) để xử lý mỗi nút có tên Element trong tệp “Employee.xml”, phương thức này gồm 2 biến đầu vào:
- node: chứa DOM tree, tuy nhiên với các lời gọi sau lần gọi đầu thì node sẽ chứa một nút “Element”
- indent: chứa các khoảng cách để đẩy thụt lùi các elements trong tệp đầu ra