EndpointAddress Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Provides a unique network address that a client uses to communicate with a service endpoint.
Inheritance Hierarchy
System.Object
System.ServiceModel.EndpointAddress
Namespace: System.ServiceModel
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Syntax
'Declaration
Public Class EndpointAddress
public class EndpointAddress
The EndpointAddress type exposes the following members.
Constructors
Name | Description | |
---|---|---|
EndpointAddress(String) | Initializes a new instance of the EndpointAddress class with a specified URI string. | |
EndpointAddress(Uri, array<AddressHeader[]) | Initializes a new instance of the EndpointAddress class with a specified URI and headers. |
Top
Properties
Name | Description | |
---|---|---|
AnonymousUri | Gets a version-neutral representation of the anonymous URI. | |
Headers | Gets the collection of address headers for the endpoints that the builder can create. | |
IsAnonymous | Gets a value that indicates whether the endpoint is anonymous. | |
IsNone | Gets a value that indicates whether the URI for the endpoint is the NoneUri. | |
NoneUri | Gets a version-neutral URI used for the address of an endpoint to which a message must not be sent. | |
Uri | Gets the URI for the endpoint. |
Top
Methods
Name | Description | |
---|---|---|
ApplyTo | Assigns the URI and properties of the endpoint address to the values of the headers of a specified message. | |
Equals | Returns a value that indicates whether a specified object is equivalent to the current endpoint address. (Overrides Object.Equals(Object).) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Provides a unique hash code for the current endpoint address. (Overrides Object.GetHashCode().) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ReadFrom | Reads an endpoint address for a specified address version from a specified XML dictionary reader. | |
ToString | Returns a canonical string representation of the URI that is contained in the endpoint address. (Overrides Object.ToString().) | |
WriteContentsTo | Saves all the child nodes of the node to the XML dictionary writer specified. |
Top
Operators
Name | Description | |
---|---|---|
Equality | Returns a value that indicates whether specified endpoint addresses are not equivalent. | |
Inequality | Returns a value that indicates whether specified endpoint addresses are not equivalent. |
Top
Remarks
An endpoint address uniquely identifies the endpoint for a service.
The endpoint address belongs to the service endpoint, which also contains the binding, contract and behaviors for the endpoint.
The EndpointAddress contains a URI and address properties that include an identity, WSDL elements, and a collection of optional headers. The optional headers are used to provide additional, more detailed addressing information to identify or interact with the endpoint. For example, they can be used to indicate which instance of a service is to be used to process an incoming message from a particular user when multiple instances are available.
Examples
' Endpoint address constructor with URI only
Dim endpointAddress As New EndpointAddress(New Uri("https://localhost/silverlightsamples/service1"))
' Create new address headers for special services and add them to an array
Dim addressHeader1 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice1", "https://localhost:8000/service", 1)
Dim addressHeader2 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice2", "https://localhost:8000/service", 2)
Dim addressHeaders1() As AddressHeader = { addressHeader1, addressHeader2 }
' Endpoint address constructor with URI and address headers
Dim endpointAddressWithHeaders As New EndpointAddress(New Uri("https://localhost/silverlightsamples/service2"), addressHeaders1)
' Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
Dim addressHeaderCollection As AddressHeaderCollection = endpointAddressWithHeaders.Headers
Dim boolHeaders As Boolean = addressHeaderCollection.Contains(addressHeader1)
' Endpoint address with the anonymous URI.
Dim anonUri As Uri = EndpointAddress.AnonymousUri
Dim anonUriEndpointAddress As New EndpointAddress(anonUri)
'Confirm the address is anonymous
Dim boolAnonUri1 As Boolean = anonUriEndpointAddress.IsAnonymous
'Use Headers property to create a collection of address headers from the EnpointAddress
Dim addressHeader3 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice3", "https://localhost:8000/service", 1)
Dim addressHeader4 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice4", "https://localhost:8000/service", 2)
Dim addressHeaders2() As AddressHeader = { addressHeader3, addressHeader4 }
Dim endpointAddressWithHeaders2 As New EndpointAddress(New Uri("https://localhost/silverlightsamples/service3"), addressHeaders2)
Dim addressHeaderCollection2 As AddressHeaderCollection = endpointAddressWithHeaders.Headers
' Confirm endpoint address has an anonymous URI.
Dim anonEndpointAddress As New EndpointAddress(EndpointAddress.AnonymousUri)
Dim boolAnonUri2 As Boolean = anonEndpointAddress.IsAnonymous
' Endpoint address with the none URI.
Dim noneUri As Uri = EndpointAddress.NoneUri
Dim noneUriEndpointAddress As New EndpointAddress(noneUri)
'Confirm the address is anonymous
Dim boolNoneUri As Boolean = noneUriEndpointAddress.IsNone
' Get the URI from the endpoint address
Dim endpointAddress1 As New EndpointAddress(New Uri("https://localhost/silverlightsamples/service1"))
Dim endpointAddressUri As Uri = endpointAddress1.Uri
'
Dim addressHeader5 As AddressHeader = AddressHeader.CreateAddressHeader("specialservice5", "https://localhost:8000/service", 2)
Dim endpointAddress2 As New EndpointAddress(New Uri("https://localhost/silverlightsamples/service1"), addressHeader5)
Dim message As Message = Message.CreateMessage(MessageVersion.Soap11, Nothing)
endpointAddress2.ApplyTo(message)
Dim messageHeaders As MessageHeaders = message.Headers
// Endpoint address constructor with URI only
EndpointAddress endpointAddress = new EndpointAddress(
new Uri("https://localhost/silverlightsamples/service1")
);
// Create new address headers for special services and add them to an array
AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("specialservice1", "https://localhost:8000/service", 1);
AddressHeader addressHeader2 = AddressHeader.CreateAddressHeader("specialservice2", "https://localhost:8000/service", 2);
AddressHeader[] addressHeaders1 = new AddressHeader[2] { addressHeader1, addressHeader2 };
// Endpoint address constructor with URI and address headers
EndpointAddress endpointAddressWithHeaders = new EndpointAddress(
new Uri("https://localhost/silverlightsamples/service2"), addressHeaders1
);
// Confirm adddressHeader1 is in endpointAddressWithHeaders - boolHeaders returns True.
AddressHeaderCollection addressHeaderCollection = endpointAddressWithHeaders.Headers;
bool boolHeaders = addressHeaderCollection.Contains(addressHeader1);
// Endpoint address with the anonymous URI.
Uri anonUri = EndpointAddress.AnonymousUri;
EndpointAddress anonUriEndpointAddress = new EndpointAddress(anonUri);
//Confirm the address is anonymous
bool boolAnonUri1 = anonUriEndpointAddress.IsAnonymous;
//Use Headers property to create a collection of address headers from the EnpointAddress
AddressHeader addressHeader3 = AddressHeader.CreateAddressHeader("specialservice3", "https://localhost:8000/service", 1);
AddressHeader addressHeader4 = AddressHeader.CreateAddressHeader("specialservice4", "https://localhost:8000/service", 2);
AddressHeader[] addressHeaders2 = new AddressHeader[2] { addressHeader3, addressHeader4 };
EndpointAddress endpointAddressWithHeaders2 = new EndpointAddress(
new Uri("https://localhost/silverlightsamples/service3"), addressHeaders2
);
AddressHeaderCollection addressHeaderCollection2 = endpointAddressWithHeaders.Headers;
// Confirm endpoint address has an anonymous URI.
EndpointAddress anonEndpointAddress = new EndpointAddress(EndpointAddress.AnonymousUri);
bool boolAnonUri2 = anonEndpointAddress.IsAnonymous;
// Endpoint address with the none URI.
Uri noneUri = EndpointAddress.NoneUri;
EndpointAddress noneUriEndpointAddress = new EndpointAddress(noneUri);
//Confirm the address is anonymous
bool boolNoneUri = noneUriEndpointAddress.IsNone;
// Get the URI from the endpoint address
EndpointAddress endpointAddress1 = new EndpointAddress(
new Uri("https://localhost/silverlightsamples/service1")
);
Uri endpointAddressUri = endpointAddress1.Uri;
//
AddressHeader addressHeader5 = AddressHeader.CreateAddressHeader("specialservice5", "https://localhost:8000/service", 2);
EndpointAddress endpointAddress2 = new EndpointAddress(
new Uri("https://localhost/silverlightsamples/service1"), addressHeader5
);
Message message = Message.CreateMessage(MessageVersion.Soap11, null);
endpointAddress2.ApplyTo(message);
MessageHeaders messageHeaders = message.Headers;
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.