Freigeben über


AddressHeader.CreateAddressHeader Methode

Definition

Erstellt eine neue Instanz der AddressHeader-Klasse.

Überlädt

CreateAddressHeader(Object)

Erstellt eine neue Instanz der AddressHeader-Klasse mit einem festgelegten Wert.

CreateAddressHeader(Object, XmlObjectSerializer)

Erstellt eine neue Instanz der AddressHeader-Klasse mithilfe eines festgelegten Formatierers für die Serialisierung des Informationselements aus einem festgelegten Objekt.

CreateAddressHeader(String, String, Object)

Erstellt eine neue Instanz der AddressHeader-Klasse mit einem festgelegten Wert, dem Namen und Namespace.

CreateAddressHeader(String, String, Object, XmlObjectSerializer)

Erstellt eine neue Instanz der AddressHeader-Klasse mit festgelegtem Namen und Namespace, die einen festgelegten Formatierer für die Serialisierung des Informationselements aus einem festgelegten Objekt verwendet.

Hinweise

Das Objekt, das das Informationselement enthält, wird durch ein XmlObjectSerializer-Objekt in den Adressheader serialisiert.

CreateAddressHeader(Object)

Erstellt eine neue Instanz der AddressHeader-Klasse mit einem festgelegten Wert.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::Object ^ value);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (object value);
static member CreateAddressHeader : obj -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (value As Object) As AddressHeader

Parameter

value
Object

Das Informationselement für den Adressheader.

Gibt zurück

AddressHeader

Der AddressHeader, der das durch den value-Parameter festgelegte Informationselement enthält.

Beispiele

Das folgende Beispiel zeigt, wie ein Adressheader mit dieser Methode erstellt wird.

// Obsolete
// Obsolete
' Obsolete
' Obsolete

Gilt für

CreateAddressHeader(Object, XmlObjectSerializer)

Erstellt eine neue Instanz der AddressHeader-Klasse mithilfe eines festgelegten Formatierers für die Serialisierung des Informationselements aus einem festgelegten Objekt.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::Object ^ value, System::Runtime::Serialization::XmlObjectSerializer ^ serializer);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (object value, System.Runtime.Serialization.XmlObjectSerializer serializer);
static member CreateAddressHeader : obj * System.Runtime.Serialization.XmlObjectSerializer -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (value As Object, serializer As XmlObjectSerializer) As AddressHeader

Parameter

value
Object

Das Informationselement für den Adressheader.

serializer
XmlObjectSerializer

Der XmlObjectSerializer, der verwendet wird, um das angegebene Objekt im value-Parameter zu serialisieren.

Gibt zurück

AddressHeader

Der AddressHeader, der das durch den Wertparameter festgelegte Informationselement enthält.

Ausnahmen

formatter ist null.

Beispiele

Das folgende Beispiel zeigt, wie ein Adressheader mit dieser Methode erstellt wird.

// Obsolete
// Obsolete
' Obsolete
' Obsolete

Gilt für

CreateAddressHeader(String, String, Object)

Erstellt eine neue Instanz der AddressHeader-Klasse mit einem festgelegten Wert, dem Namen und Namespace.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::String ^ name, System::String ^ ns, System::Object ^ value);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (string name, string ns, object value);
static member CreateAddressHeader : string * string * obj -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (name As String, ns As String, value As Object) As AddressHeader

Parameter

name
String

Der Name des Adressheaders.

ns
String

Der Namespace des Adressheaders.

value
Object

Das Informationselement für den Adressheader.

Gibt zurück

AddressHeader

Der AddressHeader mit festgelegtem name und ns, der das durch den value festgelegte Informationselement enthält.

Ausnahmen

name ist null oder name. Länge == 0.

Beispiele

Das folgende Beispiel zeigt, wie ein Adressheader mit dieser Methode erstellt wird.

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

Gilt für

CreateAddressHeader(String, String, Object, XmlObjectSerializer)

Erstellt eine neue Instanz der AddressHeader-Klasse mit festgelegtem Namen und Namespace, die einen festgelegten Formatierer für die Serialisierung des Informationselements aus einem festgelegten Objekt verwendet.

public:
 static System::ServiceModel::Channels::AddressHeader ^ CreateAddressHeader(System::String ^ name, System::String ^ ns, System::Object ^ value, System::Runtime::Serialization::XmlObjectSerializer ^ serializer);
public static System.ServiceModel.Channels.AddressHeader CreateAddressHeader (string name, string ns, object value, System.Runtime.Serialization.XmlObjectSerializer serializer);
static member CreateAddressHeader : string * string * obj * System.Runtime.Serialization.XmlObjectSerializer -> System.ServiceModel.Channels.AddressHeader
Public Shared Function CreateAddressHeader (name As String, ns As String, value As Object, serializer As XmlObjectSerializer) As AddressHeader

Parameter

name
String

Der Name des Adressheaders.

ns
String

Der Namespace des Adressheaders.

value
Object

Das Informationselement für den Adressheader.

serializer
XmlObjectSerializer

Der XmlObjectSerializer, der verwendet wird, um das angegebene Objekt im value-Parameter zu serialisieren.

Gibt zurück

AddressHeader

Der AddressHeader mit festgelegtem name und ns, der das durch den value festgelegte Informationselement enthält.

Ausnahmen

name oder serializer ist null oder name. Länge == 0.

Beispiele

Das folgende Beispiel zeigt, wie ein Adressheader mit dieser Methode erstellt wird.

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

Gilt für