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.
Creating a New Web Service
To create a new web service:
- Configure Web Services in Business Manager
- Code Your Web Service.
- Set Up Logging and Troubleshoot Your Web Service.
- Get the web service ready to go live.
Getting the Web Service Ready to Go Live
- 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.
- Use code replication to push your code to the Development and Production instance.
- Select Service option to export your service, profile, and credential configurations and import them into the Development and Production instances. . Select the
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:
.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.