Discover方法解析及示例
XMLA的Discover方法的命令很多,每个命令所附带的属性及参数也很复杂,如果逐条去掌握的话比较费力,本文主要以构建任务一中的多维数据库结构(见图1)及任务二中的Cube结构(见图2)为例介绍常用的命令及属性。这两个处理流程已经包含了基本的处理过程,更复杂的要求可以根据需要对之调整即可。
在介绍过程中,仅给出XMLA封包中的命令部分,外围的SOAP及HTTP封包(参见上一节)基本相同(除非打算在SOAP封包中显式控制SESSION及事务处理)不再重复给出。
注1:由于没有特别指定SESSION及事务,因此,下面的示例每个步骤都是独立的,可以单独请求获取对应信息;
注2:本节Discover命令可通过Execute命令配合MDX语句实现类似效果。
注3:本文的所有命令都是在SSAS2008下调试通过,使用的是微软提供的SSAS2008示例数据库(版本:Refresh1)Adventure Works DW 2008(http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=18407);
任务一:构建多维数据库结构
图1:
步骤示例:
Step1:获取服务器或 Web 服务上可用的 XML for Analysis (XMLA) 访问接口数据源的列表;
DISCOVER_DATASOURCES
返回结果
<Discover xmlns=”urn:schemas-microsoft-com:xml-analysis” SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<RequestType>DISCOVER_DATASOURCES</RequestType>
<Restrictions>
<RestrictionList>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<Content>Data</Content>
</PropertyList>
</Properties>
</Discover>
行集:包含了可用数据源DataSource的名称、属性、支持特性等。
Step2:返回指定数据源所对应的数据库中的目录(Catalog)列表;
DBSCHEMA_CATALOGS
返回结果
<Discover xmlns=”urn:schemas-microsoft-com:xml-analysis”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<RequestType>DBSCHEMA_CATALOGS</RequestType>
<Restrictions>
<RestrictionList>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>http://www.JBean.cn</DataSourceInfo>
<Content>Data</Content>
</PropertyList>
</Properties>
</Discover>
行集:获取上一步返回的数据源JBean 中的目录(Catalog)的名称、描述、访问控制列表ACL等信息。
Step3:返回指定数据源、Catalog下多维数据集(CUBE)列表;
MDSCHEMA_CUBES
返回结果
<Discover xmlns=”urn:schemas-microsoft-com:xml-analysis”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<RequestType>MDSCHEMA_CUBES</RequestType>
<Restrictions>
<RestrictionList>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>http://www.JBean.cn</DataSourceInfo>
<Catalog>Adventure Works DW 2008</Catalog>
<Format>Tabular</Format>
<Content>SchemaData</Content>
</PropertyList>
</Properties>
</Discover>
行集:返回指定数据源(JBean)、Catalog(Adventure Works DW 2008)下的CUBE列表;
任务二:构建多维数据库结构
接下来介绍的是获取一个CUBE(这里是任务一最后一步获取的Adventure Works多维数据集)的维度、层次及成员结构所需的基本步骤。
如下图2所示,我们将展开‘Adventure Works’Cube的维度,并展开其Sale Channel维度的层级直到该维的成员一级。
步骤示例:
Step1:获取指定CUBE的维度(Dimension)列表;
MDSCHEMA_DIMENSIONS
返回结果
<Discover xmlns=”urn:schemas-microsoft-com:xml-analysis”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<RequestType>MDSCHEMA_DIMENSIONS</RequestType>
<Restrictions>
<RestrictionList>
<CATALOG_NAME>Adventure Works DW 2008</CATALOG_NAME>
<CUBE_NAME>Adventure Works</CUBE_NAME>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>http://www.JBean.cn</DataSourceInfo>
<Catalog>Adventure Works DW 2008</Catalog>
<Format>Tabular</Format>
<Content>SchemaData</Content>
</PropertyList>
</Properties>
</Discover>
行集:返回指定数据源(JBean)及Catalog(Adventure Works DW 2008)下的CUBE(Adventure Works)的所有维度列表;
Step2:获取指定维度(Dimension)的默认层次(Level)列表;
MDSCHEMA_DIMENSIONS
返回结果
<Discover xmlns=”urn:schemas-microsoft-com:xml-analysis”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<RequestType>MDSCHEMA_LEVELS</RequestType>
<Restrictions>
<RestrictionList>
<CATALOG_NAME>Adventure Works DW 2008</CATALOG_NAME>
<CUBE_NAME>Adventure Works</CUBE_NAME>
<DIMENSION_UNIQUE_NAME>[Sales Channel]</DIMENSION_UNIQUE_NAME>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>http://www.JBean.cn</DataSourceInfo>
<Catalog>Adventure Works DW 2008</Catalog>
<Format>Tabular</Format>
<Content>SchemaData</Content>
</PropertyList>
</Properties>
</Discover>
行集:返回指定数据源(JBean)、Catalog(Adventure Works DW 2008)、CUBE(Adventure Works)下的维度(Sales Channel)的所有层次列表;
Step3:获取指定层次(Level)下的成员(Member)列表;
MDSCHEMA_MEMBERS
返回结果
<Discover xmlns=”urn:schemas-microsoft-com:xml-analysis”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<RequestType>MDSCHEMA_MEMBERS</RequestType>
<Restrictions>
<RestrictionList>
<CATALOG_NAME>Adventure Works DW 2008</CATALOG_NAME>
<CUBE_NAME>Adventure Works</CUBE_NAME>
<LEVEL_UNIQUE_NAME>[Sales Channel].[Sales Channel].[(All)]</LEVEL_UNIQUE_NAME>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>http://www.JBean.cn</DataSourceInfo>
<Catalog>Adventure Works DW 2008</Catalog>
<Format>Tabular</Format>
<Content>SchemaData</Content>
</PropertyList>
</Properties>
</Discover>
行集:返回维度sale Channel的指定层次(All)下的成员列表;
相关文章:
当前没有评论!
第一个在本文留言。