다음을 통해 공유


데이터 서비스 구성(WCF Data Services)

WCF Data Services 를 사용하여 Open Data Protocol(OData) 피드를 노출하는 데이터 서비스를 만들 수 있습니다. 이러한 피드의 데이터는 다양한 데이터 원본에서 올 수 있습니다. WCF Data Services 에서는 데이터 제공자를 사용하여 이 데이터를 OData  피드로 노출시킵니다. 이러한 공급자에는 Entity Framework 공급자, 리플렉션 공급자 및 사용자 지정 데이터 서비스 공급자 인터페이스의 집합이 포함됩니다. 공급자 구현은 서비스에 대한 데이터 모델을 정의합니다. 자세한 내용은 데이터 서비스 공급자(WCF Data Services)를 참조하십시오.

WCF Data Services 에서 데이터 서비스는 데이터 서비스 형식이 데이터 모델의 엔터티 컨테이너인 DataService 클래스에서 상속하는 클래스입니다. 이 엔터티 컨테이너에는 데이터 모델의 엔터티 집합에 액세스하는 데 사용되는 IQueryable을 반환하는 속성이 하나 이상 들어 있습니다.

데이터 서비스의 동작은 DataServiceConfiguration 클래스의 멤버 및 DataServiceConfiguration 클래스의 DataServiceBehavior 속성에서 액세스되는 DataServiceBehavior 클래스의 멤버에 의해 정의됩니다. DataServiceConfiguration 클래스는 Northwind 데이터 서비스의 다음 구현과 같이 데이터 서비스에서 구현되는 InitializeService 메서드에 제공됩니다.

' This method is called only once to initialize service-wide policies.
Public Shared Sub InitializeService(ByVal config As DataServiceConfiguration)
    ' Set the access rules of feeds exposed by the data service, which is
    ' based on the requirements of client applications.
    config.SetEntitySetAccessRule("Customers", EntitySetRights.ReadSingle)
    config.SetEntitySetAccessRule("Employees", EntitySetRights.ReadSingle)
    config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead _
        And EntitySetRights.WriteAppend _
        And EntitySetRights.WriteMerge)
    config.SetEntitySetAccessRule("Order_Details", EntitySetRights.All)
    config.SetEntitySetAccessRule("Products", EntitySetRights.ReadMultiple)

    ' Set page size defaults for the data service.
    config.SetEntitySetPageSize("Orders", 20)
    config.SetEntitySetPageSize("Order_Details", 50)
    config.SetEntitySetPageSize("Products", 50)

    ' Paging requires v2 of the OData protocol.
    config.DataServiceBehavior.MaxProtocolVersion = _
        System.Data.Services.Common.DataServiceProtocolVersion.V2
End Sub
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
    // Set the access rules of feeds exposed by the data service, which is
    // based on the requirements of client applications.
    config.SetEntitySetAccessRule("Customers", EntitySetRights.ReadSingle);
    config.SetEntitySetAccessRule("Employees", EntitySetRights.ReadSingle);
    config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead 
        & EntitySetRights.WriteAppend
        & EntitySetRights.WriteMerge);
    config.SetEntitySetAccessRule("Order_Details", EntitySetRights.All);
    config.SetEntitySetAccessRule("Products", EntitySetRights.ReadMultiple);

    // Set page size defaults for the data service.
    config.SetEntitySetPageSize("Orders", 20);
    config.SetEntitySetPageSize("Order_Details", 50);
    config.SetEntitySetPageSize("Products", 50);

    // Paging requires v2 of the OData protocol.
    config.DataServiceBehavior.MaxProtocolVersion =
        System.Data.Services.Common.DataServiceProtocolVersion.V2;
}

데이터 서비스 구성 설정

DataServiceConfiguration 클래스를 사용하면 다음 데이터 서비스 동작을 지정할 수 있습니다.

멤버 동작

AcceptCountRequests

$count 경로 세그먼트와 $inlinecount 쿼리 옵션을 사용하여 데이터 서비스로 전송되는 개수 요청을 사용하지 않도록 설정할 수 있습니다. 자세한 내용은 OData: URI 규칙을 참조하십시오.

AcceptProjectionRequests

$select 쿼리 옵션을 사용하여 데이터 서비스로 전송되는 데이터 프로젝션 지원을 사용하지 않도록 설정할 수 있습니다. 자세한 내용은 OData: URI 규칙을 참조하십시오.

EnableTypeAccess

IDataServiceMetadataProvider 인터페이스를 사용하여 정의된 동적 메타데이터 공급자의 메타데이터에 데이터 형식을 노출할 수 있습니다.

EnableTypeConversion

데이터 서비스 런타임이 페이로드에 포함된 형식을 요청에 지정된 실제 속성 형식으로 변환해야 하는지 여부를 지정할 수 있습니다.

InvokeInterceptorsOnLinkDelete

두 엔터티 간의 관계 링크가 삭제될 때 관련 엔터티에 대해 등록된 변경 인터셉터를 호출할지 여부를 지정할 수 있습니다.

MaxBatchCount

단일 일괄 처리에서 허용되는 변경 집합과 쿼리 작업 수를 제한할 수 있습니다. 자세한 내용은 OData: 일괄 처리일괄 처리 작업(WCF Data Services)을 참조하십시오.

MaxChangesetCount

단일 변경 집합에 포함할 수 있는 변경 수를 제한할 수 있습니다. 자세한 내용은 방법: 데이터 서비스 결과의 페이징 사용(WCF Data Services)을 참조하십시오.

MaxExpandCount

$expand 쿼리 연산자로 단일 요청에 포함할 수 있는 관련 엔터티 수를 제한하여 응답 크기를 제한할 수 있습니다. 자세한 내용은 다음 항목을 참조하십시오. OData: URI 규칙지연된 콘텐츠 로드(WCF Data Services)를 참조하십시오.

MaxExpandDepth

$expand 쿼리 연산자로 단일 요청에 포함할 수 있는 관련 엔터티 그래프 수를 제한하여 응답 크기를 제한할 수 있습니다. 자세한 내용은 다음 항목을 참조하십시오. OData: URI 규칙지연된 콘텐츠 로드(WCF Data Services)를 참조하십시오.

MaxObjectCountOnInsert

단일 POST 요청에 포함할 수 있는 삽입할 엔터티 수를 제한할 수 있습니다.

MaxProtocolVersion

데이터 서비스에 사용되는 Atom 프로토콜의 버전을 정의합니다. MaxProtocolVersion 값을 DataServiceProtocolVersion의 최대값보다 작은 값으로 설정하면 데이터 서비스에 액세스하는 클라이언트가 WCF Data Services 의 최신 기능을 사용할 수 없습니다. 자세한 내용은 다음 항목을 참조하십시오. 여러 버전의 WCF Data Services 작업 작업을 참조하십시오.

MaxResultsPerCollection

데이터 피드로 반환되는 각 엔터티 집합의 엔터티 수를 제한하여 응답 크기를 제한할 수 있습니다.

RegisterKnownType

데이터 서비스에서 인식하는 형식 목록에 데이터 형식을 추가합니다.

SetEntitySetAccessRule

데이터 서비스에서 사용할 수 있는 엔터티 집합 리소스에 대한 액세스 권한을 설정합니다. 이름 매개 변수에 별표(*) 값을 제공하여 나머지 모든 엔터티 집합에 대한 액세스를 같은 수준으로 설정할 수 있습니다. 클라이언트 응용 프로그램에 필요한 데이터 서비스 리소스에 대한 최소 권한 액세스를 제공하도록 엔터티 집합에 대한 액세스를 설정하는 것이 좋습니다. 자세한 내용은 WCF Data Services에 보안 설정을 참조하십시오. 지정된 URI 및 HTTP 동작에 필요한 최소 액세스 권한의 예제는 Minimum Resource Access Requirements 단원의 표를 참조하십시오.

SetEntitySetPageSize

엔터티 집합 리소스의 최대 페이지 크기를 설정합니다. 자세한 내용은 방법: 데이터 서비스 결과의 페이징 사용(WCF Data Services)을 참조하십시오.

SetServiceOperationAccessRule

데이터 서비스에 정의된 서비스 작업에 대한 액세스 권한을 설정합니다. 자세한 내용은 서비스 작업(WCF Data Services)을 참조하십시오. 이름 매개 변수에 별표(*) 값을 제공하여 모든 서비스 작업에 대한 액세스를 같은 수준으로 설정할 수 있습니다. 클라이언트 응용 프로그램에 필요한 데이터 서비스 리소스에 대한 최소 권한 액세스를 제공하도록 서비스 작업에 대한 액세스를 설정하는 것이 좋습니다. 자세한 내용은 WCF Data Services에 보안 설정을 참조하십시오.

UseVerboseErrors

이 구성 속성을 사용하면 오류 응답 메시지에 더 많은 정보가 반환되므로 데이터 서비스 문제를 보다 쉽게 해결할 수 있습니다. 이 옵션은 프로덕션 환경에 사용하기에 적합하지 않습니다. 자세한 내용은 WCF Data Services 개발 및 배포를 참조하십시오.

최소 리소스 액세스 요구 사항

다음 표에서는 특정 작업을 수행하기 위해 부여되어야 하는 최소 엔터티 집합 권한에 대해 설명합니다. 경로 예제는 퀵 스타트를 완료하면 만들어지는 Northwind 데이터 서비스를 기반으로 합니다. EntitySetRights 열거형과 ServiceOperationRights 열거형이 FlagsAttribute를 사용하여 정의되기 때문에 논리 OR 연산자를 사용하여 단일 엔터티 집합이나 작업에 여러 사용 권한을 지정할 수 있습니다. 자세한 내용은 방법: 데이터 서비스에 액세스할 수 있도록 설정(WCF Data Services)을 참조하십시오.

경로/동작 GET DELETE MERGE POST PUT

/Customers

ReadMultiple

지원 안 함

지원 안 함

WriteAppend

지원 안 함

/Customers('ALFKI')

ReadSingle

ReadSingleWriteDelete

ReadSingleWriteMerge

n/a

ReadSingleWriteReplace

/Customers('ALFKI')/Orders

Customers: ReadSingle

-및-

Orders: ReadMultiple

지원 안 함

지원 안 함

Customers: ReadSingleWriteMerge 또는 WriteReplace

-및-

Orders :WriteAppend

지원 안 함

/Customers('ALFKI')/Orders(10643)

Customers: ReadSingle

-및-

Orders: ReadSingle

Customers: ReadSingle

-및-

Orders: ReadSingleWriteDelete

Customers: ReadSingle

-및-

Orders: ReadSingleWriteMerge

지원 안 함

Customers: ReadSingle

-및-

Orders: ReadSingleWriteReplace

/Orders(10643)/Customer

Customers: ReadSingle

-및-

Orders: ReadSingle

Customers: ReadSingleWriteDelete

-및-

Orders: ReadSingle

Customers: ReadSingleWriteMerge

-및-

Orders: ReadSingle

Customers: WriteAppend

-및-

Orders: WriteAppendReadSingle

지원 안 함

/Customers('ALFKI')/$links/Orders

Customers: ReadSingle

-및-

Orders: ReadMultiple

지원 안 함

지원 안 함

Customers: ReadSingleWriteMerge 또는 WriteReplace

-및-

Orders: ReadSingle

지원 안 함

/Customers('ALFKI')/$links/Orders(10643)

Customers: ReadSingle

-및-

Orders: ReadSingle

Customers: ReadSingleWriteMerge 또는 WriteReplace

-및-

Orders: ReadSingle

지원 안 함

지원 안 함

지원 안 함

/Orders(10643)/$links/Customer

Customers: ReadSingle

-및-

Orders: ReadSingle

Orders: ReadSingleWriteMerge 또는 WriteReplace

Customers: ReadSingle

-및-

Orders: ReadSingleWriteMerge

지원 안 함

Customers: ReadSingle;

-및-

Orders: ReadSingleWriteReplace

/Customers/$count

ReadMultiple

지원 안 함

지원 안 함

지원 안 함

지원 안 함

/Customers('ALFKI')/ContactName

ReadSingle

지원 안 함

WriteMerge

지원 안 함

WriteReplace

/Customers('ALFKI')/Address/StreetAddress/$value 1

ReadSingle

WriteDelete

지원 안 함

지원 안 함

지원 안 함

/Customers('ALFKI')/ContactName/$value

ReadSingle

ReadSingleWriteDelete

WriteMerge

지원 안 함

WriteReplace

/Customers('ALFKI')/$value 2

ReadSingle

지원 안 함

지원 안 함

지원 안 함

WriteReplace

/Customers?$select=Orders/*&$expand=Orders

Customers: ReadSingle

-및-

Orders: ReadMultiple

지원 안 함

지원 안 함

Customers: WriteAppend

지원 안 함

/Customers('ALFKI')?$select=Orders/*&$expand=Orders

Customers: ReadSingle

-및-

Orders: ReadMultiple

지원 안 함

지원 안 함

지원 안 함

지원 안 함

1 이 예제에서 AddressStreetAddress라는 속성이 있는 Customers 엔터티의 복합 형식 속성을 나타냅니다. Northwind 데이터 서비스에서 사용되는 모델은 이 복합 형식을 명시적으로 정의하지 않습니다. 데이터 모델이 Entity Framework 공급자를 사용하여 정의된 경우 엔터티 데이터 모델 도구를 사용하여 이러한 복합 형식을 정의할 수 있습니다. 자세한 내용은 How to: Create and Modify Complex Types (Entity Data Model Tools)을 참조하십시오.

2 이 URI는 BLOB(Binary Large Object)를 반환하는 속성이 미디어 링크 항목인 엔터티(이 경우에는 Customers)에 속한 미디어 리소스로 정의된 경우 지원됩니다. 자세한 내용은 스트리밍 공급자(WCF Data Services)를 참조하십시오.

버전 관리 요구 사항

다음 데이터 서비스 구성이 동작하려면 OData 프로토콜 버전 2 이상이 필요합니다.

  • 계산 요청 지원

  • 프로젝션의 $select 쿼리 옵션 지원

자세한 내용은 여러 버전의 WCF Data Services 작업을 참조하십시오.

참고 항목

개념

데이터 서비스 호스팅(WCF Data Services)

기타 리소스

WCF Data Services 정의