Basics of WCF Data Services

Source: Internet
Author: User
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
    • HTTP Method

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 as <link href = "MERs ('alfki')/orders

    • Statelessness

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.