Export (0) Print
Expand All

AddressHeader.CreateAddressHeader Method (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.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public static AddressHeader CreateAddressHeader(
	string name,
	string ns,
	Object value,
	XmlObjectSerializer serializer
)

Parameters

name
Type: System.String
The name of the address header.
ns
Type: System.String
The namespace of the address header.
value
Type: System.Object
The information item for the address header.
serializer
Type: System.Runtime.Serialization.XmlObjectSerializer
The XmlObjectSerializer used to serialize the specified object in the value parameter.

Return Value

Type: System.ServiceModel.Channels.AddressHeader
The AddressHeader with the specified name and ns that contains the information item specified by value.

ExceptionCondition
ArgumentNullException

name or serializer is null or name.Length == 0.

The following example shows how to create an address header using this method.


			'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)()



//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>();



//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, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft