Web Services

Salesforce B2C Commerce provides a web service framework, which helps you manage calls to web services and analyze service performance. The framework enforces limits that you configure ― limits on the overall number of calls allowed in a time interval, and limits on the number of failed calls allowed in a time interval. It also collects analytics on your web service calls.

Overview

For each web service, the framework requires a service configuration, a service profile configuration, and a service credential configuration. You create these configurations in Business Manager.

The service configuration generates a ServiceConfig object. The service credential is used for basic authentication. The service profile determines how B2C Commerce manages timeouts and rate limits for the web service.



The Web Service Script

A web service script obtains a Service object by calling the LocalServiceRegistry.createService method. The method takes two arguments: the name of a service configuration, and a script object that contains callback code that you provide.

Your script then invokes the service by calling Service.call. When you call this method, the framework checks if the configured rate limit or circuit breaker limit has been exceeded. If not, the framework executes the callbacks you implemented in the Service object.

When the call is complete, your script either passes the result of the successful call to the pipeline dictionary or throws an error.

Note: If your storefront uses pipelines to call web services, the web service script is invoked by a script node within the pipeline. If your storefront uses SFRA controllers to call web services, the web service script does not have to be a separate script file: it can be embedded in the controller itself.

Creating a New Web Service

To create a new web service:

Getting the Web Service Ready to Go Live

  1. Configure credentials, private keys and certificates on the Development and Production instance. These can't be imported or exported and must be manually created on each instance.
  2. Use code replication to push your code to the Development and Production instance.
  3. Select Administration > Operations > Import & Export > Service. Select the Service option to export your service, profile, and credential configurations and import them into the Development and Production instances.

Web Service Performance and Incident Analysis

If you experience reports of problems with a specific web service on your site, in addition to logging, you can also investigate the incident using the analytics for registered web services.

The analytics are available at Business Manager: Administration > Operations > Service Status.

Click on any web service name to drill down to see information about the performance of that web service. Data for a web service is available in near real-time. Data is stored for up to 10 days.

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.