Service types and the client classes they wrap
Key Takeaway
The service type you select in a service configuration decides which client class makes the call and which Service subclass, methods and callbacks your script code works with.
In B2C Commerce, every web service call runs through a service configuration that you create in Business Manager. Part of that configuration is the service type. The type picks the underlying client class that talks to the remote system, such as dw.net.HTTPClient for HTTP. The type also adds type-specific methods to the ones inherited from the dw.svc.Service class. So the type you choose decides which methods and callbacks your script code works with.
How to set up and call a service
- In Business Manager, go to "Administration > Operations > Services" and create a service configuration.
- Select a service type. You must select one when you create the configuration.
- In script code, call
LocalServiceRegistry.createService()with the service ID and an object of callbacks to get the service instance. - Invoke the service by calling
call()on that instance.
Every type inherits the base Service methods, such as call(), setURL(), setCredentialID(), setMock() and setThrowOnError(). The Service class has no constructor. Any configuration you set on a Service instance is local to the currently executing call.