REST-101 Flashcards

1
Q

Which is the default factory to create the RestTemplate?

A

ClientHttpRequestFactory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is GingerBread?

A

It is Google API for RTemp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Does RTemp supports GZIP Compression trxn

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Google GSON

A

It is a Object to JSON marshalling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is required for RTemp construction?

A

A MessageConvertor and a factory, Offcourse both choice has defaults set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the default Exception Handler ?

A

RestClientException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Does all HTTP methods throws REstClientException?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do RTemp supports the GZIP compression?

A

By adding Accept-Encoding in the headers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

For all HTTP methoda what are the general return types?

A

T, ResponseEntity, URI,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Just say the different Methid types?

A

GET, PUT, POST, OPTIONS, HEAD, POST

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why we require HttpMessageConverter

A

The Object are to and from converted to HTTPRequest to HTTPResponse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Say the methods of HttpMessageConverter?

A
boolean canRead(Class> clazz , Mediatype type)
boolean canWrite(Class> clazz, MediaType type)
List getSupportedMediaTypes()
T read(Class> clazz, HttpInputMessage inputMessage) 
throws IOException, HttpMessageNotReadableException

T write(Class> clazz, HttpOutputMessage ouptputMessage) throws IOException, HttpMessageNotWritableException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you register your own MessageConverter?

A

By using messageconverters prop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Name the main MessageCoverters type?

A
ByteArrayHttpMessageConverter
StringHttpMessageConverter
ResourceHttpMessageConverter
XmlAwareFormHttpMessageConverter
FormHttpMessageConverter
SimpleXmlHttpMessageConverter
MappingJackson2HttpMessageConverter
MappingJacksonHttpMessageConverter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Does by default all messagecoverters available?

A

Nope, by default, ByteArray,String & ResourceHttpMessageCoverter is available

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Generally which MessageConverters is used as interface?

A

HttpMessageConverter

17
Q

What does ByteArraymessageConverter does?

A

It supports the converter that read and write byte arrays ito and from Http Request-Response.

18
Q

What is the content-type for ByteArraymessageConverter ?

A

application/octet-stream

19
Q

Can we override the ByteArraymessageConverter meda type?

A

Yes you can override the supportedMedia Types and override getContentType(byte[])

20
Q

Whish converter helps for eriting to and fro for the form data in http request-response cycle?

A

FormHttpmessageConverter

21
Q

How does a form data is read -write in http request-response cycle?

A

MultiValueMap

22
Q

What is the content-type for FormHttpMessageConverter?

A

application/x-www-form-urlencoded

23
Q

How can we have XMLMessgaeConverter?

A

You can have XMLAwareFormHttpMessageConverter, add support through SourceHttpMessageConverter

24
Q

what is default way of showing all content-type

A

text/*, text/plain as output

25
Q

Which XMl Message Converter is used for simple xml

A

SimpleXMLHttpMessageConverter

26
Q

What is the content-type for SimpleXMLHttpMessageConverter?

A

application/*+xml

27
Q

Which HttpMessageConverter is used for JSON

A

MappingJackson[2]HttpMessageConverter

28
Q

How can we have a custom JSON reader /writer specific to a class??

A

Inject ObjectMapper

29
Q

What is the content-type for JSON

A

application/json

30
Q

Is GsonHttpMessageConveter is same as JSON Converter type?

A

Yes both supports application/json content-type, thus only use one always

31
Q

Can you write a basic code way for RTEMP?

A
String url = ""
RestTemplate template = new RestTemplate()
restTemplate().getMessageConverter(new StringHttpMessageConverter())
Stirng result = template.getForObject(url, String.class, "simplanameit")
32
Q

Write a code for GZIP Compressioin ?

A

Thr GZIp is sent through the String way but the accept-encoding header is required.
Httpheaders headers = new HttpHeaders()
headers.setAccpetEncoding(ContentCodingType.GZIP)
Httpenetity<> entity = new HttpEnetity(requestHeaders)
RestTemplate temp = new RestTemplate()
template.gettMessageConverters.add(new StringHttpMessageConverter)

ResponseEntity response = restTemplate.exchange(url, HhttpMethod.GET, requestEnety.Class, String.class)

33
Q

When do we use exchange method of RTemp?

A

When we have HttpEnetity and all

34
Q

What is HttpEntity

A

An Entity show an Http to be done , with header and body setted

35
Q

Does the Accept Encoding set by default?

A

Yes sometimes, and thus take care while impl, remeber World is hidden

36
Q

What extra do we have to do for HttpBasisaUTHENTICATION?

A

hTTPaUTHENTICATION authHeader = new HttpBasicAuthentication(username, password)

Httpheaders = header - new Httpheader();
requestHeaders.setAuthrorization(authHeaders))
HttpEnetity> entity = new HttpEnetity (requestHEaders)

same use exchange method