[Download] | [Documentation Home] | [Release Note]
A data service is also a typical web service, with some added specialized functionality. So when talking about a web service, namespace handling is a crucial requirement, as every aspect is based on XML. In this section, we will show how WSO2 Data Services Server handles namespaces, from how the service namespace is set, to having multiple namespaces inside a complex result.
The service namespace is the namespace that is used to unique identify a web service uniquely. In the WSDL which represents the service, it will be indicated with the "targetNamespace" attribute of the WSDL document element. The service namespace is set in the first step of the data services wizard. Figure 1 shows an example on how this is done.
Figure 1: Setting the service namespace.
This namespace is set by setting the "Row namespace" value in the query result section. This namespace basically associates the result rows or result entries a specific namespace. So all the subelements in that result raw will be under this namespace by default. Figure 2 shows how the row namespace is set for the query result element "customers".
Figure 2: Setting the service row namespace.
Figure 3: XML Schema type definition of the "customers" element with the given namespace.
We may get the requirement that, only some of the elements in the result row should contain a specific namespace. This can be done by setting the namespace in the output mappings. Figure 4 shows how it is done.
Figure 4: Setting a namespace for a single element in a result row.
Figure 5 shows how this is reflected in the WSDL.
Figure 5: WSDL of a data service with a specific namespace assigned to the "country" element.
In complex results in data services, result elements can be arbitrarily nested. These nested elements can have their own namespaces. Figure 6 shows how this is represented in a dbs file fragment, which has a complex result.
Figure 6: Data service configuration with namespace assigned to a nested element.
The WSDL created for the above service is shown in Figure 7.
Figure 7: Data service WSDL with namespaces provided to a complex result.
Finally, when this service is executed, the resulted XML is shown below in Figure 8.
Figure 8: Data service result with complex types.
There are several places in a data service where you will define namespaces. And there's an inheritance order, where a top level defined namespace will be inherited by its children. The below list summarizes the inheritance order.