A developer needs to make a call to a long running web service which is critical to finalizing their checkout process. Which three items should the developer consider in their implementation?
Correct Answer: A,B,C
Explanation
A developer needs to make a call to a long running web service which is critical to finalizing their checkout process. The developer should consider the following items in their implementation:
* A new CORS entry may need to be created in Setup. CORS stands for Cross-Origin Resource Sharing, which is a mechanism that allows web browsers to make requests to servers on different domains. If the web service is hosted on a different domain than the B2B Commerce site, the developer may need to add a CORS entry in Setup to allow the browser to access the web service. This entry specifies the origin, path, and method of the request, as well as any headers or cookies that are allowed1.
* A new Named Credential may need to be created in Setup. A Named Credential is a type of metadata that stores the URL and authentication settings of a web service. By using a Named Credential, the developer can avoid hardcoding the web service URL and credentials in their code, and instead reference the Named Credential by name. This makes the code more secure and easier to maintain2.
* An Apex method returning a Continuation will need to be created. A Continuation is a special type of Apex object that allows the developer to make asynchronous calls to long running web services.
Byusing a Continuation, the developer can avoid blocking the main thread and improve the user experience. A Continuation method must return a Continuation object, specify the web service URL and parameters, and register a callback method that handles the response3.
Option D and Option E are incorrect because they are not relevant to the scenario. Option D suggests that the developer should broker the requests to the web service, which means to use an intermediary service that manages the requests and responses. This may be useful for some scenarios, but it is not required for making a call to a long running web service. Option E suggests that the developer should create a new Remote Site in Setup, which is a way to whitelist the domains that can be accessed from Apex code. However, this is not necessary if the developer uses a Named Credential, which automatically handles the Remote Site setting2.
References:
* Set Up CORS
* Named Credentials
* Continuation Class
Recent Comments (The most recent comments are at the top.)
A,B,C are also correct here https://www.actual4test.com/discussions/Salesforce/exam-b2b-commerce-developer-topic-1-question-160-discussion-p1015745.html
According to Google Gemini:
The developer should consider the following three items in their implementation:
B. An Apex method returning a Continuation will need to be created.
A long-running web service call can potentially block the checkout process. To avoid this, the developer should create an Apex method that returns a Continuation. This allows the method to execute asynchronously, preventing the checkout process from being delayed.
C. Requests to the service should be brokered to prevent limit exceptions.
If the long-running web service has rate limits, the developer should implement a brokering mechanism to manage requests and prevent exceeding those limits. This can involve queuing requests or using a message queue system.
D. A new Remote Site may need to be created in Setup.
If the web service is hosted on a different domain, a new Remote Site setting may need to be created in Setup to allow Salesforce to make cross-domain requests. This is necessary to ensure that the Apex method can successfully communicate with the external web service.
While a new CORS entry or Named Credential might be necessary in certain scenarios, they are not always required for long-running web service calls. The key considerations are to avoid blocking the checkout process, manage rate limits, and ensure proper communication with the external service....