此方法一般用于Web,部署环境经常变化导致IP经常变动

 

例子是Silveright调用同域WCF服务的方法

        WordGameServiceClient GetClient()
        {
            BasicHttpBinding basicbind = new BasicHttpBinding(BasicHttpSecurityMode.None);

            BinaryMessageEncodingBindingElement binE = new BinaryMessageEncodingBindingElement();
            CustomBinding bind = new CustomBinding(basicbind);
            bind.Elements.Add(binE);
            EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../Service/WordGameService.svc"));

            //也可以自定义绑定,需要和服务绑定对应
            //return new WordGameServiceClient(bind, address);
            return new WordGameServiceClient("CustomBinding_WordGameService", address);
           
        }

 


 

相关文章:

  • 2022-01-02
  • 2021-06-07
  • 2022-12-23
  • 2021-09-14
  • 2021-09-11
  • 2022-12-23
  • 2022-02-06
  • 2021-10-25
猜你喜欢
  • 2021-07-27
  • 2021-04-03
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
相关资源
相似解决方案