Which annotation exposes an Apex class as a RESTful web service?

Which annotation exposes an Apex class as a RESTful web service?
A . @HttpInvocable
B . @RemoteAction
C . @RestResource (urlMapping="’/mySexrvice/*’)
D . @AuraEnabled(cacheable=true)

Answer: C

Explanation:

To expose an Apex class as a RESTful web service, you use the @RestResource annotation.

Option C: @RestResource(urlMapping=’/myService/*’)

@RestResource Annotation:

The @RestResource annotation is used to define an Apex class as a RESTful web service, specifying the URL mapping.

Methods within the class are annotated with @HttpGet, @HttpPost, @HttpPut, etc., to handle HTTP

requests.

Example:

apex

Copy code

@RestResource(urlMapping=’/myService/*’)

global with sharing class MyRestService {

@HttpGet

global static String doGet() {

// Implementation

}

}

Reference: "Use @RestResource to expose an Apex class as a RESTful web service."

― Apex Developer Guide: Exposing Apex Classes as REST Web Services Why Other Options Are Incorrect:

Option A: @HttpInvocable

There is no @HttpInvocable annotation in Apex. Option B: @RemoteAction

Used to expose methods to JavaScript in Visualforce pages, not for REST services. "@RemoteAction methods enable you to call methods in Apex controllers from JavaScript code in a Visualforce page."

― Apex Developer Guide: Remote Action Methods

Option D: @AuraEnabled(cacheable=true)

Used to expose Apex methods to Lightning components, not for REST services.

Conclusion:

Using @RestResource with a URL mapping is the correct way to expose an Apex class as a RESTful web service.

Latest DEX-450 Dumps Valid Version with 456 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments