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.
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.
To create a new web service:
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:
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.