1

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.

Community
  • 1
  • 1
Plastikfan
  • 3,674
  • 7
  • 39
  • 54

1 Answers1

2

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);
tomasr
  • 13,683
  • 3
  • 38
  • 30
  • Hi thanks for your response. However, this is the code I tried, but you can't pass SpnEndpointIdentity to the EndpointAddress constructor – Plastikfan Dec 16 '09 at 15:17
  • Make sure EndpointName is an Uri and not a string. It should work. – tomasr Dec 16 '09 at 22:01
  • Hoorah, thanks for that, it finally works when I pass the EndpointName into a Uri first. Now I just have to understand what a 'null' SpnEndpoint Identity actually means. – Plastikfan Dec 21 '09 at 13:45