WebServices (Revature)

¡Supera tus tareas y exámenes ahora con Quizwiz!

What are the six REST constraints?

1. Uniform Interface - A resource in a system should have only one logical URI, and then should provide a way to fetch related or additional data 2. Client-Server - The client application and the server application must be able to evolve separately without any dependency on each other 3. Stateless - The server will not store anything about latest HTTP request client made. 4. Cacheable - Caching shall be applied on resources when applicable and then these resources must declare themselves cacheable. 5. Layered System - Allows you to use a layered system architecture 6. Code on Demand (optional) - You are free to return executable code to support a part of your applications

What are some of the different categories of HTTP response codes that can be sent in an HTTP response message?

100's - Information 200's - Success 300's - Redirection 400's - Client Error 500's - Server Error

What are some of the properties that the WSDL contains?

<defintions> - The root tag of the WSDL that defines the name of the web service, declares multiple namespaces used throughout the document and contains all of the following service elements: <types> - Contains the data types to be used in the messages in the form of XML schemas. <message> - Maps parameters and return types of web service methods. <portType> - An abstract set of operations mapped to one or more end points, defining the collection of operations for a binding. <binding> - The concrete protocol and data formats for the operations and messages defined for a particular port type; includes the encoding type and transport protocol. <service> - A collection of related end-points encompassing the service definitions in the file; map the binding to the port and include any extensibility definitions. <operation> - An abstract description of an action supported by the service. (a child tag of portType) <port> - A single endpoint defined as a combination of a binding and a network address.

Another annotation used to deal with exceptions in REST?

@ExceptionHandler({ CustomException1.class, CustomException2.class })

What is an annotation that can be used to implement custom exception handling for ResponseEntity objects?

@ResponseStatus - Used above a custom exception class to indicate what HTTP Status code & message should be sent back with a ResponseEntity object if it is thrown.

What annotation should you replace @Controller with to implement RESTful web services using Spring?

@RestController should be used. It makes it so @ResponseBody is no longer needed over the controller methods. @RestController assumes you're marshalling objects already, so adding @ResponseBody is redundant

What is a SOAP message? What are some of the properties of a SOAP message?

A SOAP 1.1 message is an XML file used for communication in SOAP. Properties include: <soap: Envelope> is the root of the SOAP message; all other elements are contained by it. It contains two different children: the Header element and the Body element. <soap: Header> element is generally used for carrying infrastructure data such as security tokens, transaction IDs, routing information, and so on. Header element is optional. <soap: Body> element carries the application specific data or a fault message. Application-specific data is the information that we want to exchange with a web service. <soap: Fault> - An optional element that provides information about errors that occur while processing the message. This tag is a child of the body tag.

What is a safe Http method?

A safe http method is a http method that does not alter the database at all. Safe methods can be cached and prefetched without any repercussions to the resource.

What is a Web Service

A web service is any piece of software that makes itself available over the internet via a standard protocol or messaging system. Web services are actually an implementation of SOA. A web service must be self describing. It must be discoverable. It shouldn't be tied to any operating system.

What is an idempotent http method?

An Idempotent http method is a HTTP method that can be called many times without different outcomes. Example, imagine creating a varaible "int num=0;" num= 5; //this is an idempotent operation num++; //this is NOT an idempotent operation

What are the four types of WSDL bindings? Which one is not used?

Bindings can either be Remote Procedure Call style binding or a document style binding. RPC/Encoded, RPC/literal, Document/encoded (not used), and Document/literal.

What is the difference between the Contract-First and Contract-Last approaches to creating a SOAP service?

Contract-First - The implementation code is written from the WSDL Contract-Last - The WSDL is generated from the implementation code

What are some examples of key-value pairs that might be passed in an HTTP Request?

Examples include Accept, Cookie, User-Agent, and Referrer.

What are some examples of key-value pairs that might be passed in an HTTP Response?

Examples include Age, Location, or Server.

What http methods are idempotent? which are safe?

GET is idempotent and safe. POST is neither idempotent or safe. PUT is idempotent, not safe. DELETE is idempotent, not safe. OPTIONS is idempotent and safe. HEAD is idempotent and safe.

What are the HTTP methods supported by REST?

HTTP methods supported by REST are: •GET: It requests a resource at the request URL. It should not contain a request body as it will be discarded. •POST: It submits information to the service for processing; it should typically return the modified or new resource •PUT: At the request URL it update the resource •DELETE: At the request URL it removes the resource •OPTIONS: It indicates which methods are supported •HEAD: Same as GET but does not return the body. It returns meta information

What is status code 418?

IM_A_TEAPOT

How can we send a status code to inform the client of an issue?

In our controller method we put "new ResponseEntity<OurObject>(HttpStatus.IM_A_TEAPOT)" or whatever status code that is appropriate

What is Marshalling? What is Unmarshalling?

Marshalling - The process of transforming an object into its serializable version to be transmitted through the network Unmarshalling - The process of transforming the serialized version of an object Common marshalling tools: Jackson (used for JSON) Jax-B (used for XML)

