---
schema_version: "1"
id: aed9c33f194b80500a49687baa9403ca3e4d25a1ed6f600d6f9d314d419a7e60
title: Class ServiceDefinition
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/script-api/references/current/dw.svc.ServiceDefinition.md
canonical_url: https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f91fbf518d714af1c1a13074b6b7ef0e644e2920728e73c83011ae05d484b409
products:
  - B2C Commerce
  - Salesforce APIs
---
<!-- prettier-ignore-start -->
# Class ServiceDefinition

- [TopLevel.Object](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.svc.ServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md)

Base class of Service Definitions.


A service definition represents configuration that is shared across all [Service](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.Service.md) instances.


**Deprecated:**
**warning:** This class is only used with the deprecated [ServiceRegistry](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceRegistry.md). Use the [LocalServiceRegistry](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.LocalServiceRegistry.md)
            instead, which allows configuration on the [Service](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.Service.md) directly.
**API Version:**
**note:** No longer available as of version 19.10.

## All Known Subclasses
[FTPServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.FTPServiceDefinition.md), [HTTPFormServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPFormServiceDefinition.md), [HTTPServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.HTTPServiceDefinition.md), [SOAPServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.SOAPServiceDefinition.md)
## Property Summary

| Property | Description |
| --- | --- |
| [configuration](#configuration): [ServiceConfig](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceConfig.md) `(read-only)` | Returns the Service Configuration stored in the database. |
| [mock](#mock): [Boolean](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) | Returns the status of whether mock mode is enabled for all instances of this definition. |
| [serviceName](#servicename): [String](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)` | Returns the name of this service. |
| [throwOnError](#throwonerror): [Boolean](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) | Returns the status of whether the shared throwOnError flag is set. |

## Constructor Summary

This class does not have a constructor, so you cannot create it directly.
## Method Summary

| Method | Description |
| --- | --- |
| [configure](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#configureobject)([Object](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)) | Register a callback to handle custom portions of the service. |
| [getConfiguration](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#getconfiguration)() | Returns the Service Configuration stored in the database. |
| [getServiceName](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#getservicename)() | Returns the name of this service. |
| [isMock](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#ismock)() | Returns the status of whether mock mode is enabled for all instances of this definition. |
| [isThrowOnError](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#isthrowonerror)() | Returns the status of whether the shared throwOnError flag is set. |
| [setMock](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#setmock)() | Sets the mock mode for all Service instances that use this definition. |
| [setThrowOnError](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md#setthrowonerror)() | Sets the throwOnError flag to true for all Service instances that use this definition. |

### Methods inherited from class Object

[assign](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)
## Property Details

### configuration
- configuration: [ServiceConfig](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceConfig.md) `(read-only)`
  - : Returns the Service Configuration stored in the database.


---

### mock
- mock: [Boolean](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Returns the status of whether mock mode is enabled for all instances of this definition.


---

### serviceName
- serviceName: [String](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the name of this service.


---

### throwOnError
- throwOnError: [Boolean](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Returns the status of whether the shared throwOnError flag is set.


---

## Method Details

### configure(Object)
- configure(config: [Object](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)): [ServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md)
  - : Register a callback to handle custom portions of the service.
      
      
      This callback may declare multiple methods:
      
      
      ```
      {
        initServiceClient: function() {
            // Create and return the internal service client object.
            // This is usually optional, except in the case of SOAP services.
        },
      
        // svc is the call-specific Service instance. For example, it may be an HTTPService or FTPService.
        // params are the arguments passed to the call method (if any).
        createRequest: function(svc:Service, params) {
             // Perform any required call-time configuration.
             // Optionally return a Service-specific object
        },
      
        // svc is the call-specific Service instance.
        // arg is the output of createRequest.
        execute: function(svc:Service, arg:Object) {
             // Execute the service call and return a result
             // This method is not used by default for HTTP-related services unless executeOverride is set.
        },
      
        // Use the execute function if it is present. This is only required to use the functionality with HTTP services.
        executeOverride: true,
      
        // svc is the call-specific Service instance.
        // response is the output of execute.
        parseResponse: function(svc:Service, response: Object) {
             // Process the response object as needed.
             // The return value of this method will be the return value of the outer call method.
        },
      
        // svc is the call-specific Service instance.
        // arg is the output of createRequest.
        mockCall: function(svc:Service, arg:Object) {
             // This method takes the place of the 'execute' phase when mocking is enabled.
             // Note initServiceClient, createRequest, and parseResponse still invoked.
        },
      
        // svc is the call-specific Service instance.
        // params are the arguments passed to the call method (if any).
        mockFull: function(svc:Service, params) {
             // This method takes the place of the entire service call when mocking is enabled.
             // No other callbacks are invoked. The output of this method becomes the output of call.
        }
      
      }
      ```


    **Parameters:**
    - config - Callback object.

    **Returns:**
    - this


---

### getConfiguration()
- getConfiguration(): [ServiceConfig](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceConfig.md)
  - : Returns the Service Configuration stored in the database.

    **Returns:**
    - Service Configuration.


---

### getServiceName()
- getServiceName(): [String](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the name of this service.

    **Returns:**
    - Service name.


---

### isMock()
- isMock(): [Boolean](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Returns the status of whether mock mode is enabled for all instances of this definition.

    **Returns:**
    - true for mock mode, false otherwise.


---

### isThrowOnError()
- isThrowOnError(): [Boolean](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Returns the status of whether the shared throwOnError flag is set.

    **Returns:**
    - throwOnError flag.


---

### setMock()
- setMock(): [ServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md)
  - : Sets the mock mode for all Service instances that use this definition.

    **Returns:**
    - this Service Definition.


---

### setThrowOnError()
- setThrowOnError(): [ServiceDefinition](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.svc.ServiceDefinition.md)
  - : Sets the throwOnError flag to true for all Service instances that use this definition.

    **Returns:**
    - this Service Definition.


---

<!-- prettier-ignore-end -->
