# Calling services with LocalServiceRegistry callbacks

*B2C Commerce Developer Study Guide · Application Development · Last updated November 3, 2026 · https://www.certifyforce.com/study-guide/b2c-commerce-developer/application-development/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.

- Certification: Salesforce B2C Commerce Developer
- Exam section: Application Development
- Study guide: https://www.certifyforce.com/study-guide/b2c-commerce-developer

**Official exam objective:**

> Integrate, deploy, and use a service instance based on a given requirement.

## 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

| Fact | Detail | Source |
|---|---|---|
| `createService` arguments | Service ID from Business Manager plus a callback object | [Class LocalServiceRegistry](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.LocalServiceRegistry.html) |
| No init script | Service is local to the script call; no package.json entry | [Class LocalServiceRegistry](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.LocalServiceRegistry.html) |
| Callback order | `initServiceClient`, `createRequest`, `execute`, `parseResponse` | [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html) |
| HTTP default method | POST | [Class HTTPService](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPService.html) |
| Request body | Return value converted to a String | [Class HTTPService](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPService.html) |
| Default authentication | BASIC; set NONE to turn it off | [Class HTTPService](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPService.html) |
| `setCachingTTL` | GET, 2xx, content length, under 50k, not written to file | [Class HTTPService](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPService.html) |
| Cached calls | Still count toward rate limits and circuit breakers | [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html) |
| `result.error` | Type-specific code, such as 404 for HTTP | [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html) |
| Throw on failure | `setThrowOnError()` before `call()` | [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html) |
| Service Status data | Near real time, kept up to 10 days | [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html) |
| Several URIs, one credential | `getURL` callback | [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html) |

## Check yourself

- 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?

## Sources

- [Web Services](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-webservices.html)
- [Class LocalServiceRegistry](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.LocalServiceRegistry.html)
- [Class HTTPService](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPService.html)
- [Class Result](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.Result.html)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 15 linked practice questions, and unlimited timed mock exams are included with the B2C Commerce Developer pack (USD $19): https://www.certifyforce.com/practice-exams
