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
Public methodSupported by Silverlight for Windows Phone EndpointAddress(String) Initializes a new instance of the EndpointAddress class with a specified URI string.
Public methodSupported by Silverlight for Windows Phone EndpointAddress(Uri, array<AddressHeader[]) Initializes a new instance of the EndpointAddress class with a specified URI and headers.

Top

Properties

  Name Description
Public propertyStatic memberSupported by Silverlight for Windows Phone AnonymousUri Gets a version-neutral representation of the anonymous URI.
Public propertySupported by Silverlight for Windows Phone Headers Gets the collection of address headers for the endpoints that the builder can create.
Public propertySupported by Silverlight for Windows Phone IsAnonymous Gets a value that indicates whether the endpoint is anonymous.
Public propertySupported by Silverlight for Windows Phone IsNone Gets a value that indicates whether the URI for the endpoint is the NoneUri.
Public propertyStatic memberSupported by Silverlight for Windows Phone NoneUri Gets a version-neutral URI used for the address of an endpoint to which a message must not be sent.
Public propertySupported by Silverlight for Windows Phone Uri Gets the URI for the endpoint.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone ApplyTo Assigns the URI and properties of the endpoint address to the values of the headers of a specified message.
Public methodSupported by Silverlight for Windows Phone Equals Returns a value that indicates whether a specified object is equivalent to the current endpoint address. (Overrides Object.Equals(Object).)
Protected methodSupported by Silverlight for Windows Phone 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.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Provides a unique hash code for the current endpoint address. (Overrides Object.GetHashCode().)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberSupported by Silverlight for Windows Phone ReadFrom Reads an endpoint address for a specified address version from a specified XML dictionary reader.
Public methodSupported by Silverlight for Windows Phone ToString Returns a canonical string representation of the URI that is contained in the endpoint address. (Overrides Object.ToString().)
Public methodSupported by Silverlight for Windows Phone WriteContentsTo Saves all the child nodes of the node to the XML dictionary writer specified.

Top

Operators

  Name Description
Public operatorStatic memberSupported by Silverlight for Windows Phone Equality Returns a value that indicates whether specified endpoint addresses are not equivalent.
Public operatorStatic memberSupported by Silverlight for Windows Phone 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.

See Also

Reference