Integration: 11% Flashcards

1
Q

How do you expose an Apex class as a REST API?

A
The class must be global and annotated with the @RestResource annotation.
The parameter of the @RestResrouce annotation, urlMapping is used to uniquely idnetify your resource and is relate to the base URL https://instance.salesforce.com/services/apexrest
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: All Apex REST methods must be global static?

A

True

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

What does @HttpGet mean?

A

The @HttpGet annotation exposes the method as a REST API that is called when an HTTP GET request is sent from the client

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

What does @HttpPost mean?

A

The @HttpPost annotation exposes the method as a REST API and is called when an HTTP POST request is sent form the client.

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

How do you expose an Apex class as a SOAP Webservice?

A

By creating a global Class, and then create a web service method within the class. These methods will inherit the global access of their parent class.

Example:
global with sharing class MySOAPWebService {
    webservice static Account getRecord(String id) {
        // Add your code
    }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or False: Webservice methods cannot be static

A

False: webservice methods must be static

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

True or False: Webservice methods can be overloaded

A

False: webservice methods cannot be overloaded

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

Can the webservice keyword be used in any code contained in a trigger?

A

False, the webservice keyword cannot be used in any code contained in a trigger

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

When would you use the @ReadOnly annotation in a Web Service?

A

To allow unrestricted queries when no DML operations are necessary

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

What does Apex support for the WSDL?

A

Apex supports:

  • A limited set of WSDL schema types
  • The element and sequence WSDL schema constructs
  • Blob, decimal, and enum for call ins but not for call outs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does Apex not support with WSDL?

A

Apex does not support

  • Encoded services
  • WSDL files with multiple portTypes, multiple services or multiple bindings
  • WSDLs that exceed the size limit, including the Salesforce WSDLs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Are WSDL files with imports supported?

A

No

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

Why would you set HTTP headers on a Web Service callout?

A

To set the value of a cookie in an authorization header
inputHttpHeaders_x is used for callout and outputHttpHeaders can be used to read the HTTP response headers returned after an HTTP request

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

When importing an external WSDL, what is generated in SFDC?

A

Successful importation of an external WSDL will generate an Apex stub (proxy) class

Use the stub instance to

  • setup your authorization credentials for the external service
  • make external service method calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you expose an Apex class as a REST service

A

Define your class as global and define methods as global static. Add the annotations to the class and methods

The Apex class should have the @RestResource annotation. Similarly, you can add annotations to the class methods to expose them through REST

example: 
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
    @HttpGet
    global static Account getRecord() {
        // Add your code
    }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which annotation is used to specify a RESTful Web service method that will delete a specified resource?

A

@httpDelete deletes the specified resource

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

Which annotation is used to specify a RESTful Web service method that will return a specified resource?

A

@httpGet reads or retrieves records

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

Which annotation is used to specify a RESTful Web service method that will update a specified resource?

A

@HttpPatch updates fields in existing records

@HttpPut can also be used to update a existing records or create records

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

Which annotation is used to specify a RESTful Web service method that will create a specified resource?

A

@HttpPost creates a new record

@HttpPut can also be used to create records (as well as updating them)

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

Which annotation is used to specify a RESTful Web service method that will create or update a specified resource?

A

@HttpPut creates a new resource or updates the specified resource.

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

The RestContext object cointains which two Rest objects?

A

RestContext object cointains the RestRequest and RestResponse objects

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

Why do @HttpGet or @HttpDelete annotations not have any parameters?

A

This is because GET and DELETE requests do not have a body and hence do not need serialization

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

What type of parameters are used in Apex REST methods?

A

Use user-defined types for parameters in Apex REST methods

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

Which formats are used to represent resources for Apex REST Web Services?

A

JSON and XML formats are used to represent resources.

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

How do you invoke a REST-based webservice?

A

Through an appropriate HTTP request and a URL which includes a location of the Salesforce server, an Apex REST service and a resource

for example:
https://instance.salesforce.com/services/apexrest/resourceName

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

Can you make an webservice callout when a WSDL has not been imported?

A

Yes, you can make callouts from Apex where you are not using WSDL. It is also possible to access external Web Services using HTTP callouts without the associated infrastructre or requirement of WSDL or SOAP.

You can send HTTP requests, such as GET, POST and PUT and also handle responses returned by these requests

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

Which XML class is used to read through XML responses returned from callouts

A

XMLStreamReader

It enables foward, read-only access to XML data returned from an HTTP callout

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

Which XML class is used to create an XML document (or enables the writing of XML data)

A

XMLStreamWriter

29
Q

What alternate classes (excluding the XMLStream classes) can be used for XML classes?

A

Document and XMLNode classes can be used as an alternate to XML classes?

30
Q

What does JSON stand for?

A

JavaScript Object Notation

31
Q

What is the purpose of the JSON class?

A

It provides methods to serialize and de-serialize JSON content

32
Q

What is the purpose of the JSONGenerator class?

A
  • Contains methods used to serialize Apex objects into JSON content
  • Enables the generation of standard JSON-encoded content
33
Q

What is the purpose of the JSONParser class

A

Represents a parser of JSON-encoded content that is returned from a web service call

34
Q

What does REST stand for?

A

Stands for Representational State Transfer

35
Q

Why would you use REST instead of SOAP calls?

A

REST builds on the existing structure of the web by using HTTP verbs such as POST, GET, PUT and DELETE to call services located at a specific URL without the need to delve into the intricacies of SOAP.

REST simply sends and receives XML or JSON data ver HTTP to or from a specific URL

36
Q

What is the only method for the HTTP Class. Also provide the argument and return object

A

send() is the only method, which takes one HTTPRequest argument and returns and HTTPResponse

37
Q

What are the methods for the HTTPRequest Class

A
setEndpoint()
setBody()
setHeader()
setMethod()
setClientCertificate()

getEndpoint()
getBody()
getHeader()
getMethod()

38
Q

What are the methods for the HTTPResponse Class

A
getStatus()
getStatusCode()
getHeader()
getHeaderKeys()
getBody()
getXMLStreamReader()
39
Q

Which class can you use to encode or decode URL strings

A

EncodingUtil class

40
Q

Which class can you use to enable access to external services that require encryption?

A

Crypto class

41
Q

What 5 methods are available for the EncodingUtil Class?

A
base64Decode()
base64Encode()
convertToHex()
urlDecode()
urlEncode()
42
Q

What 6 methods are available for the Crypto Class?

A
encrypt()
decrypt()
sign()
generateMAC()
generateDigest()
generateAesKey()
43
Q

What are two governor limits that there are for Asynchronous Methods ?

A
  • The number of @future method calls per Apex invocation

- The maxium number of asynchronous Apex method executions per 24 hour period

44
Q

What datatype parameters are allowed for an asynchronous method?

A

Must be primitive datatypes or collections of primitive data types.

45
Q

Methods with the @future annotation cannot take _____ as arguments?

A

Methods with the @future annotation cannot take sObjects or objects as arguments?

46
Q

The @future annotation cannot be used in ______ methods or constructors of Visualforce controllers?

A

The @future annotation cannot be used in getter/setter methods or constructors of Visualforce controllers

47
Q

True or False:

You can call Web Services from external sources using SOAP Web Service Callouts?

A

True. You can call Web Services from external sources using SOAP Web Service Callouts

48
Q

Which of the following guidelines are used for creating custom Web Services?
A) webservice methods must be static
B) webservice methods cannot be overloaded
C) A system-defined enum can be used anywhere in a webservice method
D) All classes that contain methods defied with the webService keyword must be declared as private

