Previous Page Arrow Next Page Arrow

11.7 Operation Template

An operation may have a $template URL. If so, a GET operation on the $template URL will return default values for the operation parameters. For example:

GET /sdata/myApp/myContract/-/products/$service/computeSimplePrice/$template

Returns:

200 OK
Content-Type: application/atom+xml; type=entry
 
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.example.com/sdata/myApp/myContract/-/products/$service/computeSimplePrice</id>
  <sdata:payload>
    <productComputeSimplePrice xmlns="http://schemas.sage.com/myContract">
      <request>
        <quantity>1.0</quantity>
      </request>
    </productComputeSimplePrice>
  </sdata:payload>
</entry>

This URL is useful if the operation is invoked via a form. It allows the SData consumer to easily fill the form with meaningful default values. In the example above, the consumer will use 1.0 as default value for the quantity field.

The service schema MUST advertise the presence of a $template URL on service operations. This is done by setting the sme:hasTemplate attribute to true on service operation elements. For example:

<xs:element name="productComputeSimplePrice" 
              type="tns:productComputeSimplePrice--type"
              sme:role="serviceOperation"
              sme:path="products/$service/computeSimplePrice"
              sme:hasTemplate="true"
              sme:invocationMode="sync" 
              sme:batchingMode="syncOrAsync"/>
SData providers MAY support $template URLs on service operations. If so, they MUST advertise it with an sme:hasTemplate attribute in the schema.

Previous Page Arrow Next Page Arrow