Freigeben über


2.2.8.1.1 XML Error Response

This section defines an XML format for error messages that MUST be used in response payloads representing top-level errors, as specified in Error Response (section 2.2.8.1), when the server uses the default XML format. For examples of errors that are defined in JSON, see Error Response in [MS-ODATAJSON] section 2.1.28. For examples of errors that are defined in Verbose JSON, see Verbose JSON Error Response (section 2.2.8.1.2).

The structure of a top-level error message formatted as XML (application/xml) is defined in the following XSD Schema for Top-level Error Payloads Formatted by Using XML listing.

 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://schemas.microsoft.com/ado/2007/08/
    dataservices/metadata">
 <xs:element name="error">
  <xs:complexType>
   <xs:sequence>
     <xs:element name="code" type="xs:string" minOccurs="1"
     maxOccurs="1"/>
     <xs:element name="message" minOccurs="1" maxOccurs="1">
         <xs:complexType>
          <xs:simpleContent>
           <xs:extension base="xs:string">
            <xs:attribute ref="xml:lang" type="xs:string"/>
           </xs:extension>
          </xs:simpleContent>
         </xs:complexType>
     </xs:element>
     <xs:element name="innererror" type="xs:any"
     minOccurs="0" maxOccurs="1"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 </xs:schema>

Listing: XSD Schema for Top-level Error Payloads Formatted by Using XML

code: A data-service-defined string that serves as a substatus to the HTTP response code.

message: A human-readable string that describes the error.

innererror: An optional element that contains data-service–specific debugging information to assist a service implementer in determining the cause of an error.

Note The innererror element is to be used only in development environments. If it is present in a response from a production data service, it is not to include system internal information in order to guard against information disclosure security concerns.