Web Services – Fall 2006 - FAU College of Engineering
Download
Report
Transcript Web Services – Fall 2006 - FAU College of Engineering
Florida Atlantic University
Department of Computer Science & Engineering
COP 4814 – Web Services
Dr. Roy Levow
Part 1 – Introducing Ajax
Fall 2006
Ajax is Born
• February 2006
• Jesse James Garrett of Adaptive Path
Conceives alternative to Macromedia Flash using
• Asynchronous HTTP Request
• JavaScript
• XML
• Publishes ideas online
Ajax: A New Approach to Web Applications
• See also article form June 2006 Wired
• Intro to Ajax film clip
Web Services – Fall 2006
Frames
• Introduced in HTML 4.0
• Allow page to be loaded into portion of browser window
• Use discouraged in XHTML because of poor interaction with back
button
• Hidden frame technique
• Use 1-pixel frame to contain form (thus hidden)
• Fill in form from JavaScript and submit
• Receive response asynchronously to update page
• Iframes
• Independent of frameset
• Go anywhere on page and can be hidden
Web Services – Fall 2006
The Real Ajax
• On Browser
• Ajax Engine (JavaScript code)
•
•
•
•
Generates display using HTML and CSS
Receive JS calls from user intefface
Sends HTTPRequest to Server
Receives Data from Server
• Server
• Recieves HTTPRequest from Browser
• Interacts with local database
• Sends Data to Browser
Web Services – Fall 2006
HTTP
• Hypertext Transfer Protocol
• Accepts requests from browser
• Transfers responses to browser
• Fetch web pages
• but has many other uses
• HTTPRequest format
<request-line>
<headers>
<blank line>
[<request body>]
Web Services – Fall 2006
HTTP Request
• Many request types
• GET and POST are of interest in Ajax
• Example GET
GET / HTTP/1.1
Host: www.wrox.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.6) Gecko/20050225 Firefox/1.0.1
Connection: Keep-Alive
• Get request for root node with HTTP version
• Originating client and information on client
• Request to maintain connection for more transfers
Web Services – Fall 2006
HTTP Request
Item following GET is path to page to load
GET /index.html HTTP/1.1
Parameters can be appended to the url with
URL ? name1=value1&name2=value2&…
Web Services – Fall 2006
POST
POST Example
POST / HTTP/1.1
Host: www.wrox.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.6) Gecko/20050225 Firefox/1.0.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 40
Connection: Keep-Alive
name=Provessional%20Ajax&publisher=Wiley
Adds Content-Type, Content-Length, and data
Web Services – Fall 2006
GET vs POST
GET
Data coded and sent as part of URL
Data visible (and modifiable) by user
Use for smaller amount of data
Slightly less transmission overhead
POST
Data sent separately from URL
Invisible to user
Can easily handle large amount of data
Web Services – Fall 2006
HTTP Responses
• Response format
<status-line>
<headers>
<blank line>
<[<response-body>]
• Example
HTTP/1.1 200 OK
Date: Sat, 31 Dec 2005 23:59:59 GMT
Content-Type: text/html; charset=ISO8859-1
Content-Length: 122
Web Services – Fall 2006
Response Codes
•
•
•
•
•
200 (OK) – the one we want
304 (NOT MODIFIED) – used to check cached page
401 (UNAUTHORIZED)
403 (FORBIDDEN)
404 (NOT FOUND)
Web Services – Fall 2006