A

A) and B): The webservice methods must be static and cannot be overloaded

49
Q
Identify the XMLStream classes that provide methods to read and write XML strings
A) XMLStreamWriter
B) XMLWriter
C) XMLStreamReader
D) XMLReader
A

A) and C): The XMLStreamWriter and XMLStreamReader classes provide methods to read and write XML strings

50
Q
Identify the classes that you can use to make HTTP or RESTful callouts 
A) HTTP class
B) HTTPRequest class
C) HTTPServerRequest class
D) HTTPResponse class
E) HTTPServerResponse class
A
A) and B) and C).
You can use HTTP class, HTTPRequest class and HTTPResponse class to make HTTP or RESTful callouts
51
Q
An integration user makes a successful login() call via the SOAP API. What can be used in the SOAP header to provide server authorization for subsequent API requests?
A) Named Credentials
B) Session ID
C) OAuth access toekn
D) Security token
A

B) Session ID

52
Q

Which of these statements is true for Lightning Connect?
A) No external data is imported into your Salesforce org
B) External data is read in real time when you request it
C) It can be used with any data source that supports OData 2.0.
D) All of the above

A

D) All of the above

53
Q

Which of these is NOT an appropriate use case for Lightning Connect?
A) You want to integrate external data without writing custom code.
B) The external data is changing frequently.
C) You need to set up workflows and triggers for the external data.
D) You only need real-time access to a small fraction of the external data.

