views:

171

answers:

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:

http://stackoverflow.com/questions/489915/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.

+1  A: 

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
Hi thanks for your response. However, this is the code I tried, but you can't pass SpnEndpointIdentity to the EndpointAddress constructor
Shantaram
Make sure EndpointName is an Uri and not a string. It should work.
tomasr
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.
Shantaram