Download presentation
Presentation is loading. Please wait.
1
Web Services
2
Definition Many definitions
“…technologies that allow for making connections” “a software system designed to support interoperable m2m interaction over the network” “..a service offered by an electronic device to another electronic device, communicating with each other via WWW” Web services may use SOAP protocol over http (or ftp, smtp, ..) for their communication http is utilized for m2m communication and for transferring information in XML or JSON Has an interface described in WSDL or REST (WADL, RAML, OAS/OpenApi) machine-readable format 4/7/2019 Web Services
3
Service A function that is well defined, self contained, does not depend on the context or state of other services, can be accessed remotely and updated independently Services carry out a function, such as producing data, validating a customer, or retrieve a credit card statement Web services: connection technology of SOA Most APIs in cloud computing are implemented as SOAP or RESTful Web services 4/7/2019 Web Services
4
Web Services vs Websites
A Web site is typically intended for human consumption (human-to-computer interaction), whereas web services are typically intended for computer-to-computer interaction A Web service may have GUI or API, a Web site may implement Web Services in the background Paypal has both GUI and implements web services (e.g. for payments, use management etc.) 4/7/2019
5
A Service example Basic service oriented architecture: The service provider returns a response message to the service consumer (client) Simple data, message passing The request and subsequent response connections are defined in some way that is understandable to both the service consumer and service provider 4/7/2019 Web Services
6
Service Oriented Architecture (SOA)
Architecture based on services: All functional components of a system are viewed as services that communicate with each other through well defined interfaces by message passing One of the keys to SOA architecture is that interactions occur with loosely coupled services that operate independently SOA architecture allows for service reuse, making it unnecessary to start from scratch when developing an application or when upgrades and other modifications are needed This is a benefit to businesses that seek ways to save time and money 4/7/2019 Web Services
7
SOA Patterns A SOA building block can play one of the following roles
Service broker: Also known as service registry; Its main functionality is to make the information regarding the web services available to any potential requester (public or private brokers) Service consumer: It locates entries in the broker registry (using find operations), binds to the service provider, invokes its web service Service provider: It creates a web service and provides its information to the service registry, provides responses to consumers 4/7/2019 Web Services
8
Service Registry (Broker)
UDDI is a registry for the discovery of services described by WSDL WSDL is an XML-based description language for services SOAP is the protocol for exchanging information in the communication of Web services over http UDDI, WSDL, SOAP, XML are platform and language independent Procedure: A service provider describes its services using WSDL Publishes its service in the registry (UDDI) A service consumer issues queries to the registry to locate a service The registry returns WSDL description The consumer knows how to use and communicate with the service The consumer uses SOAP to send a request to the service provider The provider returns a response to the service consumer 4/7/2019 Web Services
9
Web Services basic architecture
4/7/2019 Web Services
10
SOA Principles 1/2 Standardized service contract: services adhere to the same design principles, usually expressed as WSDL, REST, … documents, XML schema Service reference autonomy (loose coupling): services are independent and control the functionality they provide on their own Service location transparency (loose coupling): services can be called from anywhere Service abstraction: services as black boxes (inner logic is hidden) Service granularity: services have adequate size and scope (provide functionality relevant to request) 4/7/2019 Web Services
11
SOA Principles 2/2 Service composability: can be used to compose other services Service discovery: come with communicative metadata by which they can be discovered and interpreted Service re-usability: promote re-use of code Service encapsulation: may get encapsulated or become part of a SOA Service statelessness: services are stateless and simply return the requested value or an exception, each request is unrelated to any previous request 4/7/2019 Web Services
12
SOA and Cloud Computing
Complementary technologies While SOA exhibited varying success in the past, the movement to cloud computing provides some renewed value to SOA Clouds are typically API or service-driven, and therefore service-oriented As cloud computing becomes more popular, more enterprises will use SOA, which includes the use of service directories, orchestration, and other technologies related to SOA FIWARE, ORACLE provide collections of RESTful services (IDM, CB) 4/7/2019 Web Services
13
WSDL XML format that describe services as a set of service end-points for data/message exchange Service End-Point: Describes a service and how it is bound to specific IP addresses / interface declares all abstract methods that are exposed to the client 4/7/2019 Web Services
14
WSDL Documents (XML) Specifies location and methods of service using
<types> XML data types used by the service <message> data elements for each operation <portType> operations that can be performed with the messages involved <binding> defines protocol, operations and data format for each port type Port: end-point as combination of binding + IP Service: a collection of end-points 4/7/2019 Web Services
15
Structure of WSDL document
4/7/2019 Web Services
16
WSDL Example 1/2 4/7/2019 Web Services
17
WSDL Name Spaces xmlns: set default name spaces for the entity being described targetNameSpace: the name space for your web service (points to the WSDL of the service) tns: same URI as targetNameSpace 4/7/2019 Web Services
18
WSDL Example 2/2 4/7/2019 Web Services
19
Example Explanation 1/2 Definitions: “HelloService”
Type: Using built-in data types and data types defined in XML schema Message: “SayHelloRequest”: “firstName” parameter “SayHelloResponse”: “greeting” return value Port Type: “sayHello” operation that consists of a request and a response service Binding: Direction to use the SOAP http protocol Service: operations available at 4/7/2019
20
EncodingStyle Attribute
Can be used to indicate the encoding style used for the header entries, either simple or compound data types Compound types: structure array, string, enumeration Indicate the serialization rules used in a SOAP message The attribute value is an ordered list of one or more URIs identifying the serialization rule or rules that can be used to de/serialize the SOAP message Examples of values are: " " 4/7/2019 Services
21
XML Serialization Serialization is the process of converting an object into a form that can be transported Serialize an object and transport it over the internet using http between a client and a serve Deserialization reconstructs the object from the stream XML serialization serializes only the public fields and property values of an object into an XML stream XML serialization does not include type information Eg., a Book object that exists in the Library namespace, there is no guarantee that it is deserialized into an object of the same type. 4/7/2019 Web Services
22
SOAP Simple Object Access Protocol (SOAP): a protocol based on XML for exchanging information among computers Specifies how to communicate / pass messages using http Initially used for remote procedure calls Similar to CORBA, DCOM, Java RMI but SOAP messages are written in XML (language / platform independent) Communication protocol for internet Extends http for XML messaging specifying what information is sent Provides data transport for Web services Can also used for document exchange Language / platform independent Can be used with Java, PHP, … 4/7/2019 Web Services
23
SOAP Message XML document with elements
Envelope: defines start/end of message, identifies the XML document as SOAP message Header: attributes for processing the message Body: message that contains call/response information Fault: information about errors that occur while processing the message All elements are declared in the default namespace for the SOAP envelope Default name space for SOAP data 4/7/2019 Web Services
24
SOAP Message Structure
Provides an “envelope” for sending Web service messages over internet (typically http) Envelope parts: Optional header Body (message) 4/7/2019 Web Services
25
SOAP Message Structure
XML namespaces disambiguate SOAP identifiers from application specific identifiers. 4/7/2019 Web Services
26
SOAP Header Element Application specific information
mustUnderstand Attribute: indicates whether the header is mandatory for the recipient processsoap:mustUnderstand="0|1” Actor Attribute: address of recipient of the Header soap:actor=' EncodingStyle Attribute: define the data types and serialization rules soap:encodingStyle=" 4/7/2019 Web Services
27
SOAP Fault Element Indicates error messages (optional) and has sub-elements <faultcode> identifies the fault VersionMissmatch: invalid namespace found MustUnderstand: an element with “1” attributed was not understood Client: message incorrectly formed or contained fault information Server: problem with server so the message could not proceed <faultstring> human readable information <faultactor> who caused the fault <detail> fault specific information 4/7/2019 Web Services
28
SOAP Request for Price of Apples
m:GetPrice, m:Price are application specific 4/7/2019 Web Services
29
SOAP Response 4/7/2019 Web Services
30
SOAP example: GetQuotation request
4/7/2019 Web Services
31
SOAP example: Quotation response
4/7/2019 Web Services
32
SOAP example: GetStockPrice request
4/7/2019 Web Services
33
SOAP example: GetStockPrice response
4/7/2019 Web Services
34
Representation State Transfer (REST)
REST is a lightweight alternative to SOAP Like Web services Platform independent Runs on http Language independent Can be used with most programming environments like C#, Java, JavaScript, Perl, PHP, Python … 4/7/2019 Web Services
35
Restful Web Services In REST everything is a resource which is identified by its URI A URI is of following format <protocol>://<service-name>/<ResourceType>/<ResourceID> A REST server provides access to resources and REST client accesses and presents resources A RESTful web service usually defines a URI, provides resource representation such as JSON and a set of http methods 4/7/2019 Web Services
36
How Simple is REST ? SOAP to query a phone book for the details of a given user REST (no “body”, its just a URL sent to server using an http POST request) Can handle requests with multiple parameters 4/7/2019 Web Services
37
Definition of REST 1/2 Client-Server: Client and server application can evolve separately without any dependency on each other (also SOA) Stateless: The service doesn't store information from previous requests (also SOA) A request from a client contains the necessary information to interact with the service Cacheable: Response messages are labeled as cacheable or non-cacheable If cacheable, a client is given the right to cache and reuse response data for later, equivalent requests Performance improvement: reduces the number of requests to server as clients may instantly reuse existing information without the need to send a new request 4/7/2019 Web Services
38
Definition of REST 2/2 Uniform Interface (HATEOAS): A client needs min or no prior information on how to interact with server Server's responses include hyperlinks that a client can use to discover all the available actions and resources it needs Simplifies the service architecture Every component of the service can evolve independently Layered System: Architecture is composed of layers Each component cannot “see” beyond the immediate layer with which it is interacting 4/7/2019 Web Services
39
HATEOAS A client sends a message in the form of a HTTP request ..
.. server responds in form of HTTP response 4/7/2019 Web Services
40
REST vs SOAP Unlike SOAP services, REST is not bound to XML
CSV: comma separated values JSON: JavaScript Object Notation (key value pairs) Html is acceptable, human readable format, not machine processable SOAP advantages include type safety of XML requests (although REST can still use XML) REST advantage is ease of implementation, lightweight approach, better performance REST: The service producer and service consumer need to have a common understanding of the context as well as the content being passed along as there is no standard set of rules to describe the REST Web services interface SOAP: WSDL to define messages, operations, bindings and URI of service which can be more useful for publishing services to the world 4/7/2019 Web Services
41
Representation of Resources
REST treats every content as a resource Text files, html pages, images, binary data .. REST uses XML And JSON 4/7/2019 Web Services
42
REST - Statelessness A RESTful Web service should not keep a client state on server Will always return user whose id is 1 Advantages of Statelessness Web services can treat each method request independently Web services need not to maintain client's previous interactions It simplifies application design 4/7/2019 Web Services
43
HTTP Methods Following well known HTTP methods are commonly used in REST based architecture GET - Provides a read only access to a resource PUT - Used to create a new resource DELETE - Used to remove a resource. POST - Used to update a existing resource or create a new resource. OPTIONS - Used to get the supported operations on a resource 4/7/2019 Web Services
44
More REST Examples / http Methods
A Web service for “user management” with functionalities Define REST service in Java using Jersey REST Web Services framework for developing RESTful Web services in Java Tomcat Web server for Java Servlet, http Web server in which Java code will run PHP, Node.js, Perl, Python … can used as well to define RESTful services 4/7/2019 Web Services
45
HTTP Method, URI and Operation
4/7/2019 Web Services
46
HTTP Request Verb: HTTP methods (GET, POST, DELETE, PUT)
HTTP request’s major parts: Verb: HTTP methods (GET, POST, DELETE, PUT) URI: to identify the resource on server HTTP Version: for example HTTP v1.1 . Request Header: Contains metadata for the HTTP Request message as key-value pairs. For example, client ( or browser) type, format supported by client, format of message body, cache settings etc. Request Body: Message content or Resource representation. 4/7/2019 Web Services
47
HTTP Response HTTP Response parts:
Status/Response Code: 404 means resource not found and 200 means response is ok. HTTP Version: for example HTTP v1.1 . Response Header: Contains metadata for the HTTP Response message as key-value pairs. For example, content length, content type, response date, server type etc. Response Body: Response message content or Resource representation. 4/7/2019 Web Services
48
References http://W3schools.com
Web services, Service Oriented Architectures and Cloud Computing, Douglas K. Bary, 4/7/2019 Web Services
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.