Service variants provide views on service interfaces. Instead of using all the parameters in a service interface, a service variant allows you to use only parameters that are needed for a particular business context.
A service variant is based on a service interface and reuses the implementation of that service to create the new service. It is not necessary to create a new service implementation.
A service variant has its own WSDL and service endpoint, and is published to the Service Registry in the same way as any other standard service.
Service interfaces can often contain many parameters to support several different use cases and to enable a high degree of reuse of services. For this reason, it can sometimes be difficult to know which parameters in the service interface are relevant for their specific business purpose. By using service variants, you can simplify the way a service is consumed, for example, by hiding fields or assigning fixed values.
Service variants are created in the ABAP back-end system.
Start transaction SVAR.
Choose New.
The Wizard for service variants is started.
Note
Alternatively, you can start the Wizard from the context menu in the root node of the package. Choose
Specify a name and a namespace suffix for the new service variant.
The namespace is built by concatenating the namespace prefix and the namespace suffix. The namespace prefix cannot be changed.
In the Base Service Interface box, specify the service interface on which to base the new service variant, and its namespace.
Note
The service interface you specify must be released. If the service interface is not released, the system prevents you from continuing.
Choose Continue.
Specify a package and a transport request.
Choose Finish.
The new service variant is now created.
When a service variant is first created, it has the following default field states:
Hidden with fixed value propagation |
for all optional fields |
Hidden without fixed value propagation |
for all optional fields that reference complex types |
Visible |
for all non-optional field and for all operations |
Note
If the base service is changed, for example, if optional fields or operations are added, the default state for the new fields and the new operations is Hidden without fixed value propagation.
You can change the following properties of a service variant:
Hide or unhide operations from the base service interface
Hide fields from the base service that are not required for the service variant
Set fixed values for fields
Define optional fields as mandatory
You cannot define mandatory fields as optional.
To change a service variant:
Start the proxy editor (transaction code SPROXY).
Locate the service variant that you want to change.
Use transaction code SE80, then choose Edit Object, and search for the service variant.
Go to the External View tab.
Choose Edit.
You can now change the field attributes.
Below is an overview of the field attributes:
Visible |
Visible applies when none of the hidden states is used. The behavior of a Visible field is the same as in the base service interface. |
Mandatory |
Only optional fields in the base service interface can be defined as mandatory in the service variant. To ensure that the response XML is valid, you should set to mandatory only fields that are always filled by the base service implementation. If a field in the response structure is not filled, this may result in an invalid XML response at runtime. Note This attribute cannot be used for tables (maxOccurs > 1). End of the note. |
Hidden |
Hidden fields are not included in the XSD document. If mandatory fields are set to hidden, a value is required. If a XSD default value is assigned to the base service interface, this becomes the default field value. If a field is hidden in a service variant, the field is not included in the WSDL document when it is generated. There are two different hidden states.
|