SF-PD2 Process Automation, Logic, and Integration Practice Question
An architect needs to expose custom Apex business logic as a RESTful web service that accepts complex JSON payloads containing polymorphic relationships. Which annotation and method signature combination should a developer use to implement this endpoint?
⚠ Common exam trap
Candidates often forget the required global access modifier on the class or select incorrect annotations for HTTP methods, causing the endpoint to fail registration or execution.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Global class with @RestResource(urlMapping='/api/v1/orders/*') and a static method annotated with @HttpPost receiving parsed wrapper instances.
Apex REST services are exposed using the @RestResource annotation on a global class. The inbound HTTP POST method must be annotated with @HttpPost and accept parameters that map directly to the incoming JSON structure using Apex deserialization or wrapper classes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Global class with @RestResource(urlMapping='/api/v1/orders/*') and a static method annotated with @HttpGet returning a Blob.
Why it's wrong here
@HttpGet maps to the HTTP GET verb, which carries no request body, so complex JSON payloads cannot be accepted; returning a Blob also bypasses JSON deserialisation. It is tempting because @RestResource with a URL mapping correctly exposes Apex as REST, and would suit a read-only endpoint returning binary data.
- ✓
Global class with @RestResource(urlMapping='/api/v1/orders/*') and a static method annotated with @HttpPost receiving parsed wrapper instances.
Why this is correct
A global class exposing @RestResource with a URL mapping, plus a static @HttpPost method accepting deserialised wrapper instances, lets Apex parse complex JSON including polymorphic types. Wrappers give explicit typed fields, which Apex requires because it cannot natively bind polymorphic JSON to a single concrete type.
- ✗
Public webservice class with a static method annotated with @WebService returning a serialized JSON string to the calling client.
Why it's wrong here
The webservice keyword and @WebService annotation expose SOAP endpoints, not REST, and returning a serialised string bypasses automatic JSON deserialisation of the payload. It is tempting because Apex web services do expose logic externally, and would be correct for a SOAP integration with XML messages.
- ✗
Global restful class implementing Database.Batchable with an execute method annotated with @HttpPost processing single payloads.
Why it's wrong here
Database.Batchable is an asynchronous bulk-processing interface, not an HTTP endpoint; annotating an execute method with @HttpPost does not expose it to inbound REST calls. It is tempting because batch Apex handles large volumes, and would be correct for processing bulk records asynchronously rather than serving a synchronous web service.
About these practice questions
This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.