WebServices (Revature), Revature: Web Services, Servlets and DevOps, Web Services, Web Services

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Children of the fault tag

* <faultCode> * <faultString> * <faultActor> * <detail>

What is the difference between lazy and eager init()?

-Lazy init() is called upon the first request to a servlet. -Eager init() is called as soon as the application starts.

Why do we use Web Services?

1. Makes applications platform and tech independent 2. Low cost of communication delivery through REST and SOAP 3. Allows for code reusability 4. Allows for Distributed Business Applications

How do you create a SOAP Web Service?

1. Requires creation and exposure of the WSDL which can be generated w/ JAX-WS (API) and Apache CXF (engine, contract last) or wsdl2java mavengoal (contract first) 2. @WebService and @WebMethod in an interface → you model the concrete - Concrete has @WebService(serviceName="/location" 3. Set up your web container and Spring MVC config - Beans.xml needs specific configuration for Apache CXF using the jaxws: schema -- Must specify the service location 4. Run the server and Apache CXF perform Contract_Last: generate the WSDL from the code and present it (expose) it in a specific location

How do you handle exceptions in REST?

1. ResponseEntity and Status Codes 2. @ResponseStatus on custom classes 3. @ExceptionHandler on (customException.class) - Can also be done globally in a separate class that uses @ControllerAdvice

How do you create a RESTful Web Service (How do you implement it in Spring)?

1. Set up the web container and Spring MVC config 2. Write your controller logic within @Controller or @RestController 3. Write all your mappings with @RequestMapping or @GetMapping, @PostMapping, etc to register the different endpoint 4. Run your server so the Spring container lifecycle starts. Your server will now listen for requests

What's the structure of the HTTP Response.

1. Status Code 2. Version 3. Header 4. Body

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's the structure of the HTTP Request.

1. Verb 2. URI 3. HTTP Version 4. Header (METADATA of the request in the format of key-value pairs) 5. Body

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 is the Servlet Hierarchy?

3 interfaces: Servlet, servlet config, serializable these interfaces are implemented on the Generic Servlet. HttpServlet inherits Generic Servlet. Then your own Servlet ("MyServlet") will inherit from that.

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.

SOAP message structure.

<envelope> <header> <body> <fault>

WSDL Tags in detail.

<types> - Defines the XML Schema (xsd) data types used by the web service <message> - Maps parameters and return types of web service methods. <portType> - Describes the operations that can be performed and the messages involved <binding> - Encoding type and transport protocol. SOAP can use almost any application protocol (layer 7) <service> - URL locator of web service.

Annotations in REST.

@Controller: Designates a controller class @RestController: Same as controller but can remove @ResponseBody; convert value to Http @RequestBody: convert to parameter object @Path: specifies URIs @Produces: type of media file produced by a class or API @Consumes: type of media file received by a class or API

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 servlet?

A Java object to handle incoming requests not solely HTTP. Servlets can generate responses and process requests using Java Logic

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 web server?

A computer that is designed to handle HTTP requests

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 Tomcat?

A server designed by Apache that will host or house our servlet container

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.

REST (Representational State Transfer)

A web service that follows the Service Oriented Architecture standard and uses HTTP as its main protocol. - It supports JSON and XML for data transmission (representational). - Everything is considered a resource (state). - Objects are transmitted with HTTP methods (transfer). - Endpoints are classified by URIs, which provide the resources.

What is Cloud Computing?

Abstracting ownership of physical hardware and computers to the web. This includes removing the physical infrastructure required to create a software project/service.

What is the header of the message used for?

Added security features (optional), allows for transaction configurations as well

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 is the DevOps pipeline?

An automated set of processes that use tools to compile, test, and deploy code for new software features.

What are endpoints in SOAP?

An entity, processor, or resource that can be referenced and to which web services messages can be addressed

What is ServletConfig?

An object specific to a single servlet that holds information on that servlet

What is a ServletContext?

An object that holds information about the entire servlet container and thus all servlets

What is HttpSession?

An object that will keep track of the session server side.

What are Web Services?

Any piece of software that makes itself available over the internet via a standard protocol (HTTP) or messaging system (ex: JSON or XML)

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.

Contract First - Contract Last, how to implement it?

CF: Obtain WSDL first, code last. Implement it with a special maven goal wsdl2java and then run the client CL: Obtain code first, WSDL last. Implemented via JAX-WS within Apache CXF (dependencies for both)

What is Horizontal Scalability?

Commissioning more machines to handle current needs.

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 the advantages of cloud computing?

Elasticity, Scalability, and Cost. You pay for what you use and you don't have to buy infrastructure.

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's the difference between @RestController and @Controller?

For @RestController, you don't have to specify @ResponseBody

What is the difference between a forward and a redirect?

Forward occurs on the server side and sends a request from one servlet to another. Forward uses a RequestDispatcher. Redirect is when a resource tells the client to send another request to a different location. Uses response.sendRedirect("location").

GET vs POST.

GET can be bookmarked, cached, and data is visible in the URL; retrieves data, has a body that isn't expected POST sends data and has body that data flows through

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.

HTTP methods.

GET: read-only data POST: submits data to the resource PUT: updates data in the resource/representation of URI DELETE: deletes the resource HEAD: GET method that returns only headers OPTIONS: returns methods supported by the server

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 protocols does SOAP allow?

HTTP, HTTPS, FTP, SMTP

What is status code 418?

IM_A_TEAPOT

What are the three services of cloud computing?

IaaS - Infrastructure as a Service PaaS - Platform as a Service SaaS - Software as a Service

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 IaaS?

Infrastructure as a Service ----------------------------- Using the cloud to abstract hardware. EC2 or virtual machines buy processing time

What is a servlet container?

It contains one to many Servlets and is primarily responsible for mapping the servlets to different addresses. They configure our servlets.

What is the web.xml file? (Deployment Descriptor)

It gives the servlet container mapping and configuration details and decides what requests are handled by the servlet

What is Git?

It is a distributed version-control system for tracking changes in source code during software development.

What is the fault of the message used for? Where is it in the structure?

It resides in the envelope and is used to provide error handling

What media types does REST support?

JSON, XML, Excel, PDF, and more

What is Jenkins?

Jenkins is a continuous integration application that allows you to build and test software projects continuously. Jenkins can generate test reports, schedule tests, deploy directly to production or test environments, and allow for easy notification.

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.

SOAP exception handling.

Modeled: Maps to an exception that is implicit Unmodeled: Maps to a generic runtime exception

Idempotency.

No matter how many times the data is sent, it will always produce the same result. All methods except POST are idempotent.

What are some other http methods?

PATCH, TRACE, CONNECT

What is PaaS?

Platform as a Service ----------------------------- It is the concept of providing a computing platform and software solution stack as a virtual or cloud-based service. It is a foundation for you to develop on. -RDS

What is the difference between portType and binding?

Port Type describes the operations that can be performed and the messages involved Binding gives the concrete details of the portType with a given protocol

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.

SOAP Binding styles.

RPC (Remote Procedure Call) encoded/literal Document encoded (rarely used)/literal

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 are some of the tags in the web.xml file?

Servlet, url-pattern, servlet-name, servlet-class, context-param, init-param (Know a basic description of them)

What is SaaS?

Software as a Service ----------------------------- Software as a Service provides on-demand online access to specific software applications or suites without the need for local installation. -Google Drive or Netflix

What is a service?

Software that makes itself available.

Differences between SOAP and REST.

TECMAPS Tools: - SOAP: Apache CXF along with others - REST: is tool-less Exception Handling: - SOAP: Built in through fault tag - Rest: Has to be defined through Spring Contract: - SOAP: Contract based (WSDL) - Rest: Not contract-based (not meant for contracts) Message: - SOAP: Uses an envelope that only allows XML - Rest: Uses the HTTP package itself, allows JSON, XML, and more Atomicity: - SOAP: Transactions built in, configurable in the header, makes it atomic - Rest: Doesn't perform atomic transactions, only represents the state of the resource Protocol: - SOAP: HTTP, HTTPS, FTP, SMTP - REST: HTTP and HTTPS only Security: - SOAP: has security built in, configurable in header, allows for double encryption - REST: only has HTTPS

What is Vertical Scalability?

Taking one computer and increasing its cpu, memory, or storage. Not increasing the amount of machines.

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 is the 2nd stage of the Servlet Life-cycle?

The Servlet Class is instantiated

What is the 1st stage of the Servlet Life-cycle?

The Servlet Class is loaded into the Servlet Container

What is the 5th stage of the Servlet Life-cycle?

The Servlet destroy() method is called only once and that is when the application is shut down.

What is the 4th stage of the Servlet Life-cycle?

The Servlet service() method is called upon each request to the servlet. The service() method delegates the request to doGet(), doPost(), doDelete(), etc.....

What is the 3rd stage of the Servlet Life-cycle?

The Servlet's init() method of the servlet class is run only once and sets up initial configuration/parameters.

What is Elasticity?

The commission and decommission resources (computers/databases) as necessary. This happens dynamically. It will meet the demand that is appropriate.

What does stateless mean?

The server does not retain session data once the session ends.

What is DevOps?

The word is a combination of Development and Operations. It is a mindset wherein programs are developed, tested, and operated on at the same time. The goal is to automate everything that you can.

What are Cookies?

They are small files which are stored on a browser. In Java, it is an object used to store information client side.

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 is the URI?

Uniform Resource Identifier - identifies a file or resource/servlet

What is the URL? What is it comprised of?

Uniform Resource Locator - a reference to a web resource that specifies its location on a computer network Compromised of: host(domain) + port + uri + parameters

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.

What is front controller design pattern?

When you funnel all requests to a single point and then send requests to appropriate services.

What media types does SOAP support?

XML

Is SOAP stateless?

Yes, unless you use an SMTP protocol.

Protocol stack

a. Transport Protocol b. Messaging Protocol c. Description Protocol d. Discovery Protocol

Name other forms of Session Handling (typically on the do not recommend list).

url rewriting Hidden forms


संबंधित स्टडी सेट्स

ch 6 - Topic D - 1.1 + 1.8 + 5.2

View Set

Pathophys Exam 2 Practice Questions

View Set

Adult/Family Health III Exam 1 Case Studies

View Set

Maternity 2, Exam 2 REVIEW QUESTIONS

View Set

Chapter 27: Safety, security, and emergency preparedness

View Set