Salesforce Certified B2C Commerce Developer free question 9 / 10 · Domain 4: Application Development
A script calls Service.call for a SOAP service, and the framework invokes the callbacks of the service. In which order are they called?
- initServiceClient, createRequest, execute, parseResponse
- initServiceClient, execute, createRequest, parseResponse
- createRequest, execute, parseResponse, initServiceClient
- createRequest, initServiceClient, execute, parseResponse
Show the answer and explanation
Answer: A
Why this is correct
The Web Services page lists the callback methods in the order in which the framework calls them when Service.call is used. First initServiceClient creates the underlying client, then createRequest configures the request, then execute performs it, and finally parseResponse converts the result into the object that Service.call returns. Some callbacks are optional, depending on the type of service.
Why the other options are wrong
"createRequest, initServiceClient, execute, parseResponse" … The client is created first with initServiceClient, and createRequest then configures the actual request.
"initServiceClient, execute, createRequest, parseResponse" … createRequest configures the request, and execute performs it, so createRequest comes before execute.
"createRequest, execute, parseResponse, initServiceClient" … initServiceClient creates the underlying client used to make the call, so it comes first and not last.
Key points
initServiceClient is required only for SOAP services, because other client types are created automatically.