Export (0) Print
Expand All

EndpointAddress Class

Provides a unique network address that a client uses to communicate with a service endpoint.

System.Object
  System.ServiceModel.EndpointAddress

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

public class EndpointAddress

The EndpointAddress type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneEndpointAddress(String)Initializes a new instance of the EndpointAddress class with a specified URI string.
Public methodSupported by Silverlight for Windows PhoneEndpointAddress(Uri, AddressHeader[])Initializes a new instance of the EndpointAddress class with a specified URI and headers.
Top

  NameDescription
Public propertyStatic memberSupported by Silverlight for Windows PhoneAnonymousUriGets a version-neutral representation of the anonymous URI.
Public propertySupported by Silverlight for Windows PhoneHeadersGets the collection of address headers for the endpoints that the builder can create.
Public propertySupported by Silverlight for Windows PhoneIsAnonymousGets a value that indicates whether the endpoint is anonymous.
Public propertySupported by Silverlight for Windows PhoneIsNoneGets a value that indicates whether the URI for the endpoint is the NoneUri.
Public propertyStatic memberSupported by Silverlight for Windows PhoneNoneUriGets 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 PhoneUriGets the URI for the endpoint.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneApplyToAssigns the URI and properties of the endpoint address to the values of the headers of a specified message.
Public methodSupported by Silverlight for Windows PhoneEqualsReturns 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 PhoneFinalizeAllows 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 PhoneGetHashCodeProvides a unique hash code for the current endpoint address. (Overrides Object.GetHashCode().)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberSupported by Silverlight for Windows PhoneReadFromReads an endpoint address for a specified address version from a specified XML dictionary reader.
Public methodSupported by Silverlight for Windows PhoneToStringReturns a canonical string representation of the URI that is contained in the endpoint address. (Overrides Object.ToString().)
Public methodSupported by Silverlight for Windows PhoneWriteContentsToSaves all the child nodes of the node to the XML dictionary writer specified.
Top

  NameDescription
Public operatorStatic memberSupported by Silverlight for Windows PhoneEqualityReturns a value that indicates whether specified endpoint addresses are not equivalent.
Public operatorStatic memberSupported by Silverlight for Windows PhoneInequalityReturns a value that indicates whether specified endpoint addresses are not equivalent.
Top

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.



            // Endpoint address constructor with URI only
            EndpointAddress endpointAddress = new EndpointAddress(
                new Uri("http://localhost/silverlightsamples/service1")
                );

            // Create new 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[] addressHeaders1 = new AddressHeader[2] { addressHeader1, addressHeader2 };

            // Endpoint address constructor with URI and address headers
            EndpointAddress endpointAddressWithHeaders = new EndpointAddress(
                new Uri("http://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", "http://localhost:8000/service", 1);
            AddressHeader addressHeader4 = AddressHeader.CreateAddressHeader("specialservice4", "http://localhost:8000/service", 2);
            AddressHeader[] addressHeaders2 = new AddressHeader[2] { addressHeader3, addressHeader4 };
            EndpointAddress endpointAddressWithHeaders2 = new EndpointAddress(
                new Uri("http://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("http://localhost/silverlightsamples/service1")
                );
            Uri endpointAddressUri = endpointAddress1.Uri;

            //
            AddressHeader addressHeader5 = AddressHeader.CreateAddressHeader("specialservice5", "http://localhost:8000/service", 2);
            EndpointAddress endpointAddress2 = new EndpointAddress(
                new Uri("http://localhost/silverlightsamples/service1"), addressHeader5
                );
            Message message = Message.CreateMessage(MessageVersion.Soap11, null);
            endpointAddress2.ApplyTo(message);
            MessageHeaders messageHeaders = message.Headers;



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

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft