Programmatically set identity on WCF EndpointAddress

狂风中的少年 提交于 2019-12-20 05:23:30

问题


I am using the following function to create a System.ServiceModel.EndpointAddress when connecting to a WCF Service:

private static EndpointAddress GetEndPointAddress(string url, EndpointIdentity identity)
{
    Uri baseAddress = new Uri(url);
    EndpointAddress endpointAddress = new EndpointAddress(
        baseAddress,
        identity,
        new AddressHeaderCollection());
    return endpointAddress;
}

I need to pass in an EndPointIdentity that correlates with the following excerpt from my web.config:

<identity>
  <dns value="Some Value" />
</identity>

My WCF Service uses an X509 certificate, so it seems that my identity needs to be of type X509CertificateEndpointIdentity. The constructor for this requires me to pass in a certificate...but I want to pass it a dns value, as shown above.

Can anyone suggest what is wrong with my approach?


回答1:


In fact I needed to create a DnsEndpointIdentity, as follows:

DnsEndpointIdentity identity = new DnsEndpointIdentity("Some value");


来源:https://stackoverflow.com/questions/798684/programmatically-set-identity-on-wcf-endpointaddress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!