Skip to content

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();

Feedback and Knowledge Base