Using SDMX 2.0 Web Service

The Data Service can be used either as ASP.NET Web Service or as WCF Service. They are distinguished by the URL.

To add reference to ASP.NET Web Service, use the following URL: http://dataservices.imf.org/sdmx20/SDMX_Web_Service.asmx.

To add reference to WCF Service into your project, use the following URL: http://dataservices.imf.org/sdmx20/SDMX_WCF_Service.svc.

These URLs are given as examples and may be different on the concrete server.

The SDMX Web Service exposes the following methods:

• GetDataflow
• GetDataStructure
• GetCompactData
• GetMetadataStructure
• GetGenericMetadata
• GetCodeList
• GetMaxSeriesInResult

1.1 GetDataflow Method   

GetDataflow method returns the list of the datasets, registered for the Data Service.

C# SYNTAX

public XElement GetDataflow();

RETURN VALUE

Type: System.Xml.Linq.XElement

An XML data that represents the SDMX-ML structure message.

REMARKS

Empty SDMX-ML structure message is returned if there are no databases registered for the SDMX Web Service, and if there are no exceptions are being shown.

EXAMPLES

The following code example shows the use of GetDataflow metho

ASP.NET Web Service example:

ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient(); XElement structureMessage = sdmxServiceClient.GetDataflow();

WCF Service example:

WCF20.SDMXServiceClient client = new WCF20.SDMXServiceClient(); var result = client.GetDataflow(); return result.ToString();

1.2 GetDataStructure Method

GetDataStructure method returns the structure of the dataset in the SDMX-ML structure message for the given SDMX-ML query message.

C# SYNTAX

public XElement GetDataStructure(XElement queryMessage);

PARAMETERS

queryMessage

Type: System.Xml.Linq.XElement

An XML data, that represents the SDMX-ML query message

RETURN VALUE

Type: System.Xml.Linq.XElement

An XML data that represents the SDMX-ML structure message.

EXAMPLES

The following code example creates simple SDMX data structure query and shows the use of GetDataStructure method.

ASP.NET Web Service example:
string query = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">     <Query>         <KeyFamilyWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">             <KeyFamily>FAS</KeyFamily>         </KeyFamilyWhere>     </Query> </QueryMessage>"; XDocument queryMessageDocument = XDocument.Parse(query); XElement queryMessage = queryMessageDocument.Root; ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient(); XElement structureMessage = sdmxServiceClient.GetDataStructure(queryMessage);
WCF Service example:  
SDMXServiceClient client = new SDMXServiceClient();
string query = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <KeyFamilyWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <KeyFamily>FAS</KeyFamily>
    </KeyFamilyWhere>
  </Query>
</QueryMessage>";
var result = client.GetDataStructure(XElement.Parse(query));
1.3 GetCompactData Method

GetCompactData method returns the SDMX-ML compact data message for the given SDMX-ML query message.

C# SYNTAX

public XElement GetCompactData(XElement queryMessage);

PARAMETERS

queryMessage

Type: System.Xml.Linq.XElement

An XML data, that represents the SDMX-ML query message

RETURN VALUE

Type: System.Xml.Linq.XElement

An XML data that represents the SDMX-ML compact data message.

EXAMPLES

The following code example creates simple SDMX data query and shows the use of GetCompactData method.

ASP.NET Web Service example:   

string query = 
@"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <DataWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <And>
        <DataSet>FAS</DataSet>
        <Time>
          <StartTime>2010</StartTime>
          <EndTime>2015</EndTime>
        </Time>
        <Dimension id=""FREQ"">A</Dimension>
        <Dimension id=""INDICATOR"">FCMOA_NUM</Dimension>
        <!-- Geographical Outreach, Mobile Banking, Agent Outlets, active, Number of -->
        <Dimension id=""REF_AREA"">AF</Dimension>
        <!-- Afghanistan, Islamic Republic of -->
      </And>
    </DataWhere>
  </Query>
</QueryMessage>";

XDocument queryMessageDocument = XDocument.Parse(query);
XElement queryMessage = queryMessageDocument.Root;
ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient();
XElement compactDataMessage = sdmxServiceClient.GetCompactData(queryMessage);
 WCF Service example:  
SDMXServiceClient client = new SDMXServiceClient();
var request = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <DataWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <And>
        <DataSet>FAS</DataSet>
        <Time>
          <StartTime>2010</StartTime>
          <EndTime>2015</EndTime>
        </Time>
        <Dimension id=""FREQ"">A</Dimension>
        <Dimension id=""INDICATOR"">FCMOA_NUM</Dimension>
        <!-- Geographical Outreach, Mobile Banking, Agent Outlets, active, Number of -->
        <Dimension id=""REF_AREA"">AF</Dimension>
        <!-- Afghanistan, Islamic Republic of -->
      </And>
    </DataWhere>
  </Query>
</QueryMessage>";

XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(request));
var message = Message.CreateMessage(MessageVersion.Soap11, "http://www.imf.org/SDMX/ISDMXService/GetCompactData", reader);
var responseMessage = client.GetCompactData(message);
var xmlReader = responseMessage.GetReaderAtBodyContents();
var result = xmlReader.ReadOuterXml();

1.4 GetMetadataStructure Method 


GetMetadataStructure method returns the metadata structure of the dataset in the SDMX-ML structure message for the given SDMX-ML query message.

C# SYNTAX

public XElement GetMetadataStructure(XElement queryMessage);

PARAMETERS

queryMessge

Type: System.Xml.Linq.XElement

An XML data, that represents the SDMX-ML query message

RETURN VALUE

Type: System.Xml.Linq.XElement

An XML data that represents the SDMX-ML metadata structure message.

EXAMPLES

The following code example creates simple SDMX metadata structure query and shows the use of GetMetadataStructure method.

 ASP.NET Web Service example:  

string query =
    @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <MetadataStructureWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <KeyFamily>FAS</KeyFamily>
    </MetadataStructureWhere>
  </Query>
</QueryMessage>";

XDocument queryMessageDocument = XDocument.Parse(query);
XElement queryMessage = queryMessageDocument.Root;
ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient();
XElement structureMessage = sdmxServiceClient.GetMetadataStructure(queryMessage);    
 WCF Service example:    
SDMXServiceClient client = new SDMXServiceClient();
string query = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <MetadataStructureWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <KeyFamily>FAS</KeyFamily>
    </MetadataStructureWhere>
  </Query>
</QueryMessage>"; 
var result = client.GetMetadataStructure(XElement.Parse(query));

1.5 GetGenericMetadata Method 


GetGenericMetadata method returns the SDMX-ML generic metadata message for the given SDMX-ML query message.


C# SYNTAX

public XElement GetGenericMetadata(XElement queryMessage);

PARAMETERS

queryMessage

Type: System.Xml.Linq.XElement

An XML data, that represents the SDMX-ML query message

RETURN VALUE

Type: System.Xml.Linq.XElement

An XML data that represents the SDMX-ML generic metadata message.

EXAMPLES

The following code example creates simple SDMX data query and shows the use of GetGenericMetadata method

 ASP.NET Web Service example:    

string query = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">   <Query>     <MetadataWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">       <And>         <DataSet>FAS</DataSet>         <Time>           <StartTime>2010</StartTime>           <EndTime>2015</EndTime>         </Time>         <Dimension id=""FREQ"">A</Dimension>         <Dimension id=""REF_AREA"">AF</Dimension>         <Dimension id=""REF_AREA"">AL</Dimension>         <Dimension id=""REF_AREA"">DZ</Dimension>         <Or>           <Dimension id=""INDICATOR"">FCMOA_NUM</Dimension>           <Dimension id=""INDICATOR"">FCMOR_NUM</Dimension>           <Dimension id=""INDICATOR"">FCAC_NUM</Dimension>           <Dimension id=""INDICATOR"">FCACL_NUM</Dimension>           <Dimension id=""INDICATOR"">FCBODCL_NUM</Dimension>         </Or>       </And>     </MetadataWhere>   </Query> </QueryMessage>";

XDocument queryMessageDocument = XDocument.Parse(query); XElement queryMessage = queryMessageDocument.Root; ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient(); XElement compactDataMessage = sdmxServiceClient.GetGenericMetadata(queryMessage);

WCF Service example:

SDMXServiceClient client = new SDMXServiceClient();
string query = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <MetadataWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <And>
        <DataSet>FAS</DataSet>
        <Time>
          <StartTime>2010</StartTime>
          <EndTime>2015</EndTime>
        </Time>
        <Dimension id=""FREQ"">A</Dimension>
        <Dimension id=""REF_AREA"">AF</Dimension>
        <Dimension id=""REF_AREA"">AL</Dimension>
        <Dimension id=""REF_AREA"">DZ</Dimension>
        <Or>
         <Dimension id=""INDICATOR"">FCMOA_NUM</Dimension>
          <Dimension id=""INDICATOR"">FCMOR_NUM</Dimension>
          <Dimension id=""INDICATOR"">FCAC_NUM</Dimension>
          <Dimension id=""INDICATOR"">FCACL_NUM</Dimension>
          <Dimension id=""INDICATOR"">FCBODCL_NUM</Dimension>
        </Or>
      </And>
    </MetadataWhere>
  </Query>
</QueryMessage>";
var result = client.GetGenericMetadata(XElement.Parse(query));

1.6 GetCodeList Method 


GetCodeList method returns the description of CodeLists


C# SYNTAX

public XElement GetCodeList(XElement queryMessage);

PARAMETERS

queryMessage

Type: System.Xml.Linq.XElement

An XML data, that represents the SDMX-ML query message

RETURN VALUE

Type: System.Xml.Linq.XElement

An XML data that represents the SDMX-ML codelist message.

EXAMPLES

The following code example creates simple SDMX data query and shows the use of GetCodeList method.

ASP.NET Web Service example:      

string query = 
@"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
    <Query>
        <CodelistWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
           <Or>
               <Codelist id=""CL_Indicator_FAS""/>
           </Or>
        </CodelistWhere>
    </Query>
</QueryMessage>";

XDocument queryMessageDocument = XDocument.Parse(query); XElement queryMessage = queryMessageDocument.Root; ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient(); XElement compactDataMessage = sdmxServiceClient.GetCodeList(queryMessage);

WCF Service example:
SDMXServiceClient client = new SDMXServiceClient();
string query = @"<QueryMessage xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"">
  <Query>
    <CodelistWhere xmlns=""http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query"">
      <Or>
        <Codelist id=""CL_Indicator_CPIS"" />
      </Or>
    </CodelistWhere>
  </Query>
</QueryMessage>";
var result = client.GetCodeList(XElement.Parse(query));

1.7 GetMaxSeriesInResult Method

GetMaxSeriesInResult method returns the maximum number of time series that can be returned by GetCompactData.

C# SYNTAX

public int GetMaxSeriesInResult();

RETURN VALUE

Type: System.Int32

A non-negative integer value that represents the maximum number of time series that can be returned by GetCompactData method.

A special value of 0 means GetCompactData method can return unlimited number of time series.

EXAMPLES

The following code example shows the use of GetMaxSeriesInResult method.

ASP.NET Web Service example:

ASMXSDMXServiceSoapClient sdmxServiceClient = new ASMXSDMXServiceSoapClient(); 
int limit = sdmxServiceClient.GetMaxSeriesInResult();

WCF Service example:

SDMXServiceClient client = new SDMXServiceClient(); var result = client.GetMaxSeriesInResult();

Help Documents and References

  1. Query: How to use it
  2. Search: How to use it?
  3. Export Data: How to Bulk Download
  4. Navigation: How to find a dataset from the Home page
  5. Query: How to find the indicator for which I want data?
  6. Query: How to select multiple indicators
  7. Query: How to select the countries for which I want data?
  8. Query: How to select time and frequencies for which I want data?
  9. Query: How to change the font and font size?
  10. Query: How to change the number of decimal places?
  11. Table: How to export data from Tables
  12. Query: How to change the units
  13. Query: How to export my Query table into Excel
  14. Query: How to save queries
  15. Query: How to retrieve longer historical data series for a dataset
  16. Search Tips
  17. Browser Compatibility
  18. Query: How to create a Pie chart
  19. Query: How to create a Rating chart
  20. Query: How to create a Table
  21. Query: How to create Stacked bar
  22. Query: How to create Stacked column
  23. Query: How to create Area
  24. Query: How to create Column
  25. Query: How to create Bar
  26. Query: How to create Line
  27. Query: How to create Spline
  28. Query: How to create Scatter chart
  29. Query: How to create Bubble chart
  30. Query: How to create Treemap
  31. Query: How to create Map
  32. Query: How to change database from the query tool
  33. How do I get the underlying data in a table or a chart?
  34. Finding Data using Concept Codes
  35. Data Services
  36. Using SDMX 2.0 Web Service
  37. Using SDMX 2.1 Web Service
  38. JSON RESTful Web Service
  39. SDMX 2.0 RESTFUL WEB SERVICE
  40. EZProxy: How to configure on the User side
  41. Table: How to select countries for which I want data
  42. Table: How to select indicators for which I want data
  43. IFS publication in PDF file – where to find
  44. Composition of Current Statistical Groups and Aggregates
  45. Bulk Download: How to extract and view data in Excel?
  46. Data services: how to get the code of a dataset and a list of all dimensions and elements?
  47. Workbook: How to show additional attributes (Country Name, Indicator Name, Database, etc.)?
  48. Workbook: How to add an attribute (Country, Time, Frequency, etc.) to a Series Tree?

Feedback and Knowledge Base