EndpointAddress 构造函数

定义

初始化 EndpointAddress 类的新实例。

重载

EndpointAddress(String)

使用指定的 URI 字符串初始化 EndpointAddress 类的新实例。

EndpointAddress(Uri, AddressHeader[])

使用指定的 URI 和标头初始化 EndpointAddress 类的新实例。

EndpointAddress(Uri, EndpointIdentity, AddressHeader[])

使用指定的 URI、标识和标头初始化 EndpointAddress 类的新实例。

EndpointAddress(Uri, EndpointIdentity, AddressHeaderCollection)

使用指定的 URI、标识和标头集合初始化 EndpointAddress 类的新实例。

EndpointAddress(Uri, EndpointIdentity, AddressHeaderCollection, XmlDictionaryReader, XmlDictionaryReader)

使用指定的 URI、标识、标头集合、元数据和扩展读取器初始化 EndpointAddress 类的新实例。

EndpointAddress(String)

使用指定的 URI 字符串初始化 EndpointAddress 类的新实例。

public:
 EndpointAddress(System::String ^ uri);
public EndpointAddress (string uri);
new System.ServiceModel.EndpointAddress : string -> System.ServiceModel.EndpointAddress
Public Sub New (uri As String)

参数

uri
String

标识终结点的 URI。

示例

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 };
AddressHeaderCollection headers = new AddressHeaderCollection(addressHeaders);

EndpointIdentity endpointIdentity =
    EndpointIdentity.CreateUpnIdentity(WindowsIdentity.GetCurrent().Name);
EndpointAddress endpointAddress = new EndpointAddress(
    new Uri
    ("http://localhost:8003/servicemodelsamples/service/incode/identity"),
    endpointIdentity, addressHeaders);

Uri anonUri = EndpointAddress.AnonymousUri;

适用于

EndpointAddress(Uri, AddressHeader[])

使用指定的 URI 和标头初始化 EndpointAddress 类的新实例。

public:
 EndpointAddress(Uri ^ uri, ... cli::array <System::ServiceModel::Channels::AddressHeader ^> ^ addressHeaders);
public EndpointAddress (Uri uri, params System.ServiceModel.Channels.AddressHeader[] addressHeaders);
new System.ServiceModel.EndpointAddress : Uri * System.ServiceModel.Channels.AddressHeader[] -> System.ServiceModel.EndpointAddress
Public Sub New (uri As Uri, ParamArray addressHeaders As AddressHeader())

参数

uri
Uri

标识终结点位置的 Uri

addressHeaders
AddressHeader[]

类型为 ArrayAddressHeader,包含用于与终结点交互的地址信息。

示例

下面的代码演示此构造函数的用法。

适用于

EndpointAddress(Uri, EndpointIdentity, AddressHeader[])

使用指定的 URI、标识和标头初始化 EndpointAddress 类的新实例。

public:
 EndpointAddress(Uri ^ uri, System::ServiceModel::EndpointIdentity ^ identity, ... cli::array <System::ServiceModel::Channels::AddressHeader ^> ^ addressHeaders);
public EndpointAddress (Uri uri, System.ServiceModel.EndpointIdentity identity, params System.ServiceModel.Channels.AddressHeader[] addressHeaders);
new System.ServiceModel.EndpointAddress : Uri * System.ServiceModel.EndpointIdentity * System.ServiceModel.Channels.AddressHeader[] -> System.ServiceModel.EndpointAddress
Public Sub New (uri As Uri, identity As EndpointIdentity, ParamArray addressHeaders As AddressHeader())

参数

uri
Uri

标识终结点位置的 Uri

identity
EndpointIdentity

终结点的 EndpointIdentity

addressHeaders
AddressHeader[]

类型为 ArrayAddressHeader,包含用于与终结点交互的地址信息。

示例

下面的代码演示如何使用 EndpointAddressUriEndpointIdentity 对象的数组来构造 AddressHeader 对象。

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

        EndpointIdentity endpointIdentity = EndpointIdentity.CreateUpnIdentity(WindowsIdentity.GetCurrent().Name);

        EndpointAddress endpointAddress = new EndpointAddress(
            new Uri
        ("http://localhost:8003/servicemodelsamples/service/incode/identity"),
        endpointIdentity, addressHeaders);

适用于

EndpointAddress(Uri, EndpointIdentity, AddressHeaderCollection)

