The recently used WCF Data Service and WCF RIA Service examples are published on the website http://dskit.codeplex.com. This series of articles describe the main aspects involved in WCF Data Service and WCF RIA Service. We hope that through these contents, 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.
- Resource based
Resources are expressed as “services” that clients consume.
- Addressability
The scoping information is kept in the URL. Operations such as $filter $top $skip
- Relationships
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 <link href=”Customers(‘ALFKI’)/Orders
- Statelessness
No stateful messages are exchanged between resources
MIME type
you can use JSON or ATOM to return the MIME type in the request as follows:
HTTP Operation Success Return Codes
according to the definition of REST, the server return values defined for different operations are as follows:
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. Follow these steps to create an example project:
build Microsoft SQL example database NorthWind
1. Add Ado.net Entity: Select the initial 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 preceding section is used to configure various parameters such as service accessibility, permissions, and behaviors. For more information, see MSDN. If it is not published on the Internet, the default configuration can also be used.
4. Service access test: you can access the service after you Build the solution.
The following table lists several accessed instances.
[The project can be downloaded from http://dskit.codeplex.com]]
as you can see, there are very few codes written for publishing a data and processing it, but the functions provided are very powerful. We will continue to explain the query and so on in the future.
Start Building Today with a Free Trial to 50+ Products
Learn and experience the power of Alibaba Cloud.
Sign Up Now