Lesson 4: Web Services Flashcards
What is the 3-tier architecture?
Presentation - Business - Persistence
Client - web server - database
What is a web service?
A web service is a software system designed to support interoperable machine-to-machine interaction over a network.
— extra details —
It has an interface described in a machine-processable format (WSDL). Other systems interact with the web service in a manner prescribed by its description using SOAP or RESTful messages, typically conveyed using HTTP with an XML or JSON serialization in conjunction with other web-related standards.
Give some benefits of a web service.
- loose coupled design
- ease of integration
- service reuse
What benefits do we gain with a loose coupled design in a web service?
- Each service exists independently of the other services that make up the application
- Individual pieces of the application can be modified without impacting unrelated areas.
What are some characteristics of the ‘ease of integration’ benefit when using a web service?
- Data is isolated between applications.
- Web services act as glue between these and enable easier communications within an across organizations
Describe the ‘service reuse’ benefit of web services.
- Take 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
What is REST and what is it short for?
REpresentational State Transfer.
Rest in an architectural style.
What is the difference between URI, URL and URN
URI is a Uniform Resource Identifier and can be a URL, URN or both.
URL is a Uniform Resource Locator and is the location where you can find the resource
URN is a Uniform Resource Name and defines an item identity
How are REST resources described?
- Describe resources, not applications
- Make it short
- Hackable up the tree
- Meaningful
- Predictable, human-readable
- Nouns, not verbs
- Permanent
- Query arguments are only for parameters
- Avoid extensions
What is a RESTful API? What does it have?
= web service API that adheres to the REST style
- it has a base URI
- it has an internet media type for the data
- It uses standard HTTP methods
- It uses hypertext links to reference states
- It uses hypertext links to reference related resources
Describe JSON in keywords.
- Open Standard
- Human-Readable text
- Alternative to XML
- Language-independent
- Support in many programming languages
- has the ability to define a schema for validation
What are the 6 REST architectural constraints?
1) Interface uniformity between components
2) Client-server model (separation of concerns)
3) Stateless client-server communication
4) caching
5) Layering
6) Code on demand (optional)
What is the “Interface uniformity between components” constraint in REST?
Components need to speak the same language and know what to expect in order to understand each other
What is the “client-server model (separation of concerns)” constraint in REST?
Client and server are fully decoupled and can be developed independently
What is the “stateless client-server communication” constraint in REST?
Each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored session state on the server.
What is the “caching” constraint in REST?
Clients can cache responses to requests, improving scalability and performance. The fact that responses are not cacheable should be implicitly or explicitly defined.
What is the “layering” constraint in REST?
A client cannot tell if it is directly connected to a server or to some intermediary. This allows for load-balancing, fail-over and data transformation.
What is the “code-on-demand” constraint in REST?
Client functionality can be dynamically extended through the transfer of executable code.
Compare REST and RPC.
RPC:
- many operations, few URI
- address software components
- procedure name and parameters are transferred
Compare REST and RPC.
RPC:
- many operations, few URI
- address software components
- procedure name and parameters are transferred
REST:
- Few operations, many URI
- Address resources
- Resource representations are transferred
What are advantages of REST?
- Uniform interface is immutable
- Conceptually simpler
- Lower protocol overhead (for stateless services)
- Can improve server scalability
- Inherent support for request caching
- Less reliant on tool support and heavyweight libraries
- No need for additional messaging layer
- Complexity at the endpoints instead of the transport layer level
What are some disadvantages of REST?
- Service model not always easily mappable to REST verbs, uniform interface tailored to large-grain hypermedia data transfer
- Looser in terms of defining the exposed service API and its semantics
- Does not cover all WS standards (security, transactions, addressing, coordination, …)
What is SOAP short for?
Simple Object Access Protocol
How do you add credentials to a SOAP message?
1) Add it in the SOAP body - credentials need to be encoded in every parameter
2) Use the optional SOAP header.
–> use the mustUnderstand attribute so that the receiving body is able to interpret this header
What are some reasons to use SOAP?
(to get clean, LOL)
- SOAP exposes application logic as services
- Need more formal ways of invoking services
- Need stateful information
- If you need one of the WS- extensions
What are some requirements for SOAP Web Services?
- Text protocol: needs to be readable on the wire
- Object oriented: needs to describe components of a service
SOAP is only linked with XML. What is XML?
- Stateless and one-way
- Significant overhead
- Can be used to develop more complex “conversations”
- One level above XML RPC
Adds processing and extensibility models to the story
Style for exchanging arbitrary data - The de facto standard in human readable text back then
What is the Web Services Description Language (WSDL)?
- XML grammar to specify collection of “access end points”
- Designed to automate application-to-application interaction
- Defines the communication protocol to be used at runtime
Message format
Methods to be invoked
Parameter lists, return types - WSDL descriptions can be automatically generated for existing code
- Stub classes can be generated from WSDL descriptions