以编程方式在 WCF EndpointAddress 上设置标识
连接到 WCF 服务时,我使用以下函数创建 System.ServiceModel.EndpointAddress
:
private static EndpointAddress GetEndPointAddress(string url, EndpointIdentity identity)
{
Uri baseAddress = new Uri(url);
EndpointAddress endpointAddress = new EndpointAddress(
baseAddress,
identity,
new AddressHeaderCollection());
return endpointAddress;
}
我需要传入一个 EndPointIdentity
,它与我的以下摘录相关web.config:
<identity>
<dns value="Some Value" />
</identity>
我的 WCF 服务使用 X509 证书,因此我的身份似乎需要为 X509CertificateEndpointIdentity
类型。 此构造函数要求我传递一个证书...但我想传递一个 dns 值,如上所示。
谁能建议我的方法有什么问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,我需要创建一个 DnsEndpointIdentity,如下所示:
In fact I needed to create a DnsEndpointIdentity, as follows: