Guest User

Untitled

a guest
Apr 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. protected IService CreateProxy(Uri serviceUri, int sendReceiveTimeout)
  2. {
  3. bool isHttps = (serviceUri.Scheme == Uri.UriSchemeHttps);
  4. EndpointAddress address = new EndpointAddress(serviceUri);
  5. var binding = new BasicHttpBinding(isHttps ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None);
  6. binding.SendTimeout = TimeSpan.FromSeconds(sendReceiveTimeout);
  7. binding.ReceiveTimeout = TimeSpan.FromSeconds(sendReceiveTimeout);
  8. binding.MaxReceivedMessageSize = Int32.MaxValue;
  9. binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
  10. var channelFactory = new ChannelFactory<IService>(binding, address);
  11. IService proxy = channelFactory.CreateChannel();
  12.  
  13. return proxy;
  14. }
  15. IService client = CreateProxy(..., ...)
  16.  
  17. ServiceClient client = new ServiceClient();
Add Comment
Please, Sign In to add comment