题
我有连接WCF客户端应用程序到一个单独的机器上运行的主机的问题在先前提出的问题进行了说明
然而,这里提供的解决方案说,你需要使用SpnEndpointIdentity一个空字符串。由于我的代码不看类似的东西在我所引用的例子的情况下,我需要知道如何处理我已经创建了SpnEndpointIdentity对象做。
我有一个的ChannelFactory在我称之为创建频道,传递一个的EndpointAddress:
public override void InitialiseChannel()
{
SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
var address = new EndpointAddress(EndpointName);
Proxy = ChannelFactory.CreateChannel(address);
}
(NB:的ChannelFactory是类型IChannelFactory,其中T是服务合同接口) 所以,我该怎么跟spnEndpointIdentity办?我不能将它传递给CreateChannel。
或许当我创建通道工厂我可以使用它以某种方式:
private ChannelFactory<T> CreateChannelFactory()
{
var binding = new NetTcpBinding
{
ReaderQuotas = { MaxArrayLength = 2147483647 },
MaxReceivedMessageSize = 2147483647
};
SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
var channelFactory = new ChannelFactory<T>(binding);
return channelFactory;
}
同样,我不能把它传递到构造函数,所以我该怎么办呢?
感谢。
解决方案
您almiost得到它。
什么你缺少的就是你用的EndpointAddress的EndpointIdentity相关联,然后提供给CreateChannel():
SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
var address = new EndpointAddress(EndpointName, spnEndpointIdentity);
不隶属于 StackOverflow