Daten, die keine Entitäten sind, mit dem REST-Datenservice abrufen

Mit dem REST-Datenservice können Sie mehr als nur Entitäten, wie z. B. Entitätssammlungen und Eigenschaften, abrufen.

Entitätssammlungen abrufen

Eine RetrieveEntitySet-Anforderung kann von einem Client verwendet werden, um eine Gruppe von eXtreme-Scale-Entitäten abzurufen. Die Entitäten werden als Atom Feed Document oder JSON-Feldgruppe in den Nutzdaten der Antwort dargestellt. Weitere Einzelheiten zu dem in WCF Data Services definierten Protokoll "RetrieveEntitySet" finden Sie auf der Webseite MSDN: RetrieveEntitySet Request.

Die folgende RetrieveEntitySet-Beispielanforderung ruft alle Order-Entitäten ab, die der Entität "Customer('IBM')" zugeordnet sind. Hier werden nur die Bestellungen (Order) 5000 und 5001 gezeigt.

AtomPub

  • Methode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('IBM')/orders
  • Anforderungsheader: Accept: application/atom+xml
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: application/atom+xml
  • Nutzdaten der Antwort:
    <?xml version="1.0" encoding="utf-8"?>
    <feed xml:base = "http://localhost:8080/wxsrestservice/restservice"
    			xmlns:d = "http://schemas.microsoft.com/ado/2007/08/dataservices"
    			xmlns:m = "http://schemas.microsoft.com/ado/2007/08/dataservices/
    			metadata" xmlns =	"http://www.w3.org/2005/Atom">
        <title type = "text">Order</title>
        <id>http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/
    					Order</id>
        <updated>2009-12-16T22:53:09.062Z</updated>
        <link rel = "self" title = "Order" href = "Order"/>
        <entry>
            <category term = "NorthwindGridModel.Order" scheme = "http://
    						schemas.microsoft.com/
    						ado/2007/08/dataservices/scheme"/>
            <id>http://localhost:8080/wxsrestservice/restservice/
    						NorthwindGrid/Order(orderId=5000,customer_customerId=
    						'IBM')</id>
            <title type = "text"/>
            <updated>2009-12-16T22:53:09.062Z</updated>
            <author>
                <name />
            </author>
            <link rel = "edit" title = "Order" href = "Order(orderId=5000,
    						customer_customerId='IBM')"/>
            <link rel = "http://schemas.microsoft.com/ado/2007/08/
    						dataservices/related/customer"
    						type =	"application/atom+xml;type=entry"
    						title = "customer" href = "Order(orderId=5000,
    						customer_customerId='IBM')/customer"/>
            <link rel = "http://schemas.microsoft.com/ado/2007/08/
    						dataservices/related/orderDetails"
    						type = "application/atom+xml;type=feed"
    						title = "orderDetails" href = "Order(orderId=5000,
    									customer_customerId='IBM')/
    								orderDetails"/>
            <content type="application/xml">
                <m:properties>
                    <d:orderId m:type = "Edm.Int32">5000</d:orderId>
                    <d:customer_customerId>IBM</d:customer_customerId>
                    <d:orderDate m:type = "Edm.DateTime">2009-12-16T19:
    										46:29.562</d:orderDate>
                    <d:shipCity>Rochester</d:shipCity>
                    <d:shipCountry m:null = "true"/>
                    <d:version m:type = "Edm.Int32">0</d:version>
                </m:properties>
            </content>
        </entry>
        <entry>
            <category term = "NorthwindGridModel.Order" scheme = "http://
    						schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
            <id>http://localhost:8080/wxsrestservice/restservice/
    						NorthwindGrid/Order(orderId=5001,	customer_customerId='IBM')
    				</id>
            <title type = "text"/>
            <updated>2009-12-16T22:53:09.062Z</updated>
            <author>
                <name />
            </author>
            <link rel = "edit" title = "Order" href = "Order(orderId=5001,
    							customer_customerId='IBM')"/>
            <link rel = "http://schemas.microsoft.com/ado/2007/08/
    							dataservices/related/customer"
    							type =	"application/atom+xml;type=entry"
    							title = "customer" href = "Order(orderId=5001,
    									customer_customerId='IBM')/customer"/>
            <link rel = "http://schemas.microsoft.com/ado/2007/08/
    									dataservices/related/orderDetails"
    							type = "application/atom+xml;type=feed"
    							title = "orderDetails" href = "Order(orderId=5001,
    									customer_customerId='IBM')/orderDetails"/>
            <content type="application/xml">
                <m:properties>
                    <d:orderId m:type = "Edm.Int32">5001</d:orderId>
                    <d:customer_customerId>IBM</d:customer_customerId>
                    <d:orderDate m:type = "Edm.DateTime">2009-12-16T19:50:
    										11.125</d:orderDate>
                    <d:shipCity>Rochester</d:shipCity>
                    <d:shipCountry m:null = "true"/>
                    <d:version m:type = "Edm.Int32">0</d:version>
                </m:properties>
            </content>
        </entry>
    </feed>
  • Antwortcode: 200 OK