使用指定的 URI、标识和标头集合初始化 EndpointAddress 类的新实例。

public:
 EndpointAddress(Uri ^ uri, System::ServiceModel::EndpointIdentity ^ identity, System::ServiceModel::Channels::AddressHeaderCollection ^ headers);
public EndpointAddress (Uri uri, System.ServiceModel.EndpointIdentity identity, System.ServiceModel.Channels.AddressHeaderCollection headers);
new System.ServiceModel.EndpointAddress : Uri * System.ServiceModel.EndpointIdentity * System.ServiceModel.Channels.AddressHeaderCollection -> System.ServiceModel.EndpointAddress
Public Sub New (uri As Uri, identity As EndpointIdentity, headers As AddressHeaderCollection)

参数

uri
Uri

标识终结点位置的 Uri

identity
EndpointIdentity

终结点的 EndpointIdentity

headers
AddressHeaderCollection

包含用于与终结点交互的地址信息的 AddressHeaderCollection

示例

下面的代码演示如何使用 EndpointAddressUriEndpointIdentity 对象来构造 AddressHeaderCollection 对象。

        //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[] addressHeaders = new AddressHeader[2] { addressHeader1, addressHeader2 };
        AddressHeaderCollection addressHeaderColl = new AddressHeaderCollection(addressHeaders);

    // <Snippet#15>
        EndpointIdentity endpointIdentity = EndpointIdentity.CreateUpnIdentity(WindowsIdentity.GetCurrent().Name);
        EndpointAddress endpointAddress = new EndpointAddress(
            new Uri("http://localhost:8003/servicemodelsamples/service/incode/identity"),
        endpointIdentity,
        addressHeaderColl);
    EndpointIdentity thisEndpointIdentity = endpointAddress.Identity;
    // </Snippet#15>

适用于

EndpointAddress(Uri, EndpointIdentity, AddressHeaderCollection, XmlDictionaryReader, XmlDictionaryReader)

使用指定的 URI、标识、标头集合、元数据和扩展读取器初始化 EndpointAddress 类的新实例。

public:
 EndpointAddress(Uri ^ uri, System::ServiceModel::EndpointIdentity ^ identity, System::ServiceModel::Channels::AddressHeaderCollection ^ headers, System::Xml::XmlDictionaryReader ^ metadataReader, System::Xml::XmlDictionaryReader ^ extensionReader);
public EndpointAddress (Uri uri, System.ServiceModel.EndpointIdentity identity, System.ServiceModel.Channels.AddressHeaderCollection headers, System.Xml.XmlDictionaryReader metadataReader, System.Xml.XmlDictionaryReader extensionReader);
new System.ServiceModel.EndpointAddress : Uri * System.ServiceModel.EndpointIdentity * System.ServiceModel.Channels.AddressHeaderCollection * System.Xml.XmlDictionaryReader * System.Xml.XmlDictionaryReader -> System.ServiceModel.EndpointAddress
Public Sub New (uri As Uri, identity As EndpointIdentity, headers As AddressHeaderCollection, metadataReader As XmlDictionaryReader, extensionReader As XmlDictionaryReader)

参数

uri
Uri

标识终结点位置的 Uri

identity
EndpointIdentity

终结点的 EndpointIdentity

headers
AddressHeaderCollection

包含用于与终结点交互的地址信息的 AddressHeaderCollection

metadataReader
XmlDictionaryReader

从中获取终结点元数据的 XmlDictionaryReader

extensionReader
XmlDictionaryReader

从中获取扩展的 XmlDictionaryReader

示例

下面的代码演示如何实例化 EndpointAddress,以指定 UriEndpointIdentity、标头集合、元数据 XmlDictionaryReader 和扩展 XmlDictionaryReader

XmlDictionaryReader metadataReader = endpointAddress.GetReaderAtMetadata();
XmlDictionaryReader extensionReader = endpointAddress.GetReaderAtExtensions();
EndpointIdentity identity = EndpointIdentity.CreateUpnIdentity(WindowsIdentity.GetCurrent().Name);

EndpointAddress endpointAddress2 = new EndpointAddress(
    new Uri("http://localhost:8003/servicemodelsamples/service/incode/identity"), identity, headers, metadataReader, extensionReader);

注解

WS-Addressing 规范允许任意扩展元素出现在使用 XmlDictionaryReader 获取的终结点引用 (EPR) 末尾处。

适用于