AddressHeader.CreateAddressHeader Method (String, String, Object)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Creates a new instance of the AddressHeader class with a specified value, name and namespace.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
'Declaration Public Shared Function CreateAddressHeader ( _ name As String, _ ns As String, _ value As Object _ ) As AddressHeader
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.
Return Value
Type: System.ServiceModel.Channels.AddressHeaderThe AddressHeader with the specified name and ns that contains the information item specified by value.
| Exception | Condition |
|---|---|
| ArgumentNullException | The name is Nothing or name.Length == 0. |
The following example shows how to create an address header using this method.
' 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)
Show: