ServiceBehaviorAttribute.IgnoreExtensionDataObject 속성

정의

네트워크에서 알 수 없는 serialization 데이터를 보낼지 여부를 지정하는 값을 가져오거나 설정합니다.

public:
 property bool IgnoreExtensionDataObject { bool get(); void set(bool value); };
public bool IgnoreExtensionDataObject { get; set; }
member this.IgnoreExtensionDataObject : bool with get, set
Public Property IgnoreExtensionDataObject As Boolean

속성 값

Boolean

알 수 없는 serialization 데이터를 보내지 않으면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예제

다음 예제에서는 IgnoreExtensionDataObject의 사용과 IExtensibleDataObject의 구현을 보여 줍니다. 이 샘플에서는 IgnoreExtensionDataObjectfalse로 설정된 상태에서 클라이언트가 알고 있는 추가 데이터가 다시 클라이언트로 라운드트립됩니다.

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Xml;

namespace Microsoft.WCF.Documentation
{
  [ServiceContract(Namespace = "http://microsoft.wcf.documentation")]
  public interface ISampleService{
    [OperationContract]
    Person SampleMethod(Person personParam);
  }

  [DataContract(Name="OriginalPerson", Namespace="http://microsoft.wcf.documentation")]
  public class Person : IExtensibleDataObject
  {
    [DataMember]
    public string firstName;
    [DataMember]
    public string lastName;
    [DataMember]
    public string Message;
    [DataMember]
    public XmlNode[] Blob;

    #region IExtensibleDataObject Members
    private ExtensionDataObject data = null;

    public ExtensionDataObject ExtensionData
    {
      get
      {
        return this.data;
      }
      set
      {
        this.data = value;
      }
    }
    #endregion
  }

  [ServiceBehaviorAttribute(
    IgnoreExtensionDataObject=false,
    ValidateMustUnderstand=false
  )]
  class SampleService : ISampleService
  {
  #region ISampleService Members
    public Person SampleMethod(Person msg)
    {
      Console.WriteLine(msg.firstName);
      Console.WriteLine(msg.lastName);
      Console.WriteLine(msg.Message);

      msg.lastName = "First Name";
      msg.firstName = "Last Name";
      msg.Message = "This is the Reply message.";
        return msg;
    }
  #endregion
  }
}

설명

형식을 구현 하는 경우는 IExtensibleDataObject 인터페이스를 해당 형식으로 역직렬화 하는 동안 네트워크를 통해 제공 된 모든 추가 데이터에 대 한 알 수 없는 저장 합니다. 예를 들어, Person 형식에 FirstNameLastName이라는 멤버가 있으며 PhoneNumber라는 요소가 도착하면 이 요소가 저장됩니다. 나중에 이 형식을 serialize할 때 PhoneNumber를 다시 내보냅니다. 문제는에 대 한 스키마 Person 서비스만는에서 내보낸 FirstNameLastName이므로 스키마에 적합 하지 않은 인스턴스를 생성 하는 Windows Communication Foundation (WCF). 스키마를 엄격하게 준수하는 것이 중요하다면 IgnoreExtensionDataObjecttrue로 설정하여 이 다시 내보내기 동작을 해제할 수 있습니다.

와 상관 없이 IgnoreExtensionDataObject 설정을 WCF 항상 알려진된 데이터 처리 (모두 in 및 out) 하 고 추가 데이터가 들어올 때 예외를 throw 하지 않습니다. 애플리케이션 구성 파일에서 <dataContractSerializer> 요소를 사용하여 이 속성을 설정할 수도 있습니다.

적용 대상