Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web.

Similar presentations


Presentation on theme: "CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web."— Presentation transcript:

1 CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web Services

2 Agenda/Contents for Today’s Lecture  Introduction to Web Services  Understanding Services  SOAP Services  REST Services  Examples

3 What is a web service ? A Web Service is a standards-based, software entity, that accepts specially formatted requests from other software entities on remote machines via vendor and transport neutral communication protocols, producing application specific responses

4 Benefits of Web Service Loose Coupled Design Each service exists independently of the other services that make up the application. Individual pieces of the application to be modified without impacting unrelated areas. Ease of Integration Data is isolated between applications. Web Services act as glue between these and enable easier communications within and across organizations. Service Reuse Takes code reuse a step further. A specific function within the domain is only ever coded once and used over and over again by consuming applications.

5 Web Services Architecture The simplest Web service system has two participants: A service producer (provider) A service consumer (requester). The provider presents the interface and implementation of the service, and the requester uses the Web service

6 Web Services Architecture (SOA)  A more sophisticated system:  A registry, acts as a  broker for Web services.  A provider, can publish  services to the registry  A consumer, can then  discover services in the  registry

7 SOAP (Simple Object Access Protocol) Web Service  SOAP is a simple XML-based protocol to let applications exchange information over HTTP.  SOAP is a industry accepted W3C specification that uses standards based technologies (XML for data description and HTTP for transport) to encode and transmit application data.

8 SOAP Message Structure  The root element of a SOAP message  is the Envelope element.  It contains an optional Header  element and the required Body  Elements called Faults can be used  to describe exceptional situations.  It can contain optional Attachments in  MIME encoding for exchanging binary  data.

9 SOAP Example   <soap:Envelope  soap:encodingStyle="http://soap.org/soap/encoding/"  xmlns:xsd="http://www.w3.org/2001/XMLSchema"  xmlns:soap="http://xmlsoap.org/soap/envelope/"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst"> 

10 SOAP Message Transmission  The SOAP Message Transmission involves three main roles:  The SOAP Sender creates and sends a SOAP Message to an  ultimate SOAP Receiver.  One or more optional SOAP Intermediaries can be  positioned to intercept messages between the the sender and  the receiver. They can perform filtering, logging, catching etc.  The SOAP sender’s intended destination is called the  Ultimate SOAP Receiver.

11 SOAP Request Example POST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn IBM

12 SOAP Response HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn 34.5

13 SOAP Demo ASP.NET Web Service DEMO project step by step creation and Working Example in Class

14 Introduction to REST Representational state transfer (REST) is a style of software architecture for distributed systems such as the World Wide Web

15 REST Web Services 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. If measured by the number of Web services that use it, REST has emerged in the last few years alone as a predominant Web service design model. In fact, REST has had such a large impact on the Web that it has mostly displaced SOAP- and WSDL-based interface design because it's a considerably simpler style to use.

16 Fundamental Characteristics of REST  Client Server  Separation of Concerns is a principle where the user interface is separated from data storage. This leads to the portability of the user interface across multiple platforms and improves scalability by simplifying server components.  Stateless  Each request to the server should contain all the information required to understand and complete the request.  Cacheable  The data within a response to a request should be cacheable/ non- cacheable to be used by client at another point of time. This might improve the performance and reduce network traffic.  Layered System  Intermediary servers like Proxy servers or Cache servers can be used to improve performance or introduce security.

17 Fundamental Characteristics of REST  Uniform Interface  A uniform interface (like HTTP GET, POST, DELETE, PUT) is to be used to access a resource.  A RESTful Web Service is a collection of the following:  URI  Uniform Resource Identifier - This is a unique way of identifying resources on the network. Every resource on the web is given a unique identifier - a universal identifier (example, URL). All web browsers, servers, applications understand this identifier, which makes it easy to connect and exchange information between one another without any issues.  MIME Type  Can be XML, HTML, and JSON.  HTTP Methods  HTTP forms a standard way to communicate with resources on the web. GET, PUT, DELETE, POST are some of the common methods to access a resource.

18 SOAP Versus REST Request Using Web Services and SOAP, the request would look something like this: <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> 12345 (The details are not important; this is just an example.) The entire shebang now has to be sent (using an HTTP POST request) to the server. The result is probably an XML file, but it will be embedded, as the "payload", inside a SOAP response envelope. And with REST? The query will probably look like this: http://www.acme.com/phonebook/UserDetails/12345

19 REST Response ACME Boomerang Used by Coyote in Zoom at the Top, 1962 17.32 http://www.acme.com/parts/3322 ACME Dehydrated Boulders Used by Coyote in Scrambled Aches, 1957 19.95 http://www.acme.com/parts/783

20 Fundamental Characteristics of REST  GET  Helps to request a specific representation of the resource.  PUT  Updates a resource with a specific representation.  DELETE  Deletes a specified resource.  POST  Creates a new resource

21 REST Web Service Implementation DEMO in class

22 Reference Material http://www.w3schools.com/soap/ http://msdn.microsoft.com/en-us/library/ms972326.aspx http://www.codeproject.com/Articles/337535/Understandin g-the-Basics-of-Web-Service-in-ASP-NET http://en.wikipedia.org/wiki/Representational_state_transfer http://www.ibm.com/developerworks/webservices/library/w s-restful/ http://rest.elkstein.org/2008/02/what-is-rest.html http://msdn.microsoft.com/en-us/library/dd203052.aspx


Download ppt "CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web."

Similar presentations


Ads by Google