Discussion #4 CSS VS XSLT. Multiple stylesheet types with cascading priorities. One stylesheet type

Similar documents
Send me up to 5 good questions in your opinion, I ll use top ones Via direct message at slack. Can be a group effort. Try to add some explanation.

PS/2 Web Services

REST Services. Zaenal Akbar

REST - Representational State Transfer

What is REST? ; Erik Wilde ; UC Berkeley School of Information

Notes General. IS 651: Distributed Systems 1

04 Webservices. Web APIs REST Coulouris. Roy Fielding, Aphrodite, chp.9. Chp 5/6

XML Processing & Web Services. Husni Husni.trunojoyo.ac.id

REST Easy with Infrared360

User Interaction: jquery

InstaMember USER S GUIDE

RESTful Services. Distributed Enabling Platform

AIM. 10 September

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine.

Services Web Nabil Abdennadher

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

API USER GUIDE MARKETING MESSAGES & BROADCASTS

Web Services Week 10

WildFly and Java EE 7. What are they? New Features Some Examples Questions

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

REST AND AJAX. Introduction. Module 13

Develop Mobile Front Ends Using Mobile Application Framework A - 2

CS Final Exam Review Suggestions - Spring 2018

An Overview of. Eric Bollens ebollens AT ucla.edu Mobile Web Framework Architect UCLA Office of Information Technology

REST API Developer Preview

Session 14. Serialization/JSON. Lecture Objectives

IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4.

Case Study Schedule. NoSQL/NewSQL Database Distributed File System Peer-to-peer (P2P) computing Cloud computing Big Data Internet of Thing

RKN 2015 Application Layer Short Summary

Shankersinh Vaghela Bapu Institue of Technology

Copyright 2014 Blue Net Corporation. All rights reserved

Introduction to REST Web Services

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

ReST 2000 Roy Fielding W3C

Sending Data Updates to Tenstreet API Guide (rev 10/2017)

Sending Documents to Tenstreet API Guide (rev 06/2017)

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

AJAX Workshop. Karen A. Coombs University of Houston Libraries Jason A. Clark Montana State University Libraries

AJAX: Rich Internet Applications

Controller/server communication

TIME SCHEDULE MODULE TOPICS PERIODS. HTML Document Object Model (DOM) and javascript Object Notation (JSON)

API Spec Sheet For Version 2.5

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

Connect Media Bulk SMS API Documentation

CS109 Data Science Data Munging

<tr><td>last Name </td><td><input type="text" name="shippingaddress-last-name"

ONE SOCIAL. A Writing Project. Presented to. The Faculty of the Department of Computer Science. San José State University

API Spec Sheet For HLR v1.4

Andrew Nguyen - Brian Payton - Chunyang Xia

Developing RESTful Services Using JAX-RS

Create-A-Page Design Documentation

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

Sending Application Data to Tenstreet API Guide

Birkbeck (University of London)

of making things look better with CSS, and you have a much better platform for interface development.

JSON Example. This page shows examples of messages formatted using JSON (JavaScript Object Notation). The same text expressed as XML:

Service Oriented Architectures (ENCS 691K Chapter 2)

EPHP a tool for learning the basics of PHP development. Nick Whitelegg School of Media Arts and Technology Southampton Solent University

CSC 443: Web Programming

Designing RESTful Web Applications. Ben Ramsey

Outline. AJAX for Libraries. Jason A. Clark Head of Digital Access and Web Services Montana State University Libraries

STANDARD REST API FOR

Web System and Technologies (Objective + Subjective)

Lesson 14 SOA with REST (Part I)

AJAX: From the Client-side with JavaScript, Back to the Server

Biocomputing II Coursework guidance

Sending Job Requsition Data to Tenstreet API Guide (rev 09/2018)

WWW, REST, and Web Services

Comm 244 Week 3. Navigation. Navigation. Websites need a formalized system of links to allow users to navigate the site