JSON

  • Methode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('IBM')/orders
  • Anforderungsheader: Accept: application/json
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: application/json
  • Nutzdaten der Antwort:
    {"d":[{"__metadata":{"uri":"http://localhost:8080/wxsrestservice/
    			restservice/NorthwindGrid/Order(orderId=5000,
    			customer_customerId='IBM')",
    "type":"NorthwindGridModel.Order"},
    "orderId":5000,
    "customer_customerId":"IBM",
    "orderDate":"\/Date(1260992789562)\/",
    "shipCity":"Rochester",
    "shipCountry":null,
    "version":0,
    "customer":{"__deferred":{"uri":"http://localhost:8080/
    			wxsrestservice/restservice/NorthwindGrid/Order(orderId=
    			5000,customer_customerId='IBM')/customer"}},
    "orderDetails":{"__deferred":{"uri":"http://localhost:8080/
    			wxsrestservice/restservice/NorthwindGrid/Order(orderId=
    			5000,customer_customerId='IBM')/orderDetails"}}},
    {"__metadata":{"uri":"http://localhost:8080/wxsrestservice/
    					restservice/NorthwindGrid/
    			Order(orderId=5001,
    			customer_customerId='IBM')",
    "type":"NorthwindGridModel.Order"},
    "orderId":5001,
    "customer_customerId":"IBM",
    "orderDate":"\/Date(1260993011125)\/",
    "shipCity":"Rochester",
    "shipCountry":null,
    "version":0,
    "customer":{"__deferred":{"uri":"http://localhost:8080/
    			wxsrestservice/restservice/NorthwindGrid/Order(orderId=
    			5001,customer_customerId='IBM')/customer"}},
    "orderDetails":{"__deferred":{"uri":"http://localhost:8080/
    			wxsrestservice/restservice/NorthwindGrid/Order(orderId=
    			5001,customer_customerId='IBM')/orderDetails"}}}]}
  • Antwortcode: 200 OK

Eigenschaft abrufen

Eine RetrievePrimitiveProperty-Anforderung kann verwendet werden, um den Wert einer Eigenschaft einer eXtreme-Scale-Entitätsinstanz abzurufen. Der Eigenschaftswert wird im XML-Format für AtomPub-Anforderungen und als JSON-Objekt für JSON-Anforderungen in den Nutzdaten der Antwort dargestellt. Weitere Einzelheiten zur RetrievePrimitiveProperty-Anforderung finden Sie auf der Seite MSDN: RetrievePrimitiveProperty Request.

Die folgende RetrievePrimitiveProperty-Beispielanforderung ruft die Eigenschaft "contactName" der Entität "Customer('IBM')" ab.

AtomPub

  • Methode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('IBM')/contactName
  • Anforderungsheader: Accept: application/xml
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: application/atom+xml
  • Nutzdaten der Antwort:
    <contactName xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
        John Doe
    </contactName>
  • Antwortcode: 200 OK

JSON

  • Methode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('IBM')/contactName
  • Anforderungsheader: Accept: application/json
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: application/json
  • Nutzdaten der Antwort: {"d":{"contactName":"John Doe"}}
  • Antwortcode: 200 OK

Eigenschaftswert abrufen

Eine RetrieveValue-Anforderung kann verwendet werden, um den unaufbereiteten Wert einer Eigenschaft einer eXtreme-Scale-Entitätsinstanz abzurufen. Der Eigenschaftswert wird als unaufbereiteter Wert in den Nutzdaten der Antwort dargestellt. Wenn die Entität einen der folgenden Typen hat, ist der Medientyp der Antwort "text/plain". Andernfalls ist der Medientyp der Antwort "application/octet-stream". Diese Typen sind:
  • Primitive Java-Typen und zugehörige Wrapper
  • java.lang.String
  • byte[]
  • Byte[]
  • char[]
  • Character[]
  • enums
  • java.math.BigInteger
  • java.math.BigDecimal
  • java.util.Date
  • java.util.Calendar
  • java.sql.Date
  • java.sql.Time
  • java.sql.Timestamp

Weitere Einzelheiten zur RetrieveValue-Anforderung finden Sie auf der Webseite MSDN: RetrieveValue Request.

Die folgende RetrieveValue-Beispielanforderung ruft den unaufbereiteten Wert der Eigenschaft "contactName" der Entität "Customer('IBM')" ab.

  • Anforderungsmethode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Customer('IBM')/contactName/$value
  • Anforderungsheader: Accept: text/plain
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: text/plain
  • Nutzdaten der Antwort: John Doe
  • Antwortcode: 200 OK

Verbindung abrufen

Eine RetrieveLink-Anforderung kann verwendet werden, um die Verbindungen abzurufen, die eine :1-Assoziation oder :N-Assoziation darstellen. Bei der :1-Assoziation verläuft die Verbindung von einer eXtreme-Scale-Entitätsinstanz zu einer anderen, und die Verbindung wird in den Nutzdaten der Anforderungen dargestellt. Bei der :N-Assoziation verlaufen die Verbindungen von einer eXtreme-Scale-Entitätsinstanz zu allen anderen in einer bestimmten eXtreme-Scale-Entitätssammlung, und die Antwort wird als Gruppe von Verbindungen in den Nutzdaten der Antwort dargestellt. Weitere Einzelheiten zur RetrieveLink-Anforderung finden Sie auf der Webseite MSDN: RetrieveLink Request.

Im Folgenden sehen Sie ein RetrieveLink-Beispielanforderung. In diesem Beispiel wird die Assoziation zwischen der Entität "Order(orderId=5000,customer_customerId='IBM')" und dem zugehörigen Customer (Kunde) abgerufen. Die Antwort enthält den URI der Entität "Customer".

AtomPub

  • Methode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Order(orderId=5000,customer_customerId='IBM')/$links/customer
  • Anforderungsheader: Accept: application/xml
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: application/xml
  • Nutzdaten der Antwort:
    <?xml version="1.0" encoding="utf-8"?>
    <uri>http://localhost:8080/wxsrestservice/restservice/
    			NorthwindGrid/Customer('IBM')</uri>
  • Antwortcode: 200 OK

JSON

  • Methode: GET
  • Anforderungs-URI: http://localhost:8080/wxsrestservice/restservice/NorthwindGrid/Order(orderId=5000,customer_customerId='IBM')/$links/customer
  • Anforderungsheader: Accept: application/json
  • Nutzdaten der Anforderung: Ohne
  • Antwortheader: Content-Type: application/json
  • Nutzdaten der Antwort: {"d":{"uri":"http:\/\/localhost:8080\/wxsrestservice\/restservice\/NorthwindGrid\/Customer('IBM')"}}

Servicemetadaten abrufen

Eine RetrieveServiceMetadata-Anforderung kann verwendet werden, um das CSDL-Dokument (Conceptual Schema Definition Language) abzurufen, in dem das Datenmodell beschrieben ist, das dem REST-Datenservice von eXtreme Scale zugeordnet ist. Weitere Einzelheiten zur RetrieveServiceMetadata-Anforderung finden Sie auf der Webseite MSDN: RetrieveServiceMetadata Request.

Servicedokument abrufen

Eine RetrieveServiceDocument-Anforderung kann verwendet werden, um das Servicedokument abzurufen, in dem die Sammlung der vom REST-Datenservice von eXtreme Scale bereitgestellten Ressourcen beschrieben ist. Weitere Einzelheiten zur RetrieveServiceDocument-Anforderung finden Sie auf der Webseite MSDN: RetrieveServiceDocument Request.