Presentation is loading. Please wait.

Presentation is loading. Please wait.

INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.

Similar presentations


Presentation on theme: "INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014."— Presentation transcript:

1 INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014

2 Intro to Web Services

3 Web site vs. Web service Web site Web service User Software/Code http gethtml Browser A lot of similarities, in fact, html is kinda like xml You could say that web sites are a subset of web services But easier explanation => for people vs. for code. For person to consume For software to consume rest/soapxml/json

4 How do Web Services communicate?

5 Communication Data Format Service Protocol Application Layer Protocol Network Transport Protocol JSON, XML REST/SOAP/WSDL HTTP, SMTP, FTP, SSH TCP, UDP And more! But we’ll focus on these ones Data link layer

6 Data Format XML (1996) – Extensible Markup Language – Language independent – More verbose than JSON – Open/Close tags

7 Data Format JSON (2001) – Javascript Object Notion – Originally from JS (how to create JS objects/properties) – Now => language independent – Usually less bytes than XML – http://www.compileonline.com/try_javascript_online.php http://www.compileonline.com/try_javascript_online.php – XML was probably too much of a hassle to parse in JS (and type-less) Try this!

8 Data Format Takeaway – Both formats are language independent – Usually have native parsers/serializers for both – Size difference may be ~30% but after zipping may be negligible – So feel free to pick your favorite but generally: Web/JS/REST/type-less = JSON SOAP/non-web/Microsoft stack/strong type = XML Will show you later…

9 Service Protocol REST – Representational State Transfer – Invented along with HTTP – Goals: performance, scalability, simplicity – Uses HTTP request methods GET/POST/PUT/DELETE => simple! – Constraints: Client-server = separate responsibility, server not concerned with UI (scalable), client not concerned with state. Stateless = client doesn’t store data (portable) Others (see Wikipedia)

10 Service Protocol SOAP – Simple Object Access Protocol – Designed by Microsoft (1998) – Goals: Exchanging structured information, successor of XML-RPC – RPC = remote procedural call (you’ll see that it looks more like calling a function) – Not client-server (you can call a function in my machine and I can call a function in yours) – distributed – Not stateless (client stores the data to use it!) – Originally not over HTTP but now HTTP is so much more popular, it’s commonly used over HTTP.

11 Recap Active Server Method File (ASMX) – Microsoft’s implementation of web services – It’s actually a very neat/clean implementation! – Recap Add [WebMethod] to specify that it’s a web service method Add parameters into function Return value can be objects!!

12 Recap Make a web service with the following & upload to your Azure account Remember!!! Before closing Try this!

13 REST Call your web service on Azure via REST! http:// /WebService.asmx/OddNumbers?n=23 – Just like HTTP/web! Pass parameter and this does a http get. – Performance = fast! – Simplicity = just pass param “n=23” – Scalable/Portable = do this on any machine! Try this!

14 SOAP Call your web service on Azure via SOAP! – This is magic. – Create new project (Windows, Console proj, C#) – Right click service (add service reference) http:// /WebService.asmx – Now you can call all those functions! RPC! Wait… there’s an error… Search on Google!! Try this!

15 SOAP Magic! How did the client code get generated? WSDL = http://info344.azurewebsites.net/WebService. asmx?WSDL http://info344.azurewebsites.net/WebService. asmx?WSDL Remember: – Goals: Exchanging structured information, successor of XML-RPC – RPC = remote procedural call (you’ll see that it looks more like calling a function)

16 REST vs SOAP Long religious fight online My opinion: – Web/JS/REST/type-less = JSON More scalable, if you’re writing an API for anyone in the world to use (probably better to do REST/JSON) – SOAP/non-web/Microsoft stack/strong type = XML More convenient, if you’re writing an API for only Microsoft to use that interacts with a lot of client software => SOAP/XML = great! Others = JSON-RPC/etc => too much work, not natural. Fortunately, ASMX does both! Automatically!!

17 Application Layer Examples = HTTP, SMTP, FTP, SSH Status codes: http://www.w3.org/Protocols/ rfc2616/rfc2616-sec10.html

18 HTTP GET vs. POST http://www.w3schools.com/tags/ref_httpmethods.asp Also easier to test

19 Network Transport Protocol TCP – Transmission Control Protocol – Reliable transmission = resend lost packets – Either receiver asks for retransmission or sender auto re- sends if not received ack packet – Sliding window protocol = cause throughput to drop – FTP/SMTP/SSH/HTTP = all TCP!

20 Network Transport Protocol UDP – User Datagram Protocol – Unreliable transmission = dropped packets are ignored – Time-sensitive applications – Voice (VoIP), Video (Netflix streaming) => all UDP. – MMO Games (player position) = UDP – But In-app purchase/transactions = TCP! – Use UDP when lost packets = no longer needed.

21 Apple Game Center Real world example! https://developer.apple.com/library/ios/docum entation/NetworkingInternet/Conceptual/Game Kit_Guide/Matchmaking/Matchmaking.html Section: Exchanging Data Between Match Participants

22 Group Discussion! Groups of 3 Think of an example for TCP Think of an example for UDP (excluding the ones I gave)

23 Recap: Communication Data Format Service Protocol Application Layer Protocol Network Transport Protocol JSON, XML How data is formatted REST/SOAP/WSDL How data is communicated HTTP, SMTP, FTP, SSH How applications communicate TCP, UDP How packets are communicated

24 Recap: Key topics XML vs. JSON REST vs. SOAP ASMX does both! HTTP message TCP vs. UDP

25 PA2 hints index.html – Text input – AJAX calls your web service – Updates query suggestion/hints getQuerySuggestions.asmx – Return JSON suggestions (only need 10) – Case insensitive

26 PA2 hints Preprocess your data!!! – Remove pages with non-english char – Remove pages with digits Goal = Great User Experience

27 Questions?


Download ppt "INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014."

Similar presentations


Ads by Google