2.2.7.2.7 RetrieveServiceMetadata Request

The purpose of the RetrieveServiceMetadata Request is to enable a client to retrieve the conceptual schema definition language (CSDL) document, as specified in [MC-CSDL], describing the data model associated with the data service. AtomPub, as specified in [RFC5023], does not define the usage of an Entity Data Model, as specified in [MC-CSDL], with data services. As such, this request type is not based on any AtomPub-defined [RFC5023] request.

A RetrieveServiceMetadata Request MUST use the HTTP GET method and the URI specified by the client in the HTTP request line MUST be a valid data service URI, that identifies the $metadata endpoint of a data service, as specified in URI Syntax (section 2.2.3.1).

If the RetrieveServiceMetadata Request was successful, the response MUST have a 200 status code, as specified in [RFC2616], and the response body MUST be formatted as specified in Conceptual Schema Definition Language Document for Data Services (section 2.2.3.7.2). If the RetrieveServiceMetadata Request is not successful (for example, an error occurred while processing the request), the response MUST be formatted according to Error Response (section 2.2.8.1). The version number returned as the value of the DataServiceVersion response header MUST match the value of the DataServiceVersion attribute (section 2.2.3.7.2) in the returned EDMX [MC-EDMX] document.

The syntax of a RetrieveServiceMetadata Request is defined as follows:

 retrieveServiceMD-Req         = retrieveServiceMD-ReqLine
                                 retrieveServiceMD-ReqHeaders
                                 CRLF
  
 retrieveServiceMD-ReqLine     = "GET"
                                 SP serviceRootNoHost
                                 "/$metadata"
                                 retrieveServiceMD-QueryOps
                                 SP HTTP-Version
                                 CRLF
  
 retrieveServiceMD-ReqHeaders  = [DataServiceVersion]        ; see section 2.2.5.3
                                 [MaxDataServiceVersion]     ; see section 2.2.5.7
                                 *(HTTP-Header-Types)
  
 serviceRootNoHost = <the ServiceRoot section of the data service URI
                     beginning after  the definition of the host>
                      ; see section 2.2.3.2
  
 retrieveServiceMD-QueryOps    = ["?" customQueryOption *("&" customQueryOption)]
                                  ; see section 2.2.3.6

The syntax of a response to a successful RetrieveServiceMetadata Request is defined as follows:

 retrieveServiceMD-Resp       = Status-Line           ; see [RFC2616] section 6.1.1
                                retrieveServiceMD-RespHeaders
                                CRLF
                                retrieveServiceMD-RespBody
  
 retrieveServiceMD-RespHeaders= DataServiceVersion          ; see section 2.2.5.3
                                [Content-Type]              ; see section 2.2.5.2
                                *(HTTP-Header-Types)
  
 retrieveServiceMD-RespBody   = <CSDL-based document describing the data model
                                 defining the data service>
                                ; see section 2.2.3.7.2