What are the two types of platform-independent ways to describe an exception within a SOAP message?

Modeled - Maps an exception that is explicitly thrown from the business logic of some Java code. Unmodeled - Maps to a generic runtime exception that is generated at runtime when no buisiness logic fault is defined in the WSDL.

What are some other http methods?

PATCH, TRACE, CONNECT

What are REST and RESTful Web Services?

REST stands for Representational State Transfer. It is a web service that follows the SOA standard and uses HTTP as its main protocol RESTFUL is referred for web services written by applying REST architectural concept are called RESTful services, it focuses on system resources and how state of resource should be transported over HTTP protocol to a different clients written in different language. In RESTFUL web service http methods like GET, POST, PUT and DELETE can be used to perform CRUD operations.

What are some of the properties contained within an HTTP Response message?

Response Code - Contains a status code indicating whether or not an HTTP request has been successfully completed. HTTP Version Response Header - Metadata of the response held as key-value pairs. (e.g. content length, content type, etc) Response Body - The representation of the resource returned.

What object in Spring can be used to send an HTTP response?

ResponseEntity<BodyObject>(Object, HttpStatus.OK)

What are some of the characteristics of Service Oriented Architecture services?

Reusable - Services can be used by multiple processes depending on their granularity Autonomous - Each service provides a business function that is independent of other services Loosely Coupled - A change on one service will not require a change in another service Location-Independent - Services are accessed via URL, and therefore may move over time without disruption to consuming systems Standards Based - Services are built, consumed, and described using standards. (Standard protocols and data formats) Platform-Independent - Both the client and the server systems can be on any platform that supports the service transport and interface requirements

Are web-services SOA ?

SOA is thinking. It's an architectural concept and web service is one of the technical approach to complete it. Web services are the preferred standards to achieve SOA. • In SOA we need the services to be loosely coupled. A web service communicates using SOAP protocol which is XML based which is very loosely coupled. It answers the what part of the service. • SOA services should be able to describe themselves.WSDL describes how we can access the service. • SOA services are located in a directory.UDDI describes where we can get the web service. This nothing but implementation of SOA registry.

What are the types of web services?

SOAP (Simple Object Access Protocol): a description of an xml messaging protocol REST (Representational State Transfer): a description of an architecture for distributed hypermedia systems

What is SOAP?

SOAP stands for Simple Object Access Protocol. It is an XML-based protocol for exchanging information between computers.

What is SOA?

Service Oriented Architechure (SOA) is a technique for building business applications using loosely coupled services which act like black boxes and can be orchestrated to achieve a specific functionality by linking them together. As an example, think of the various traveling websites that tell you information about all available airlines, hotels, and car rentals. These sites will go to other companies' APIs to get information, these sites then compile that data into a digestable list for you. These sites treat other companies' API as services.

What are three major roles within the web service architecture that a service could fill?

Service Provider - Implements the service and makes it available on the internet Service Requester - Utilizes an existing web service by opening a network connection and sending a request Service Registry - A centralized directory of services where developers can publish new services or find existing ones

What is a service?

Software that makes itself available.

What library is used by Spring to automatically generate a SOAP service? Does the tool use, Contract-First, Contract-Last, or either approach?

The Apache CXF SOAP engine tool with JAX-WS is used to generate the SOAP service. The tool can generate a SOAP service using either approach.

What are some differences between SOAP and REST?

Tools - SOAP uses tools like Apache CXF that provide code and WSDL generation while REST is tool-less. Exception Handling - SOAP has exception handling built-in and configurable in the body of the message, while REST needs exception handling behavior to be provided through Spring. Contract - SOAP is contract-based (WSDL), while REST is not contract based (although you could do it through a WADL) Message - SOAP uses XML as its only media type, while REST allows JSON, XML and other media types. Atomicity - SOAP has transactions built-in, configurable in the header of the message, which can make messages become atomic, while REST does not perform atomic transactions, it just represents state. Protocol - SOAP can use almost any protocol, while REST can only use HTTP and HTTPS. Security - SOAP has security built-in, configurable in the message header, while REST can only be secured through HTTPS.

What are some of the properties contained within an HTTP Request message?

Verb - Indicates the executing HTTP method URI - Specifies the endpoint where a resource is located HTTP Version Request Header - Metadata of the request held as key-value pairs. (e.g. format supported by client, browser type, etc) Request Body - The message content or resource representation

What is WSDL?

WSDL 1.1(Web Service Description Language) is an XML markup language used to describe a WebService. WSDL is used to specify the exact message format, Internet protocol, and address that a client must use to communicate with a particular Webservice.


Conjuntos de estudio relacionados

chapter 12 social psychology quiz

View Set

HS&F: Chapter 7 - Muscular System

View Set

Chapter 1 Smart Book Managerial accounting

View Set

Medication Administration: Intramuscular Injection Elsevier Military

View Set

Ch. 13 - Monopolistic Competition

View Set