Skip to content

Instantly share code, notes, and snippets.

@vbilopav
Created September 3, 2015 12:22
Show Gist options
  • Save vbilopav/2331415cba390458658f to your computer and use it in GitHub Desktop.
Save vbilopav/2331415cba390458658f to your computer and use it in GitHub Desktop.
public class WcfDynamicSoapProxy<T> : IDisposable where T : class
{
public static WcfDynamicSoapProxy<T> CreateProxy(string endpointAdressUri)
{
return new WcfDynamicSoapProxy<T>(endpointAdressUri);
}
protected readonly ChannelFactory<T> DynamicChannelFactory;
public T Channel { get; private set; }
public WcfDynamicSoapProxy(string endpointAdressUri)
{
BasicHttpBinding binding = new BasicHttpBinding(); //'application/soap+xml; charset=utf-8'
DynamicChannelFactory = new ChannelFactory<T>(binding, endpointAdressUri);
Channel = DynamicChannelFactory.CreateChannel();
}
public void Dispose()
{
DynamicChannelFactory.Close();
(DynamicChannelFactory as IDisposable).Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment