ArticleDirectory
- Tenets of rest
- Mime Type
- Http operation success return Codes
- Simple Example
The recent use of WCF data service and WCF Ria service example published in the site http://dskit.codeplex.com, this series of articles on the WCF data service and WCF Ria Service Involved in the main aspects of the description, we hope that these frameworks can be used smoothly to improve development efficiency.
Several Basic Concepts in WCF Data Services
Tenets of rest
Method information is kept in the HTTP header, not in the body of the request.
Resources are expressed as "services" that clients consume.
The scoping information is kept in the URL. operations such as $ filter $ top $ skip
How the data relates to each other is expressed in ADO. NET data services by resource links according to the CSDL [specified in the Entity Data Model (EDM)]. A relationship link element such as <link href = "MERs ('alfki')/orders
No stateful messages are exchanged between resources
Mime Type
The service that is hosted can return the [MIME type during request] Using JSON and atom. The return type is as follows:
Mime |
Mime Type |
ApplicationProgramType |
JSON |
Application/JSON |
ASP. NET, Ajax, Silverlight |
Atom |
Application/atom + XML |
. Net clients, Silverlight, ASP. NET mashups |
Http operation success return Codes
Server return values defined for different operations based on the Rest definition:
Operation success code
Get 200 OK
Post 201 created
Put 204 no-content
Delete 204 no-content
Merge 204 no-content
Simple Example
Create a new web project in vs2010 and follow the steps below to create an example project
Create a Microsoft SQL example database, northwind
1. Add ado.net entity: select the original SQL example northwind database
2. Add WCF data services: wcfdataservice. SVC
3. configure access rules in wcfdataservice. SVC. CS:
Config. setentitysetaccessrule ("*", entitysetrights. allread );
Config. setserviceoperationaccessrule ("*", serviceoperationrights. All );
Config. dataservicebehavior. maxprotocolversion = dataserviceprotocolversion. V2;
The above section configures various parameters such as service accessibility, permissions, and behaviors. For details, refer to msdn. If it is not published on the Internet, the default configuration is also available.
4. Service Access test: You can access the service after creating a solution.
The following table lists several access instances.
Published service description HTTP: /localhost: 1206/wcfdataservice. svc/ |
Multiple entity instances HTTP: /localhost: 1206/wcfdataservice. svc/suppliers |
Single entity instance Http: // localhost: 1206/wcfdataservice. svc/suppliers (1) |
Object link navigation Http: // localhost: 1206/wcfdataservice. svc/suppliers (1)/products |
Project download from http://dskit.codeplex.com]
You can see that a data is published, queried, and written.CodeIt is very rare, but the functions provided are very powerful. We will continue to explain the query in the future.