The Pacman Project
The Webservice
When trying to write a webservice, some software is needed that handles the connections between the host/server and the clients. In our project several functionalities were needed to make the clients communicate with the central server. The central server of this project provides these functionalities which can be used by the PDA clients or other clients. Each client imports the WSDL-file (Web-Service-Description-Language) which is located on the server and in which is described what functionality the server provides for the clients. The WSDL-file is an XML Document which is (in our project) automatically generated by the AXIS-Server. It describes which parameters and return values are provided by the webservice, to which Internet-Protocol (IP) address the server is bound and also contains other information.
4.1 Axis
The used Webservice-System is called AXIS2 and is often used together with a Tomcat-Server. Tomcat and Axis both belong to the Apache Webserver Framework and are provided by the Apache Foundation.
4.2 Installation
The Axis-Webservice-Server comes in two different versions: One is a binary distribution which runs on its own, the other one is an extension for the TomcatJava-Webserver. In our project we first made tests with the Tomcat Server but got a lot of errors and java-exceptions which we could not solve. That is why we decided to run the binary standalone distribution. It is a compressed zip-file which was installed in the server's /opt/axis2-1.4 directory.
4.3 Building a webservice
When trying to build a webservice, there are several ways to do that. After a lot of tests with different methods, we used the inner Axis Functionality to help us building webservices. Axis provides several additional scripts to generate e.g. WSDL-files from Java-Code or generate Java-Classes from a given WSDL-file. In our way, we put a webservice.aar file in the repository/services directory of Axis and restarted the build in Axis-Server.
4.4 The Deployment Workflow
The used Integrated Develpment environment (IDE) is eclipse. We have a shell-script which packs the class-files into an .aar package, adds other files (like a services.xml file) and copies this file via Secure-Copy (SCP) to the server. There, another script is automatically started. The server-script kills all processes which run Axis and restarts axis. Because of the fact that all started processes on a linux system belong to the current shell, the axis-server must be started without belonging to a specific shell. This is done by the 'nohup' command which runs the axis-server in the background. The given output of the axis-server is written to the command line because of debugging reasons. Now all Webservices are provided and can be seen in the Axis-Standards-Page.
4.5 Provided Functionality
The PacMaas Web Service provides different functionality which is used by the clients.
- registerAsPacman - Registers the given name as a pacman client. A unique ID is returned which is the Userid of pacman. All other calls of pacman should be done with this ID.
- registerAsGhost - Register as ghost registers a new ghost to the System. Maximum Number of Ghosts is currently 3. A unique ghost-id is returned or -1 if the ghost could not be registered.
- registerAsVisitor - Registers a visitor to the system. This can be used to provide functionality for example to a website on which users can see how the game is running.
- getGameState - This method returns how many ghosts are connected to the webservice, if a ghost is connected and in which game-status the system is.
- updatePosition - Each player can update its position with this method. Parameters are the unique player id and a six-dim array with the gps-position.
- getAdvice - Returns an advice to the player.
- getLastPillRemoved - Returns the id of the pill that is removed last time.
- getAllGhostIDs - Returns all unique IDs of the ghosts.
- getGhostPosition - Parameter is a unique ghost-id and returned is a six-dim array with the gps-position of that ghost.
- getPacmanPosition - Parameter is the unique ID of the calling user itself and returned is a six-dim array with the gps-position of pacman. No registered ghost is allowed to see the position of pacman.
- unregister - Unregistering a Player is done with this method. The unique ID must be a valid player-id.
- unregisterAllPlayers - To end a game, this method deletes all connections to the players and resets the game. It is protected by a secure code.
- startSimulation - Calling this method with a secure code as parameter, starts an internal simulation. (See Simulation chapter)