A

C) You need to set up workflows and triggers for the external data.

54
Q

In which of these scenarios is ETL a better choice than Lightning Connect?
A) You need the external data to follow the sharing rules defined for your organization.
B) You want to generate reports and charts from the external data.
C) All of the above

A

C) All of the above

55
Q

Which of these is NOT true about external objects?
A) They integrate with Salesforce APIs, Apex, Visualforce, and Chatter.
B) They can be related to other objects.
C) You can use them in formula fields.
D) They are automatically viewable in the Salesforce1 mobile app

A

C) You can use them in formula fields.

56
Q

Which of the following statements is true about external callouts:
A) SOAP callouts use XML and may use a WSDL for code generation
B) HTTP callouts typically use JSON but can use XML as well
C) HTTP callouts are generally easier to work with than SOAP callouts
D) All of the above

A

D) All of the above

57
Q

SOAP Web Services are commonly used for:
A) Simple, light weight services that are typically stateless
B) Public APIs that use HTTP and JSON
C) Enterprise apps that require a formal exchange format or stateful operations
D) No one uses SOAP any longer … it’s a four-letter word

A

C) Enterprise apps that require a formal exchange format or stateful operations

58
Q

Which two authentication mechanisms does Apex REST and Apex SOAP support?

A

OAuth 2.0

Session ID

59
Q

What Protocol and Data Format does the REST API require?

A

Protocol: REST

Data Format: JSON/ XML

60
Q

What Protocol and Data Format does the SOAP API require?

A

Protocol: SOAP (WSDL)

Data Format: XML

61
Q

What Protocol and Data Format does the Chatter REST API require?

A

Protocol: REST

Data Format: JSON/ XML

62
Q

What Protocol and Data Format does the BULK API require?

A

Protocol: REST

Data Format: CSV/ JSON/ XML

63
Q

What Protocol and Data Format does the Metadata API require?

A

Protocol: SOAP (WSDL)

Data Format: XML

64
Q

What Protocol and Data Format does the Streaming API require?

A

Protocol: Bayeux

Data Format: JSON

65
Q

What Protocol and Data Format does the Apex Rest API require?

A

Protocol: REST

Data Format: JSON/ XML, Custom

66
Q

What Protocol and Data Format does the Apex SOAP API require?

A

Protocol: SOAP (WSDL)

Data Format: XML

67
Q

What Protocol and Data Format does the Tooling API require?

A

Protocol: REST / SOAP (WSDL)

Data Format: JSON/ XML, Custom

68
Q

What are the two declarations for using a certificate (with SOAP and HTTP)

A

SOAP: Assign the value to a clientCertName_x variable
ex: stub.clientCertName_x = ‘DocSampleCert’;

HTTP: setClientCertificateName using the certificate
ex: req.setClientCertificateName(‘DocSampleCert’);