private void Consume() { string config = string.Empty; SupportedBindings binding = GetSelectedBinding(); try { byte[] result = serializer.Serialize <ReadingDTO[]>(readings.ToArray()); switch (cmbType.Text) { case "Publisher": config = HTTP_PUBLISHER_CONFIG; if (cmbBindings.Text == TCP_CONFIG) { config = TCP_PUBLISHER_CONFIG; } stopWatch.Start(); var publisher = ChainServiceHelper.CreateServiceClient <IPublisherService>(binding, config, txtEndpoint.Text); publisher.OnNewReadingsSerialized(result, readingType); stopWatch.Stop(); break; case "Subscriber": config = HTTP_SUBSCRIBER_CONFIG; if (cmbBindings.Text == TCP_CONFIG) { config = TCP_SUBSCRIBER_CONFIG; } stopWatch.Start(); var subscriber = ChainServiceHelper.CreateServiceClient <IBusinessSubsProcess>(binding, config, txtEndpoint.Text); subscriber.ProcessReadings(result); stopWatch.Stop(); break; case "ChainLink": config = HTTP_CHAINLINK_CONFIG; if (cmbBindings.Text == TCP_CONFIG) { config = TCP_CHAINLINK_CONFIG; } if (txtNextLink.Text != string.Empty) { chainList = new List <ChainLink>(); chainList.Add(new ChainLink(binding, txtNextLink.Text, config, 1)); chainList.Add(new ChainLink(binding, txtNextLink.Text, config, 2)); } stopWatch.Start(); var chainLink = ChainServiceHelper.CreateServiceClient <IServiceLink>(binding, config, txtEndpoint.Text); chainLink.HandleRequestSerialized(chainList, result); stopWatch.Stop(); break; } } catch (Exception ex) { throw; } }
private static Binding CreateBinding(SupportedBindings bindingType, TimeSpan operationTimeout) { Binding clientBinding = null; switch (bindingType) { case SupportedBindings.BasicHttp: clientBinding = new BasicHttpBinding { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue, MaxBufferPoolSize = int.MaxValue, ReaderQuotas = { MaxArrayLength = int.MaxValue, MaxBytesPerRead = int.MaxValue, MaxNameTableCharCount = int.MaxValue, MaxDepth = int.MaxValue } }; break; case SupportedBindings.BasicHttps: clientBinding = new BasicHttpsBinding { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue, MaxBufferPoolSize = int.MaxValue, ReaderQuotas = { MaxArrayLength = int.MaxValue, MaxBytesPerRead = int.MaxValue, MaxNameTableCharCount = int.MaxValue, MaxDepth = int.MaxValue } }; break; default: break; } if (operationTimeout != null) { clientBinding.SendTimeout = operationTimeout; } return(clientBinding); }
public static HttpWcfClient <T> Create(SupportedBindings bindingType, string endPointFormat, params Object[] args) { return(FactoryClient(CreateBinding(bindingType, DefaultOperationTimeOut), endPointFormat, args)); }