PHP. MIT 6.470, IAP 2010 Yafim Landa


CS50 Quiz Review. November 13, 2017

Introduction to REST. Kenneth M. Anderson University of Colorado, Boulder CSCI 7818 Lecture 6 08/27/2008. University of Colorado 2008

CSCE 120: Learning To Code

Web Programming Paper Solution (Chapter wise)

CSE 336. Introduction to Programming. for Electronic Commerce. Why You Need CSE336

7401ICT eservice Technology. (Some of) the actual examination questions will be more precise than these.

Webservices, Proxies, Rest, File Uploads, Security. CS174. Chris Pollett. Nov. 3, 2008.

XML. Jonathan Geisler. April 18, 2008

Client Side JavaScript and AJAX

Web-APIs. Examples Consumer Technology Cross-Domain communication Provider Technology

SortMyBooks API (Application programming

Information Security CS 526 Topic 8

Errors Message Bad Authentication Data Code 215 User_timeline

week8 Tommy MacWilliam week8 October 31, 2011

Rico AjaxEngine Tutorial

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

Web Site Development with HTML/JavaScrip

CSCI 6312 Advanced Internet Programming

Controller/server communication

DATABASE SYSTEMS. Database programming in a web environment. Database System Course,

Introduction to XML. XML: basic elements

XML Web Service? A programmable component Provides a particular function for an application Can be published, located, and invoked across the Web

Chapter 10 Web-based Information Systems

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

RESTful API Design APIs your consumers will love

Programming the World Wide Web by Robert W. Sebesta

Working with Javascript Building Responsive Library apps

Transcription:

Discussion #4 CSS VS XSLT Difference 1 CSS Multiple stylesheet types with cascading priorities XSLT One stylesheet type Difference 2 Used for HTML Used for structured document Difference 3 Only client side Server side and client side Difference 4 Its own syntax XML syntax Difference 5 Commonality 1 Commonality 2 Same content, change representation Much powerful. Transformation result could only have less data Both can be used for document transformation Both can be used for html representation IS 651: Distributed Systems 1

Case Study Notes The goal of case study Learn the latest techniques in distributed systems know and collaborate with other team members Learn from other teams Process Team building: results have been sent out Select topic: talk to your team members on which topic to work on after class Inform your selection: post your topic on slack (case-study channel). For a topic, the team who post earliest get it. Search and select paper/project you want to work on: https://scholar.google.com/, http://www.apache.org/ Send me an email and get my approval Work as a team Present as a team: every member presents IS 651: Distributed Systems 2

Case Study Topics Team Topic Presentation date 1 NoSQL/NewSQL Database 11/16 (Week 13) 2 Parallel Computing 11/16 (Week 13) 3 Distributed File System 11/16 (Week 13) 4 Peer-to-peer (P2P) computing 11/30 (Week 14) 5 Mobile computing 11/30 (Week 14) 6 Ubiquitous/pervasive computing 11/30 (Week 14) IS 651: Distributed Systems 3

IS 651: Distributed Systems Chapter 7: REST Web Services Jianwu Wang

Learning Outcomes After learning chapter 7, you should be able to Understand the features of REST Web service and its differences from SOAP based Web service Know how to use proper method to call a REST Web service Know JSON and its differences from XML Know the cross-domain restriction and how to work around it IS 651: Distributed Systems 5

REST Basics REST is a term coined by Roy Fielding in his Ph.D. dissertation to describe an architecture style of networked systems. REST is an acronym standing for Representational State Transfer. It is easier to understand using representational resource state transfer. Resource: Resources are any addressable object (as something with a URI on the web), such as a book or student record. Representation: Resource representations for client and resources at server side are separated REST: access and manipulate resource states using a representational approach. We don t care how the resource is actually stored/managed on the server, we only care its representation from the client view IS 651: Distributed Systems 6

REST Basics (2) REST defines a set of architectural principles by which you can design Web services that focus on a system's resources, including how resource states are addressed and transferred over HTTP by a wide range of clients written in different languages. An HTTP REST Web service follows three basic design principles Use HTTP methods explicitly (HTTP is stateless) Expose directory structure-like URIs Transfer XML, JavaScript Object Notation (JSON), or both There are no standards/specifications for REST Web service IS 651: Distributed Systems 7

Use HTTP methods explicitly Methods POST: create GET: read, list, retrieve PUT: replace, update DELETE: delete GET Examples From your web browser: http://www.webservicex.net/uszip.asmx/getinfobyzip?uszip=21250 Curl command: curl -v http://www.webservicex.net/uszip.asmx/getinfobyzip?uszip=21250 IS 651: Distributed Systems 8

POST vs. GET POST should be used for creating resources (see #6 reference). Common error: Wrong: GET /adduser?name=robert HTTP/1.1 Correct POST /users HTTP/1.1 Host: myserver Content-Type: application/xml <?xml version="1.0"?> <user> <name>robert</name> </user> IS 651: Distributed Systems 9

GET vs. PUT GET is for data retrieval only. GET is an operation that should be free of side effects, a property also known as idempotence. GET /users/robert HTTP/1.1 Host: myserver Accept: application/xml Common error: Wrong: GET /updateuser?name=robert&newname=bob HTTP/1.1 Correct: PUT /users/robert HTTP/1.1 Host: myserver Content-Type: application/xml <?xml version="1.0"?> <user> <name>bob</name> </user> Similarly, DELETE should be used rather than a deleteuser function with GET. IS 651: Distributed Systems 10

Be Stateless A complete, independent request doesn't require the server, while processing the request, to retrieve any kind of application/client context or state. Treats each request as an independent transaction that is unrelated to any previous request A REST Web service application/client includes within the HTTP headers and body of a request all of the parameters, context, and data needed by the server-side component to generate a response. Stateless server-side components are less complicated to design, write, and distribute across load-balanced servers. A stateless service not only performs better, it shifts most of the responsibility of maintaining state to the client application. In a RESTful Web service, the server is responsible for generating responses and for providing an interface that enables the client to maintain application state on its own. For example, in the request for a multipage result set, the client should include the actual page number to retrieve instead of simply asking for next. The principle of loose-coupling implies statelessness. IS 651: Distributed Systems 11

Compare a Stateless and Stateful Service IS 651: Distributed Systems 12

Expose Directory Structure-like URIs REST Web service URIs should be intuitive to the point where they are easy to guess. Think of a URI as a kind of self-documenting interface that requires little, if any, explanation or reference for a developer to understand what it points to and to derive related resources. IS 651: Distributed Systems 13

Directory Structure-like URI Examples Example URIs from the book (not real): http://www.w3schools.com/catalog/cds (for cd list) http://www.w3schools.com/catalog/cds/2 (for the detailed info of the cd) http://www.w3schools.com/getcd.php?cd=2 (not the best url, but same as above) Examples from the #5 reference (not real): http://www.parts-depot.com/parts (for a parts list) http://www.parts-depot.com/parts/00345 (for a part) http://www.parts-depot.com/parts/getpart?id=00345 (not the best url, but same as above) IS 651: Distributed Systems 14

Transfer XML, JSON, or both The web service makes available a URL to submit a purchase order (PO). The client creates a PO instance document which conforms to the PO schema that Parts Depot has designed (and publicized in a WSDL document). The client submits PO.xml as the payload (i.e. entity body) of an HTTP POST message. The payload (HTTP entity body) should be in XML or JSON. IS 651: Distributed Systems 15

JSON Alternative serialization. {"menu": { "id": "file", "value": "File:", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }} <?xml version="1.0" encoding="utf-8"?> <menu id="file" value="file"> <popup> <menuitem value="new" onclick="createnewdoc()"/> <menuitem value="open" onclick="opendoc()"/> <menuitem value="close" onclick="closedoc()"/> </popup> </menu> IS 651: Distributed Systems 16

JSON Example The figure shows how JSON works in JavaScript. Program link The JSON is included directly in the program here, but could easily be the result of a REST query. It results in the simple text output to the browser: Sally Green 27 IS 651: Distributed Systems 17

Guardian API Most Web applications offer a REST API such as Twitter, Flickr, YAHOO, Facebook, The New York Times, NPR, and the Guardian Newspaper. The Guardian News Guardian Open Platform API docs http://content.guardianapis.com/search?q=syria&section=news&fro m-date=2013-09-01&api-key=xyz (JSON) http://content.guardianapis.com/search?q=syria&section=news&fro m-date=2013-09-01&format=xml&api-key=xyz (XML) You need to replace the xyz in the last two links with your api-key to make them work. IS 651: Distributed Systems 18

Cross-Domain Restriction One problem that comes up is that web browsers have a security limitation that requires any program running in the browser (using JavaScript with AJAX) can only return results from the same domain that the original web page came from. This is called the cross-domain restriction. Our Guardian example would therefore not work for a web page we created on gl since our web page is from umbc.edu and Guardian is on the guardian.com. Demo: https://userpages.umbc.edu/~jianwu/is651/programs/ch7/cross_do main_restriction.html IS 651: Distributed Systems 19

CURL and PHP One way around this is to use a server-side program to retrieve the XML or JSON from Guardian and then send it back to the user that requested the web page from gl. In order to do this, we will use PHP to issue the request using the Curl library. The Curl library offers a way to send a URL programmatically and handle the response. IS 651: Distributed Systems 20

CURL and PHP Example <?php $querystring='q=debates&section=news&from-date=2013-09-01&api-key=xyz'; $host ='https://content.guardianapis.com/search'; $request = $host.'?'.$querystring; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request); // set url curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return variable curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s curl_setopt($ch, CURLOPT_HTTPGET, true); // set GET method guardian.php Program link Source code link $xml = curl_exec($ch); curl_close($ch); header("content-type: text/xml"); //send http header echo "jsonprocessfn(".$json.");"; //wraps result in a function call?> IS 651: Distributed Systems 21

JSONP (JSON with Padding) The client-side program can use JSONP to call the PHP and process the result. JSONP sends JSON data without worrying about cross-domain issues. JSONP uses the <script> tag, instead of the XMLHttpRequest object. JSONP requires the data is wrapped by function name. Example: guardian.html. IS 651: Distributed Systems 22

guardian.html Example Part 1 <!DOCTYPE html> <html> <style> h3{background:red;} span{color:green;} </style> <body> <p id="output"></p> <script> function jsonprocessfn(data) { var h3 = document.createelement("h3"); h3.innerhtml = "User Tier = "+ data.response.usertier; document.getelementbyid("output").appendchild(h3); var arr = data.response.results; for (var i = 0, len = arr.length; i < len; i++) { newsprocessfn(arr[i]); } } IS 651: Distributed Systems 23

guardian.html Example Part 2 function newsprocessfn(news) { var li = document.createelement("li"); var span1 = document.createelement("span"); span1.innerhtml = "Date= "; var span2 = document.createelement("span"); span2.innerhtml = "Title= "; li.appendchild(span1); li.appendchild(document.createtextnode(news.webpublicationdate + " ")); li.appendchild(span2); li.appendchild(document.createtextnode(news.webtitle)); document.getelementbyid("output").appendchild(li); } </script> <script src="guardian.php"></script> </body> </html> IS 651: Distributed Systems 24

Ch7 Exercise IS 651: Distributed Systems 25

Discussion #5 A weather Web service maintains the current weather information which gives different results for the same place when you invoke it at different times Is this Web service a stateful or stateless service? Why? Note Do not write more than one page Write down the names you talked with (at least one) IS 651: Distributed Systems 26