Beispiel #1
0
 public static Binding CreateBinding(BindingTraits bindingTraits)
 {
     if (bindingTraits.HasFlag(BindingTraits.BasicHttp))
     {
         return(CreateBasicHttpBinding(bindingTraits));
     }
     throw new NotSupportedException(bindingTraits.ToString());
 }
Beispiel #2
0
        private static TransferMode DetermineTransferMode(BindingTraits traits)
        {
            if (traits.HasFlag(BindingTraits.BufferedTraffic))
            {
                return(System.ServiceModel.TransferMode.Buffered);
            }

            if (traits.HasFlag(BindingTraits.StreamedTraffic))
            {
                return(System.ServiceModel.TransferMode.Streamed);
            }

            if (traits.HasFlag(BindingTraits.StreamedRequest))
            {
                return(System.ServiceModel.TransferMode.StreamedRequest);
            }

            if (traits.HasFlag(BindingTraits.StreamedResponse))
            {
                return(System.ServiceModel.TransferMode.StreamedResponse);
            }

            return(DefaultTransferMode);
        }
Beispiel #3
0
        private static Binding CreateBasicHttpBinding(BindingTraits bindingTraits)
        {
            BasicHttpSecurityMode securityMode;

            // TODO: determine security mode from traits
            securityMode = BasicHttpSecurityMode.None;
            var binding = new BasicHttpBinding(securityMode);

            binding.TransferMode = DetermineTransferMode(bindingTraits);
            var largeRequests  = bindingTraits.HasFlag(BindingTraits.LargeRequests);
            var largeResponses = bindingTraits.HasFlag(BindingTraits.LargeResponses);
            var longRequests   = bindingTraits.HasFlag(BindingTraits.SlowRequests);
            var longResponses  = bindingTraits.HasFlag(BindingTraits.SlowResponses);

            binding.MaxBufferSize          = largeRequests ? LargeMaxBufferSize : StandardMaxBufferSize;
            binding.MaxBufferPoolSize      = largeRequests ? LargeMaxBufferPoolSize : StandardMaxBufferPoolSize;
            binding.MaxReceivedMessageSize = largeResponses ? LargeMaxReceivedMessageSize : StandardMaxReceivedMessageSize;
            binding.OpenTimeout            = longResponses ? TimeSpan.FromMinutes(LongOpenTimeoutMin) : TimeSpan.FromMinutes(StandardOpenTimeoutMin);
            binding.SendTimeout            = longRequests ? TimeSpan.FromMinutes(LongSendTimeoutMin) : TimeSpan.FromMinutes(StandardSendTimeoutMin);
            binding.ReceiveTimeout         = longResponses ? TimeSpan.FromMinutes(LongReceiveTimeoutMin) : TimeSpan.FromMinutes(StandardReceiveTimeoutMin);
            binding.CloseTimeout           = longResponses ? TimeSpan.FromMinutes(LongCloseTimeoutMin) : TimeSpan.FromMinutes(StandardCloseTimeoutMin);
            binding.ReaderQuotas           = (largeRequests || largeResponses) ? CreateLargeSoapReader() : CreateStandardSoapReader();
            return(binding);
        }