Ordinary websites, written in HTML, are very much geared towards the end user. The end user uses the HTML interface to perform particular tasks. However the end user is not the only possible consumer of information on the web. What about other applications? A web service is an application running on a web server which provides raw information to other applications. These other applications are clients to the web service because they make a connection to it and process the information sent back. Here are a few examples of web services and their clients:
Web services obviously send back information to their clients, but what format is typically used? HTML is one possibility but is not considered a good idea because HTML contains not only data, but also page structure information (headings, paragraphs, tables etc). A client to the web service might wish to arrange the information in a different way. Also some web service clients are not websites at all, for example the Java application used by the travel agent in the above example, or the weather "app". We could still use HTML, however it would be tricky to write a parser - a program which interprets the data and extracts the relevant information from it - as HTML contains all manner of formatting and style information in addition to the data itself.
So what we want is a format which represents the data, and the data alone. XML is one such format, and will be described here. Another is JSON: we will not have time to look at this today, but it is something which we will do later.
XML is a data description format which, like HTML, uses tags. Unlike HTML, XML is not a language as such, but rather a format for describing data. With XML, we make up our own tags to accurately describe the data. For example, some data describing students might look as follows:
Note how:Mark Gill 9gillm69 07111 111111 Steve Mills 1mills63 07222 222222 ]]> Rob Price 5pricr67 07333 333333
To be so-called well-formed XML, data must match these syntax rules:
As has already been indicated, XML is an ideal format for sending back data to clients from a web service. This is because it is pure data containing no presentation or formatting, meaning that the client application can parse (interpret) the XML and extract the data from it in whatever manner it sees fit. So we could have a web service which delivers weather data for a particular city as XML, and different clients could format it appropriately, for example a tourist board website could integrate the weather data using its own style, while a mobile phone "app" could do the same.
You have an account for the Edward web server. If you were here last year, it's the same as last year. If you are a BIB student, please see me for your login details. Info about how to upload files using FTP is here.
You will also extensively be using the dftitutorials database. To access this, go to PHPMyAdmin and login with username dftitutorials/password dftitutorials. For today, you will be using the hits table within the dftitutorials database. For the assignment, you will use your own database with the same login as for FTP.
You are now going to start developing a web service. The web service is offered by HitTastic!, a leading online music store and pop chart database. PHP is the server-side language used in the unit; if you need any revision on PHP, please see the Developing for the Internet site here.
header("Content-type: text/xml");
This line informs clients that XML is being sent back from the server, so they can act
accordingly.
Please use the dftitutorials login for the database, as given below.
"; } mysql_close($conn); ?>