17.9. XML for Analysis Provider

XML for Analysis (XMLA) is a SOAP based XML API for data access interaction between a client application and a data provider working over the Web. The Virtuoso SOAP server can act as an XMLA data provider, also the Virtuoso SOAP client can be used as a client to talk with an XMLA data provider.

The following terms: result-set and row-set will be used interchangeably to designate repeating content with identical structure. The mention of a result-set and row-set in this document is related to an SQL/ODBC result set which is represented as XML for use in XMLA.

The implementation is based on the "XML for Analysis Specification v 1.0" by Microsoft Corp, found on the MSDN website.

The XMLA protocol consists of two SOAP operations: "Discover" and "Execute" which are described below:

The Discover operation is used to retrieve settings and database object information. It accepts the following input parameters:

  • RequestType - enumerated string.
  • Restrictions - a structure of restrictions to be applied to the processing of request, the type values may vary, depending on the request.
  • Properties - properties to the request, such as data source name, initial catalog etc.

Upon success the "Discover" operation will return a specific rowset. The 'specific' means that its structure depends of type of request.

The XMLA data provider supports the following discovery rowsets:

  • DISCOVER_DATASOURCES - to discover available data sources
  • DISCOVER_PROPERTIES - the properties which can be used/set
  • DISCOVER_SCHEMA_ROWSETS - this list itself with allowed restrictions
  • DISCOVER_ENUMERATORS - enumeration values supported by provider
  • DISCOVER_KEYWORDS - reserved words
  • DISCOVER_LITERALS - restrictions on database object names etc.
  • DBSCHEMA_CATALOGS - list of catalogs
  • DBSCHEMA_TABLES - list of tables
  • DBSCHEMA_TABLES_INFO - list of info about tables
  • DBSCHEMA_COLUMNS - list of columns
  • DBSCHEMA_PROVIDER_TYPES - list of datatypes

Here is an example of a response message to the Discover invocation:

----
<SOAP:Envelope SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP:Body>
    <cli:DiscoverResponse xmlns:cli="urn:schemas-microsoft-com:xml-analysis">
      <Result xmlns="">
        <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
          <n0:schema xmlns:n0="http://www.w3.org/2001/XMLSchema"
	             targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset"
		     elementFormDefault="qualified">
            <n0:element name="root" type="n2:root" xmlns:n2="urn:schemas-microsoft-com:xml-analysis:rowset"/>
	    ... more declarations ...
          </n0:schema>
          <row xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
	    ... rowset data ...
          </row>
        </root>
      </Result>
    </cli:DiscoverResponse>
  </SOAP:Body>
</SOAP:Envelope>
  ----
  

The client can use information retrieved with the "Discover" operation for automatically formulating queries etc.

The Execute operation is used to process a SQL statement on the server and to return resultset or/and schema description for the resultset. The current implementation supports only SQL statements. It accepts the following input parameters:

  • Command - a structure with single element - "Statement" , which contains the SQL statement.
  • Properties - properties to the execution process.

On success the "Execute" operation will return the rowset and/or XSD for the rowset.

----
<SOAP:Envelope SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP:Body>
    <cli:ExecuteResponse xmlns:cli="urn:schemas-microsoft-com:xml-analysis">
      <Result xmlns="">
        <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
          <n0:schema xmlns:n0="http://www.w3.org/2001/XMLSchema"
	             targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset"
		     elementFormDefault="qualified">
            <n0:element name="root" type="n2:root" xmlns:n2="urn:schemas-microsoft-com:xml-analysis:rowset"/>
	    ... more XSD declarations ...
          </n0:schema>
          <row xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
	    ... rowset data ...
          </row>
	  more <row> elements
        </root>
      </Result>
    </cli:ExecuteResponse>
  </SOAP:Body>
</SOAP:Envelope>
 ----
  

The XML representation of the result sets can have three forms: Tabular, Multidimensional and Custom. As the Virtuoso server is a tabular data provider itself, hence the current XMLA implementation supports only Tabular representation.

The Tabular representation of the result set consist of two main parts:

  • schema - XML Schema definition of result
  • data - sequence of repeating elements, each consisting of elements representing the cells in the rowset
Security

The Execute operation needs the properties Username and Password to be supplied in order to execute the statement on behalf of an SQL user account. If these are not supplied the request will be rejected with SOAP:Fault message. To prevent a network sniffer from catching the password in clear text, it is strongly recommended that sending of these properties be done via HTTPS (SSL/TLS) connection (for HTTPS setup see Web server section, and tutorials).

State Support

The Virtuoso XMLA provider implements statelessness for the settable properties. This means that properties such as UserName and Password can be set in the beginning and they will be restored on server side on the next request ID for which they are not supplied. This mechanism is very similar to URL poisoning state support, which is described in the Web server section of the documentation. In short, the XMLA client asks to begin a session, the XMLA provider returns a session ID and from that point the client sends this ID to the server. If the client wishes, it may cancel the session with an end session request.

The above requests are SOAP messages carried in the SOAP Header element. Please note that these headers can be sent together with Discover or Execute operations.

Here is a simple session:

- client requests a session
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
  <xmla:BeginSession xmlns:xmla="urn:schemas-microsoft-com:xml-analysis" mustUnderstand="1"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
   <!-- Discover or Execute call -->

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

- server returns the SessionID
<SOAP-ENV:Header>
  <xmla:Session xmlns:xmla="urn:schemas-microsoft-com:xml-analysis" mustUnderstand="1" SessionID="NNNNNN" />
</SOAP-ENV:Header>

- sequential requests of client contains:
<SOAP-ENV:Header>
  <xmla:Session xmlns:xmla="urn:schemas-microsoft-com:xml-analysis" mustUnderstand="1" SessionID="NNNNNN" />
</SOAP-ENV:Header>

- and finally client cancel the session:
<SOAP-ENV:Header>
  <xmla:EndSession xmlns:xmla="urn:schemas-microsoft-com:xml-analysis" mustUnderstand="1" SessionID="NNNNNN" />
</SOAP-ENV:Header>
  

17.9.1. Namespaces

The request and response are in the "urn:schemas-microsoft-com:xml-analysis" namespace. Also SOAPAction header field must be "urn:schemas-microsoft-com:xml-analysis:Discover" and "urn:schemas-microsoft-com:xml-analysis:Execute" for Discover and Execute operations.


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®