Dynamically set endpoint address in wcf client (with net tcp binding)

前端 未结 1 1791
刺人心
刺人心 2021-01-03 09:41

So I\'m not overly familiar with WCF and all the stuff I\'ve googled hasn\'t helped me with how to achieve what I need. Sorry if this is a dumb question :)

Basicall

相关标签:
1条回答
  • 2021-01-03 09:47

    You could create a ChannelFactory.

    Along with your standard client, WCF WSDLs will also provide an interface class for the client.

    EndpointAddress address = new EndpointAddress("http://dynamic.address.here");
            using (ChannelFactory<IPartyControllerChannel> factory = new ChannelFactory<IPartyControllerChannel>("IPartyControllerEndpoint", address))
            {
    
                using (IPartyControllerChannel channel = factory.CreateChannel())
                {
                    channel.GetLatestPartyProfile(context, parsedParameters.PartyId);
                }
            }
    
    0 讨论(0)
提交回复
热议问题