Export (0) Print
Expand All

AddressHeader Class

Represents a header that encapsulates an address information item used to identify or interact with an endpoint.

System.Object
  System.ServiceModel.Channels.AddressHeader

Namespace:  System.ServiceModel.Channels
Assemblies:   System.ServiceModel.Primitives (in System.ServiceModel.Primitives.dll)
  System.ServiceModel (in System.ServiceModel.dll)

public abstract class AddressHeader

The AddressHeader type exposes the following members.

  NameDescription
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsAddressHeaderInitializes a new instance of the AddressHeader class.
Top

  NameDescription
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNameWhen implemented, gets the name of the address header.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNamespaceWhen implemented, gets the namespace of the address header.
Top

  NameDescription
Public methodStatic memberCreateAddressHeader(Object)Creates a new instance of the AddressHeader class with a specified value.
Public methodStatic memberCreateAddressHeader(Object, XmlObjectSerializer)Creates a new instance of the AddressHeader class using a specified formatter to serialize the information item from a specified object.
Public methodStatic memberSupported by Portable Class LibrarySupported in .NET for Windows Store appsCreateAddressHeader(String, String, Object)Creates a new instance of the AddressHeader class with a specified value, name and namespace.
Public methodStatic memberSupported by Portable Class LibrarySupported in .NET for Windows Store appsCreateAddressHeader(String, String, Object, XmlObjectSerializer)Creates a new instance of the AddressHeader class with a specified name and namespace that uses a specified formatter to serialize the information item from a specified object.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEqualsDetermines whether the information item in a specified object is equal to the object contained in the current address header. (Overrides Object.Equals(Object).)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetAddressHeaderReaderReturns an XML reader that can serialize the current address header object.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeProvides a unique hash code for an address header. (Overrides Object.GetHashCode().)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetValue<T>()Deserializes the information item from the current address header to an object of a specified type.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetValue<T>(XmlObjectSerializer)Deserializes the information item from the current address header to an object of a specified type that uses a specified formatter to serialize this information.
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsOnWriteAddressHeaderContentsWhen overridden in a derived class, is invoked when the address header contents are written to a stream or file.
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsOnWriteStartAddressHeaderWhen overridden in a derived class, is invoked when the address header contents begin to be written to a stream or file.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToMessageHeaderWraps the address header as a message header.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsWriteAddressHeader(XmlDictionaryWriter)Writes the address header to a stream or file using a specified XmlDictionaryWriter.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsWriteAddressHeader(XmlWriter)Writes the address header to a stream or file using a specified XmlWriter.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsWriteAddressHeaderContentsWrites the address header contents to a stream or file.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsWriteStartAddressHeaderStarts to write the address header contents to a stream or file.
Top

An AddressHeader is characterized by a name and namespace and has a value that contains optional information used to identify or interact with an endpoint. The name can be accessed by the Name property and the namespace by the Namespace property.

The following example shows how to create address headers, access their properties, add them to a service endpoint and host the service using the endpoint.


			' Name property 
			Dim addressHeaderWithName As AddressHeader = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1)
			Dim addressHeaderName As String = addressHeaderWithName.Name

			'Put snippet here. 
			' Namespace property 
			Dim addressHeaderWithNS As AddressHeader = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1)
			Dim addressHeaderNS As String = addressHeaderWithNS.Namespace 

			' Obsolete 

			' Obsolete 

			' Create address headers for special services and add them to an array 
			Dim addressHeader1 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1)
			Dim addressHeader2 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2)
			Dim addressHeaders() As AddressHeader = { addressHeader1, addressHeader2 }

			' Endpoint address constructor with URI and address headers 
			Dim endpointAddressWithHeaders As New EndpointAddress(New Uri("http://localhost/silverlightsamples/service1"), addressHeaders)

			' Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True. 
			Dim addressHeaderCollection As AddressHeaderCollection = endpointAddressWithHeaders.Headers
			Dim boolHeaders As Boolean = addressHeaderCollection.Contains(addressHeader1)

			'Create address headers with XmlObjectSerializer specified 
			Dim serializer As XmlObjectSerializer = New DataContractSerializer(GetType(Integer))
			Dim addressHeaderWithObjSer As AddressHeader = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer)
			Dim value As Integer = addressHeaderWithObjSer.GetValue(Of Integer)()

            // Name property
            AddressHeader addressHeaderWithName = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1);
            string addressHeaderName = addressHeaderWithName.Name;

            //Put snippet here. 
            // Namespace property
            AddressHeader addressHeaderWithNS = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1);
            string addressHeaderNS = addressHeaderWithNS.Namespace;

            // Obsolete 

            // Obsolete 

            // Create address headers for special services and add them to an array
            AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1);
            AddressHeader addressHeader2 = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2);
            AddressHeader[] addressHeaders = new AddressHeader[2] { addressHeader1, addressHeader2 };

            // Endpoint address constructor with URI and address headers
            EndpointAddress endpointAddressWithHeaders = new EndpointAddress(
                new Uri("http://localhost/silverlightsamples/service1"), addressHeaders
                );

            // Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
            AddressHeaderCollection addressHeaderCollection = endpointAddressWithHeaders.Headers;
            bool boolHeaders = addressHeaderCollection.Contains(addressHeader1);

            //Create address headers with XmlObjectSerializer specified
            XmlObjectSerializer serializer = new DataContractSerializer(typeof(int));
            AddressHeader addressHeaderWithObjSer = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer);
            int value = addressHeaderWithObjSer.GetValue<int>();

            // Name property
            AddressHeader addressHeaderWithName = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1);
            string addressHeaderName = addressHeaderWithName.Name;

            //Put snippet here. 
            // Namespace property
            AddressHeader addressHeaderWithNS = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1);
            string addressHeaderNS = addressHeaderWithNS.Namespace;

            // Obsolete 

            // Obsolete 

            // Create address headers for special services and add them to an array
            AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("specialservice1", "http://localhost:8000/service", 1);
            AddressHeader addressHeader2 = AddressHeader.CreateAddressHeader("specialservice2", "http://localhost:8000/service", 2);
            AddressHeader[] addressHeaders = new AddressHeader[2] { addressHeader1, addressHeader2 };

            // Endpoint address constructor with URI and address headers
            EndpointAddress endpointAddressWithHeaders = new EndpointAddress(
                new Uri("http://localhost/silverlightsamples/service1"), addressHeaders
                );

            // Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
            AddressHeaderCollection addressHeaderCollection = endpointAddressWithHeaders.Headers;
            bool boolHeaders = addressHeaderCollection.Contains(addressHeader1);

            //Create address headers with XmlObjectSerializer specified
            XmlObjectSerializer serializer = new DataContractSerializer(typeof(int));
            AddressHeader addressHeaderWithObjSer = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service", 1, serializer);
            int value = addressHeaderWithObjSer.GetValue<int>();

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft