WCF:为什么传入远程端点失败?

发布于 2024-08-15 05:35:38 字数 1296 浏览 11 评论 0原文

我将 wcf 客户端应用程序连接到在单独计算机上运行的主机时遇到的问题记录在之前提出的问题中:

WCF:为什么传入远程终结点会失败?

但是,此处提供的解决方案表示您需要使用带有空字符串的 SpnEndpointIdentity。由于我的代码与我引用的示例中的情况完全不同,因此我需要知道如何处理我创建的 SpnEndpointIdentity 对象。

我有一个 ChannelFactory,我在其上调用 Create Channel,并传入 EndpointAddress:(

    public override void InitialiseChannel()
    {
        SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
        var address = new EndpointAddress(EndpointName);

        Proxy = ChannelFactory.CreateChannel(address);
    }

注意: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;
    }

同样,我无法将它传递到构造函数中,那么我该如何处理它呢?

谢谢。

The problem I am having connecting a wcf client application to a host running on a separate machine is documented in a question previously asked:

WCF: Why does passing in a remote endpoint fail?

However, the solution provided here says you need to use a SpnEndpointIdentity with an empty string. Since my code doesn't look anything like the case in the example I have referenced, I need to know what to do with the SpnEndpointIdentity object I have created.

I have a ChannelFactory upon which I call Create channel, passing in an EndpointAddress:

    public override void InitialiseChannel()
    {
        SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
        var address = new EndpointAddress(EndpointName);

        Proxy = ChannelFactory.CreateChannel(address);
    }

(NB: ChannelFactory is of type IChannelFactory, where T is the service contract interface)
So what do I do with spnEndpointIdentity? I can't pass it to CreateChannel.

Or perhaps I can use it somehow when I create the channel factory:

    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;
    }

Again, I can't pass it into the constructor, so what do I do with it?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂牵梦绕锁你心扉 2024-08-22 05:35:38

你几乎明白了。

您缺少的是,将 EndpointIdentity 与 EndpointAddress 关联,然后将其提供给 CreateChannel():

SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
var address = new EndpointAddress(EndpointName, spnEndpointIdentity);

You almiost got it.

What you're missing is that you associate the EndpointIdentity with the EndpointAddress, and then provide that to CreateChannel():

SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
var address = new EndpointAddress(EndpointName, spnEndpointIdentity);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文