Dynamically switch WCF Web Service Reference URL path through config file

后端 未结 5 2039
误落风尘
误落风尘 2020-12-01 02:56

How do you dynamically switch WCF Web Service Reference URL path through config file ?

5条回答
  •  粉色の甜心
    2020-12-01 03:17

    Are you just wanting to override the URL that is in the config to a different url. Say you have a test service and a live service. You can just do this.

    client.Endpoint.Address = new EndpointAddress(Server.IsLiveServer() ?
        @"LiveUrl" : @"TestURl"); 
    

    Where those url come from wherever you want

提交回复
热议问题