---
title: "<service-template> Element"
url: https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-xml-reference/service-template-descriptor-element
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# \<service-template> Element

A `service-template` element defines a [template](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-templates.md) for a [service](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-xml-reference/service-descriptor-element.md) element, simplifying the task of deploying multiple instances of the same service definition. The template should contain a parameterized `service` element that is instantiated using a [service-instance](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-xml-reference/service-instance-descriptor-element.md) element.

This element may only appear as a child of an [application](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-xml-reference/application-descriptor-element.md) element.

The following attributes are supported:

| **Attribute** | **Description** | **Required** |
| --- | --- | --- |
| `id` | Specifies the identifier for the service template. This identifier must be unique among all service templates in the application. | Yes |

A template may declare [parameters](https://docs.zeroc.com/ice/3.8/services/icegrid/using-descriptor-variables-and-parameters.md) that are used to instantiate the `service` element. You can define a default value for each parameter. Parameters without a default value are considered mandatory and values for them must be supplied by the `service-instance` element.

Here is an example to demonstrate the use of this element:

```xml
<icegrid>
    <application name="IceBoxApp">
        <service-template id="ServiceTemplate">
            <parameter name="name"/>
            <service name="${name}" entry="DemoService:create">
                <adapter name="${service}" .../>
            </service>
        </service-template>
        <node name="Node1">
            <icebox id="IceBoxServer" ...>
                <service-instance template="ServiceTemplate" name="Service1"/>
            </icebox>
        </node>
    </application>
</icegrid>
```

## See Also

- [IceGrid Templates](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-templates.md)
- [Service Descriptor Element](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-xml-reference/service-descriptor-element.md)
- [Service-Instance Descriptor Element](https://docs.zeroc.com/ice/3.8/services/icegrid/icegrid-xml-reference/service-instance-descriptor-element.md)
- [IceBox Integration with IceGrid](https://docs.zeroc.com/ice/3.8/services/icegrid/icebox-integration-with-icegrid.md)
- [Using Descriptor Variables and Parameters](https://docs.zeroc.com/ice/3.8/services/icegrid/using-descriptor-variables-and-parameters.md)
