c# - What is the best way to use wcf client ? (memory wise) -
i have read memory usage of wcf client , have done until might wrong.
when have used wcf client, created new wcf client each call. (for self hosting , iis).
way go ? of should create 1 client member , use around ?
memory usage of wcf client ?
i think should create new client when need call service operations new endpoint, binding typically stays same. can create factory class make clients specific contract + binding different endpoints. example, following webhttpbinding can substitute whatever binding need:
public class webhttpclient<t> { protected webhttpbinding binding { get; private set; } public webhttpclient() { // set default binding here } public webhttpclient(webhttpbinding binding) { binding = binding; } public t get(string uri) { endpointaddress _endpoint = new endpointaddress(uri); channelfactory<t> _factory = new channelfactory<t>(binding, _endpoint); _factory.endpoint.behaviors.add(new webhttpbehavior()); return _factory.createchannel(); } } where t service contract.
Comments
Post a Comment