Search code examples
wcfendpointssspi

WCF: Why does passing in a remote endpoint fail?


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.


Solution

  • 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);