Presentation is loading. Please wait.

Presentation is loading. Please wait.

Offline Database Synchronization with SOAP and MySQL

Similar presentations


Presentation on theme: "Offline Database Synchronization with SOAP and MySQL"— Presentation transcript:

1 Offline Database Synchronization with SOAP and MySQL
Matt Nesterenko CS5260 11/12/2018 Matt Nesterenko

2 Simple Sync Methods Flush database with client data
The server acts as a backup essentially Compare all records and see what has changed Very costly with bandwidth and time Mark modified records with a sync flag What about deleting data? The record with the flag was deleted! How can we handle multiple users syncing the same data? 11/12/2018 Matt Nesterenko

3 Data Auditing Save all the changes made to a log file or database table Forward the changes to the other end of the connection To allow multiple users, the server must keep track of individual user modifications If using auto generated IDs (MySQL: auto_increment) the client must keep a record of the server ID field as well to keep data synchronized 11/12/2018 Matt Nesterenko

4 How server syncs data The server is a Java web-service which uses SOAP (Simple Object Access Protocol) for client requests. Client is in control of the sync, which includes adding/editing/deleting data on the server and retrieving the list of modifications from the server. The preferred underlying protocol for SOAP is HTTP (which runs over TCP). The data transferred is in preformatted XML format. The format that is sent/received is described in a WSDL (Web Service Description Language) file provided by the web service. The client initiates data transfer with a SOAP request, and when the action is performed, the server responds with a SOAP response. 11/12/2018 Matt Nesterenko

5 SOAP Client App Client Data Table Audit Table Audit Table
WSDL HTTP TCP Audit Table Server Data Table Server Web Service 11/12/2018 Matt Nesterenko

6 Java Client Output Added two tasks: Task One, Task Two, renamed task two to: Task Two Renamed. On server-side, three tasks were added and one was edited (from another use) Sync Output on Client: [sync/info/add] Synced local to remote (local:remote) (1:4) [sync/info/add] Synced local to remote (local:remote) (2:5) [sync/info/edit] Synced local to remote (local:remote) (2:5) [sync/info/get/add] Synced remote to local (local:remote) (0:1) [sync/info/get/add] Synced remote to local (local:remote) (0:2) [sync/info/get/add] Synced remote to local (local:remote) (0:3) [sync/info/get/edit] Synced remote to local (local:remote) (4:2) 11/12/2018 Matt Nesterenko

7 Java client output (cont.)
After sync, task list on client outputs: [1] Task One [Synced] [2] Task Two Renamed [Synced] [3] Server Task 1 [Synced] [4] Server Task 2 Renamed [Synced] [5] Server Task 3 [Synced] Now delete a task client-side and resync. Sync output: [sync/info/delete] Synced local to remote 11/12/2018 Matt Nesterenko

8 SOAP REQUEST (adding a task)
Client requests to add a task, sending the name of the task, and a device id <?xml version="1.0" encoding="UTF-8"?> <S:Envelope xmlns:S=" <S:Header/> <S:Body> <ns2:AddTask xmlns:ns2=" <name>A Task</name> <devid>55</devid> </ns2:AddTask> </S:Body> </S:Envelope> 11/12/2018 Matt Nesterenko

9 Soap response Server returns the ID of the added task, or -1 if it failed to add the item <?xml version="1.0" encoding="UTF-8"?> <S:Envelope xmlns:S=" <S:Body> <ns2:AddTaskResponse xmlns:ns2=" <return>6</return> </ns2:AddTaskResponse> </S:Body> </S:Envelope> 11/12/2018 Matt Nesterenko

10 Summary Keep track of all changes made both client and server side Keep client IDs mapped with server IDs for synchronization SOAP can be used for a web-service to communicate back and forth with between the server and client SOAP is XML with required tags sent over HTTP 11/12/2018 Matt Nesterenko


Download ppt "Offline Database Synchronization with SOAP and MySQL"

Similar presentations


Ads by Google