Application Development53% of the exam

Calling services with LocalServiceRegistry callbacks

How to create a service instance with LocalServiceRegistry, implement the callbacks for HTTP, FTP and SOAP types in the right order, build requests (method, body, authentication, mTLS), cache GET responses, read the Result, and troubleshoot or extend a deployed service.

Official exam objective
Integrate, deploy, and use a service instance based on a given requirement.

~7 min read · 15 practice questions ·

What the exam expects

  • Create a service instance with LocalServiceRegistry.createService and implement the callbacks a given service type needs, in the order the framework runs them.
  • Configure an HTTP request in createRequest: method, body, headers, authentication, query parameters and response caching.
  • Read a Result (ok, status, error, errorMessage) or make a non-OK result throw.
  • Deploy and troubleshoot a service: cartridge path, Enabled, Live, client certificates, Service Status, custom attributes on the service objects.

Key terms: service configuration (the Business Manager record, a ServiceConfig object, naming type, credential and profile); service instance (the single-use Service object createService returns); callback (code in the configuration object the framework runs at set points of a call); Result (the object Service.call returns); mutual TLS (the client presents a private key during the HTTPS handshake).

Key facts

createService arguments
Detail
Service ID from Business Manager plus a callback object
No init script
Detail
Service is local to the script call; no package.json entry
Callback order
Detail
initServiceClient, createRequest, execute, parseResponse
HTTP default method
Detail
POST
Request body
Detail
Return value converted to a String
Default authentication
Detail
BASIC; set NONE to turn it off
setCachingTTL
Detail
GET, 2xx, content length, under 50k, not written to file
Cached calls
Detail
Still count toward rate limits and circuit breakers
result.error
Detail
Type-specific code, such as 404 for HTTP
Throw on failure
Detail
setThrowOnError() before call()
Service Status data
Detail
Near real time, kept up to 10 days
Several URIs, one credential
Detail
getURL callback
Sources for this section (3)
  • Why must a cached HTTP response depend only on its URL?
  • Why get a SOAP port in initServiceClient rather than in execute?
  • What happens when an HTTP service's identity is set to a reference named __NONE__?
  • What is the default request body encoding of an HTTP service?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the B2C Commerce Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 28 lessons of the B2C Commerce Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Practice exams purchase adds inline bank questions and topic practice (15 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Choose guide-only, practice-only, or save $4 with both

Practice for the B2C Commerce Developer exam