protected internal override BindingElement CreateBindingElement() { ReliableSessionBindingElement bindingElement = new ReliableSessionBindingElement(); this.ApplyConfiguration(bindingElement); return(bindingElement); }
// Host the service within this EXE console application. public static void Main() { Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); // Create a ServiceHost for the CalculatorService type and provide the base address. using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress)) { // Create a custom binding containing two binding elements ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); reliableSession.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding binding = new CustomBinding(reliableSession, httpTransport); // Add an endpoint using that binding serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); // Open the ServiceHost to create listeners and start listening for messages. serviceHost.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); } }
NetTcpBinding(TcpTransportBindingElement transport, BinaryMessageEncodingBindingElement encoding, TransactionFlowBindingElement context, ReliableSessionBindingElement session, NetTcpSecurity security) : this() { this.security = security; this.ReliableSession.Enabled = session != null; InitializeFrom(transport, encoding, context, session); }
//initialize a SampleProfileUdpBinding from the info collected in a ReliableSessionBindingElement if one is present. void InitializeFrom(UdpTransportBindingElement udpTransportBindingElement, TextMessageEncodingBindingElement textMessageEncodingBindingElement, ReliableSessionBindingElement reliableSessionBindingElement, CompositeDuplexBindingElement compositeDuplexBindingElement) { this.transport.Multicast = udpTransportBindingElement.Multicast; this.transport.MaxBufferPoolSize = udpTransportBindingElement.MaxBufferPoolSize; this.transport.MaxReceivedMessageSize = udpTransportBindingElement.MaxReceivedMessageSize; ((TextMessageEncodingBindingElement)this.encoding).WriteEncoding = textMessageEncodingBindingElement.WriteEncoding; textMessageEncodingBindingElement.ReaderQuotas.CopyTo(((TextMessageEncodingBindingElement)this.encoding).ReaderQuotas); this.ReliableSessionEnabled = reliableSessionBindingElement != null; if (reliableSessionBindingElement != null) { this.SessionInactivityTimeout = reliableSessionBindingElement.InactivityTimeout; this.OrderedSession = reliableSessionBindingElement.Ordered; } if (compositeDuplexBindingElement != null) { this.ClientBaseAddress = compositeDuplexBindingElement.ClientBaseAddress; } }
private static Binding GetCustomBinding( ISettingsStorage settings, IConsoleService console) { var tcpBinding = GetNetBinding(console); try { var binding = (CustomBinding)Activator.CreateInstance( typeof(CustomBinding), tcpBinding); var rbe = new ReliableSessionBindingElement(); binding.Elements.Add(rbe); var bme = Activator.CreateInstance <BinaryMessageEncodingBindingElement>(); bme.CompressionFormat = CompressionFormat.GZip; binding.Elements.Add(bme); var tf = Activator.CreateInstance <TransactionFlowBindingElement>(); binding.Elements.Add(tf); return(binding); } catch (Exception e) { console?.AddException(e); return(tcpBinding); } }
internal static bool TryCreate(SecurityBindingElement sbe, TransportBindingElement transport, PrivacyNoticeBindingElement privacy, ReliableSessionBindingElement rsbe, TransactionFlowBindingElement tfbe, out Binding binding) { WSFederationHttpSecurityMode mode; WSFederationHttpSecurity security2; bool isReliableSession = rsbe != null; binding = null; HttpTransportSecurity transportSecurity = new HttpTransportSecurity(); if (!WSFederationHttpBinding.GetSecurityModeFromTransport(transport, transportSecurity, out mode)) { return false; } HttpsTransportBindingElement element = transport as HttpsTransportBindingElement; if (((element != null) && (element.MessageSecurityVersion != null)) && (element.MessageSecurityVersion.SecurityPolicyVersion != WS2007MessageSecurityVersion.SecurityPolicyVersion)) { return false; } if (TryCreateSecurity(sbe, mode, transportSecurity, isReliableSession, out security2)) { binding = new WS2007FederationHttpBinding(security2, privacy, isReliableSession); } if ((rsbe != null) && (rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)) { return false; } if ((tfbe != null) && (tfbe.TransactionProtocol != TransactionProtocol.WSAtomicTransaction11)) { return false; } return (binding != null); }
private static void ProcessReliableSession11Assertion(MetadataImporter importer, XmlElement element, ReliableSessionBindingElement settings) { settings.ReliableMessagingVersion = ReliableMessagingVersion.WSReliableMessaging11; IEnumerator nodes = element.ChildNodes.GetEnumerator(); System.Xml.XmlNode node = SkipToNode(nodes); ProcessWsrm11Policy(importer, node, settings); node = SkipToNode(nodes); State inactivityTimeout = State.InactivityTimeout; while (node != null) { if ((inactivityTimeout == State.InactivityTimeout) && Is11Assertion(node, "InactivityTimeout")) { SetInactivityTimeout(settings, ReadMillisecondsAttribute(node, true), node.LocalName); inactivityTimeout = State.AcknowledgementInterval; node = SkipToNode(nodes); } else { if (Is11Assertion(node, "AcknowledgementInterval")) { SetAcknowledgementInterval(settings, ReadMillisecondsAttribute(node, true), node.LocalName); return; } if (inactivityTimeout == State.AcknowledgementInterval) { return; } node = SkipToNode(nodes); } } }
public static void Main(string[] args) { Uri baseAddress = new Uri("http://localhost:8000/servicesamplemodel/service"); using (ServiceHost host = new ServiceHost(typeof(Service), baseAddress)) { ReliableSessionBindingElement reliableBinding = new ReliableSessionBindingElement(); reliableBinding.Ordered = true; HttpTransportBindingElement httpBindingElement = new HttpTransportBindingElement(); httpBindingElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpBindingElement.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding customBinding = new CustomBinding(reliableBinding, httpBindingElement); host.AddServiceEndpoint(typeof(ICalculator), customBinding, ""); host.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); } }
void Initialize() { transport = new UdpTransportBindingElement(); session = new ReliableSessionBindingElement(); compositeDuplex = new CompositeDuplexBindingElement(); encoding = new TextMessageEncodingBindingElement(); }
public ReliableSession (ReliableSessionBindingElement binding) { if (binding == null) throw new ArgumentNullException ("binding"); InactivityTimeout = binding.InactivityTimeout; Ordered = binding.Ordered; }
// Host the service within this EXE console application. public static void Main() { Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); // Create a ServiceHost for the CalculatorService type and provide the base address. using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress)) { // Create a custom binding containing two binding elements ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); reliableSession.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding binding = new CustomBinding(reliableSession, httpTransport); // Add an endpoint using that binding serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); // Open the ServiceHost to create listeners and start listening for messages. serviceHost.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); } }
public ReliableSession(ReliableSessionBindingElement reliableSessionBindingElement) { if (reliableSessionBindingElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reliableSessionBindingElement"); } this.element = reliableSessionBindingElement; }
private void Initialize() { this.transport = new TcpTransportBindingElement(); this.encoding = new BinaryMessageEncodingBindingElement(); this.context = GetDefaultTransactionFlowBindingElement(); this.session = new ReliableSessionBindingElement(); this.reliableSession = new OptionalReliableSession(this.session); }
public ReliableSession(ReliableSessionBindingElement reliableSessionBindingElement) { if (reliableSessionBindingElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reliableSessionBindingElement"); } _element = reliableSessionBindingElement; }
private void InitializeFrom(ReliableSessionBindingElement session) { if (session != null) { this.session.InactivityTimeout = session.InactivityTimeout; this.session.Ordered = session.Ordered; } }
public OptionalReliableSession(ReliableSessionBindingElement binding) : base(binding) { if (binding == null) { throw new ArgumentNullException("binding"); } }
private void initialize() { _ReliableSessionBindingElement = new ReliableSessionBindingElement(); _CompositeDuplexBindingElement = new CompositeDuplexBindingElement(); _EncodingBindingElement = new TextMessageEncodingBindingElement(); _OneWayEncodingBindingElement = new OneWayEncoderBindingElement(); _TransportBindingElement = new ExUdpBindingElement(); }
public OptionalReliableSession(ReliableSessionBindingElement reliableSessionBindingElement) : base(reliableSessionBindingElement) { if (reliableSessionBindingElement == null) { throw new ArgumentNullException("reliableSessionBindingElement"); } }
private ReliableSessionBindingElement CreateReliableSessionBindingElement() { // create and configure reliable session ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); reliableSession.Ordered = true; return reliableSession; }
public ReliableSession(ReliableSessionBindingElement reliableSessionBindingElement) { if (reliableSessionBindingElement == null) { throw new ArgumentNullException("reliableSessionBindingElement"); } InactivityTimeout = reliableSessionBindingElement.InactivityTimeout; Ordered = reliableSessionBindingElement.Ordered; }
public ReliableSession(ReliableSessionBindingElement binding) { if (binding == null) { throw new ArgumentNullException("binding"); } InactivityTimeout = binding.InactivityTimeout; Ordered = binding.Ordered; }
private void Initialize() { HttpTransport = new HttpTransportBindingElement(); HttpsTransport = new HttpsTransportBindingElement(); _session = new ReliableSessionBindingElement(true); _textEncoding = new TextMessageEncodingBindingElement(); _textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; _reliableSession = new OptionalReliableSession(_session); }
private static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context) { ReliableSessionBindingElement item = context.BindingElements.Find<ReliableSessionBindingElement>(); if (item == null) { item = new ReliableSessionBindingElement(); context.BindingElements.Add(item); } return item; }
public MessageBusTransportBinding(IBus bus, SessionfulMode sessionfulMode) : base() { _messageElement = new TextMessageEncodingBindingElement(); _transportElement = new MessageBusTransportBindingElement(bus); if (sessionfulMode == SessionfulMode.Standard) { _sessionElement = new ReliableSessionBindingElement(); } }
private void Initialize() { _securityBindingElement = CreateSecurityBindingElement(); _reliableSessionBindingElement = CreateReliableSessionBindingElement(); _mtomEncodingBindingElement = CreateMtomEncodingBindingElement(); _httpsTransportBindingElement = CreateHttpsTransportBindingElement() as HttpsTransportBindingElement; }
private void Initialize() { _transport = new TcpTransportBindingElement(); _encoding = new BinaryMessageEncodingBindingElement(); // NetNative and CoreCLR initialize to what TransportBindingElement does in the desktop // This property is not available in shipped contracts MaxBufferPoolSize = TransportDefaults.MaxBufferPoolSize; session = new ReliableSessionBindingElement(); this.reliableSession = new OptionalReliableSession(session); }
private void Initialize() { _securityBindingElement = CreateSecurityBindingElement(); _reliableSessionBindingElement = CreateReliableSessionBindingElement(); _textEncodingBindingElement = CreateTextEncodingBindingElement(); _httpsTransportBindingElement = CreateHttpsTransportBindingElement(); //_httpTransportBindingElement = CreateHttpTransportBindingElement(); }
static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context) { ReliableSessionBindingElement settings = context.BindingElements.Find<ReliableSessionBindingElement>(); if (settings == null) { settings = new ReliableSessionBindingElement(); context.BindingElements.Add(settings); } return settings; }
static void Main() { Console.WriteLine("Press <ENTER> after the service has been started."); Console.ReadLine(); // Create a custom binding that contains two binding elements. ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); reliableSession.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding binding = new CustomBinding(reliableSession, httpTransport); // Create a channel using that binding. EndpointAddress address = new EndpointAddress("http://localhost:8000/servicemodelsamples/service"); ChannelFactory <ICalculator> channelFactory = new ChannelFactory <ICalculator>(binding, address); ICalculator channel = channelFactory.CreateChannel(); // Call the Add service operation. double value1 = 100.00D; double value2 = 15.99D; double result = channel.Add(value1, value2); Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); // Call the Subtract service operation. value1 = 145.00D; value2 = 76.54D; result = channel.Subtract(value1, value2); Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); // Call the Multiply service operation. value1 = 9.00D; value2 = 81.25D; result = channel.Multiply(value1, value2); Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); // Call the Divide service operation. value1 = 22.00D; value2 = 7.00D; result = channel.Divide(value1, value2); Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result); Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); ((IChannel)channel).Close(); }
private void Initialize() { _securityBindingElement = CreateSecurityBindingElement(); //_securityBindingElement = CreateTransportSecurityBindingElement(); _reliableSessionBindingElement = CreateReliableSessionBindingElement(); //binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11WSAddressing10, Encoding.UTF8)); _mtomEncodingBindingElement = CreateMtomEncodingBindingElement(); _httpsTransportBindingElement = CreateHttpsTransportBindingElement() as HttpsTransportBindingElement; }
WSDualHttpBinding( HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session, CompositeDuplexBindingElement compositeDuplex, OneWayBindingElement oneWay, WSDualHttpSecurity security) : this() { this.security = security; InitializeFrom(transport, encoding, txFlow, session, compositeDuplex, oneWay); }
void Initialize() { httpTransport = new HttpTransportBindingElement(); httpsTransport = new HttpsTransportBindingElement(); messageEncoding = WSHttpBindingDefaults.MessageEncoding; txFlow = GetDefaultTransactionFlowBindingElement(); session = new ReliableSessionBindingElement(true); textEncoding = new TextMessageEncodingBindingElement(); textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; mtomEncoding = new MtomMessageEncodingBindingElement(); mtomEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; reliableSession = new OptionalReliableSession(session); }
WSDualHttpBinding( HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session, CompositeDuplexBindingElement compositeDuplex, OneWayBindingElement oneWay, WSDualHttpSecurity security) : this() { this.security = security; InitializeFrom(transport, encoding, txFlow, session, compositeDuplex, oneWay); }
public override void ApplyConfiguration(BindingElement bindingElement) { base.ApplyConfiguration(bindingElement); ReliableSessionBindingElement element = (ReliableSessionBindingElement)bindingElement; element.AcknowledgementInterval = this.AcknowledgementInterval; element.FlowControlEnabled = this.FlowControlEnabled; element.InactivityTimeout = this.InactivityTimeout; element.MaxPendingChannels = this.MaxPendingChannels; element.MaxRetryCount = this.MaxRetryCount; element.MaxTransferWindowSize = this.MaxTransferWindowSize; element.Ordered = this.Ordered; element.ReliableMessagingVersion = this.ReliableMessagingVersion; }
void Initialize() { this.httpTransport = new HttpTransportBindingElement(); this.messageEncoding = WSDualHttpBindingDefaults.MessageEncoding; this.txFlow = GetDefaultTransactionFlowBindingElement(); this.session = new ReliableSessionBindingElement(true); this.textEncoding = new TextMessageEncodingBindingElement(); this.textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; this.mtomEncoding = new MtomMessageEncodingBindingElement(); this.mtomEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; this.compositeDuplex = new CompositeDuplexBindingElement(); this.reliableSession = new ReliableSession(session); this.oneWay = new OneWayBindingElement(); }
protected internal override void InitializeFrom(BindingElement bindingElement) { base.InitializeFrom(bindingElement); ReliableSessionBindingElement element = (ReliableSessionBindingElement)bindingElement; this.AcknowledgementInterval = element.AcknowledgementInterval; this.FlowControlEnabled = element.FlowControlEnabled; this.InactivityTimeout = element.InactivityTimeout; this.MaxPendingChannels = element.MaxPendingChannels; this.MaxRetryCount = element.MaxRetryCount; this.MaxTransferWindowSize = element.MaxTransferWindowSize; this.Ordered = element.Ordered; this.ReliableMessagingVersion = element.ReliableMessagingVersion; }
private static void EnableMultithreadingForReliableSessions(BindingElementCollection elements) { ReliableSessionBindingElement sessionBindingElement = elements.Find <ReliableSessionBindingElement>(); if (sessionBindingElement != null) { sessionBindingElement.FlowControlEnabled = true; sessionBindingElement.Ordered = false; sessionBindingElement.MaxPendingChannels = 16384; sessionBindingElement.MaxTransferWindowSize = 4096; sessionBindingElement.AcknowledgementInterval = TimeSpan.FromMinutes(1); sessionBindingElement.MaxRetryCount = 64; } }
private void Initialize() { _messageEncoding = NetHttpBindingDefaults.MessageEncoding; _binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement() { MessageVersion = MessageVersion.Soap12WSAddressing10 }; this.TextMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; _session = new ReliableSessionBindingElement(); _reliableSession = new OptionalReliableSession(_session); this.WebSocketSettings.TransportUsage = NetHttpBindingDefaults.TransportUsage; this.WebSocketSettings.SubProtocol = WebSocketTransportSettings.SoapSubProtocol; _basicHttpSecurity = new BasicHttpSecurity(); }
public static void Main(string[] args) { Console.WriteLine("Press <ENTER> after the service has been started."); Console.ReadLine(); ReliableSessionBindingElement reliable = new ReliableSessionBindingElement(); reliable.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding binding = new CustomBinding(reliable, httpTransport); EndpointAddress address = new EndpointAddress("http://localhost:8000/servicesamplemodel/service"); ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>(binding, address); ICalculator calculator = channelFactory.CreateChannel(); // Call the Add service operation. double value1 = 100.00D; double value2 = 15.99D; double result = calculator.Add(value1, value2); Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); // Call the Subtract service operation. value1 = 145.00D; value2 = 76.54D; result = calculator.Subtract(value1, value2); Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); // Call the Multiply service operation. value1 = 9.00D; value2 = 81.25D; result = calculator.Multiply(value1, value2); Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); // Call the Divide service operation. value1 = 22.00D; value2 = 7.00D; result = calculator.Divide(value1, value2); Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result); Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); ((IChannelFactory)channelFactory).Close(); }
protected internal override void InitializeFrom(BindingElement bindingElement) { base.InitializeFrom(bindingElement); ReliableSessionBindingElement binding = (ReliableSessionBindingElement)bindingElement; SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AcknowledgementInterval, binding.AcknowledgementInterval); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.FlowControlEnabled, binding.FlowControlEnabled); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.InactivityTimeout, binding.InactivityTimeout); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxPendingChannels, binding.MaxPendingChannels); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxRetryCount, binding.MaxRetryCount); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxTransferWindowSize, binding.MaxTransferWindowSize); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Ordered, binding.Ordered); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ReliableMessagingVersion, binding.ReliableMessagingVersion); }
public static void Snippet4() { // <Snippet4> Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); // Create a ServiceHost for the CalculatorService type and provide the base address. ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress); // Create a custom binding that contains two binding elements. ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); reliableSession.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; SynchronizedCollection <BindingElement> coll = new SynchronizedCollection <BindingElement>(); coll.Add(reliableSession); coll.Add(httpTransport); CustomBinding binding = new CustomBinding(coll); // </Snippet4> // Add an endpoint using that binding. serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); // Add a MEX endpoint. ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples"); serviceHost.Description.Behaviors.Add(smb); // Open the ServiceHostBase to create listeners and start listening for messages. serviceHost.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); // Close the ServiceHostBase to shutdown the service. serviceHost.Close(); }
// This is effectively just a copy of WSHttpBinding.TryCreate(), only it news up the 2007 version internal new static bool TryCreate(SecurityBindingElement sbe, TransportBindingElement transport, ReliableSessionBindingElement rsbe, TransactionFlowBindingElement tfbe, out Binding binding) { bool isReliableSession = (rsbe != null); binding = null; // reverse GetTransport HttpTransportSecurity transportSecurity = WSHttpSecurity.GetDefaultHttpTransportSecurity(); UnifiedSecurityMode mode; if (!WSHttpBinding.GetSecurityModeFromTransport(transport, transportSecurity, out mode)) { return false; } HttpsTransportBindingElement httpsBinding = transport as HttpsTransportBindingElement; if (httpsBinding != null && httpsBinding.MessageSecurityVersion != null) { if (httpsBinding.MessageSecurityVersion.SecurityPolicyVersion != WS2007MessageSecurityVersion.SecurityPolicyVersion) { return false; } } WSHttpSecurity security; if (WS2007HttpBinding.TryCreateSecurity(sbe, mode, transportSecurity, isReliableSession, out security)) { WS2007HttpBinding ws2007HttpBinding = new WS2007HttpBinding(security, isReliableSession); bool allowCookies; if (!WSHttpBinding.TryGetAllowCookiesFromTransport(transport, out allowCookies)) { return false; } ws2007HttpBinding.AllowCookies = allowCookies; binding = ws2007HttpBinding; } if (rsbe != null && rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11) { return false; } if (tfbe != null && tfbe.TransactionProtocol != TransactionProtocol.WSAtomicTransaction11) { return false; } return binding != null; }
void Initialize() { this.messageEncoding = NetHttpBindingDefaults.MessageEncoding; this.binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement() { MessageVersion = MessageVersion.Soap12WSAddressing10 }; this.TextMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; this.MtomMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; this.session = new ReliableSessionBindingElement(); this.reliableSession = new OptionalReliableSession(this.session); this.InternalWebSocketSettings.TransportUsage = NetHttpBindingDefaults.TransportUsage; this.InternalWebSocketSettings.SubProtocol = WebSocketTransportSettings.SoapSubProtocol; this.basicHttpsSecurity = new BasicHttpsSecurity(); }
private void Initialize() { lock (this) { if (!m_isInitialized) { m_transport = new RabbitMQTransportBindingElement(); m_encoding = new TextMessageEncodingBindingElement(); // new TextMessageEncodingBindingElement(); m_session = new ReliableSessionBindingElement(); m_compositeDuplex = new CompositeDuplexBindingElement(); m_transactionFlow = new TransactionFlowBindingElement(); m_maxMessageSize = DefaultMaxMessageSize; m_isInitialized = true; } } }
static void Main(string[] args) { // <Snippet1> // <Snippet2> // Create a new reliable session object ReliableSessionBindingElement bindingElement = new ReliableSessionBindingElement(); ReliableSession reliableSession = new ReliableSession(bindingElement); // Now you can access property values Console.WriteLine("Ordered: {0}", reliableSession.Ordered); Console.WriteLine("InactivityTimeout: {0}", reliableSession.InactivityTimeout); // </Snippet2> reliableSession.Ordered = false; Console.WriteLine("The new value for the Ordered property is: {0}", reliableSession.Ordered); // </Snippet1> }
// check that properties of the HttpTransportBindingElement and // MessageEncodingBindingElement not exposed as properties on WsHttpBinding // match default values of the binding elements bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session, CompositeDuplexBindingElement compositeDuplex, OneWayBindingElement oneWay) { if (!this.httpTransport.IsMatch(transport)) { return(false); } if (this.MessageEncoding == WSMessageEncoding.Text) { if (!this.textEncoding.IsMatch(encoding)) { return(false); } } else if (this.MessageEncoding == WSMessageEncoding.Mtom) { if (!this.mtomEncoding.IsMatch(encoding)) { return(false); } } if (!this.txFlow.IsMatch(txFlow)) { return(false); } if (!this.session.IsMatch(session)) { return(false); } if (!this.compositeDuplex.IsMatch(compositeDuplex)) { return(false); } if (!this.oneWay.IsMatch(oneWay)) { return(false); } return(true); }
bool IsSessionMatch(BindingElement a, BindingElement b) { if (b == null) { return(false); } ReliableSessionBindingElement sessionA = a as ReliableSessionBindingElement; ReliableSessionBindingElement sessionB = b as ReliableSessionBindingElement; if (sessionB == null) { return(false); } if (sessionA.AcknowledgementInterval != sessionB.AcknowledgementInterval) { return(false); } if (sessionA.FlowControlEnabled != sessionB.FlowControlEnabled) { return(false); } if (sessionA.InactivityTimeout != sessionB.InactivityTimeout) { return(false); } if (sessionA.MaxPendingChannels != sessionB.MaxPendingChannels) { return(false); } if (sessionA.MaxRetryCount != sessionB.MaxRetryCount) { return(false); } if (sessionA.MaxTransferWindowSize != sessionB.MaxTransferWindowSize) { return(false); } if (sessionA.Ordered != sessionB.Ordered) { return(false); } return(true); }
public QpidBinding(string host, int port, string username, string password, string virtualhost) { Host = host; PortNumber = port; UserName = username; Password = password; VirtualHost = virtualhost; _transport = new QpidTransportBindingElement(); _transport.Host = host; _transport.PortNumber = port; _transport.Password = password; _transport.UserName = username; _transport.VirtualHost = virtualhost; _encoding = new TextMessageEncodingBindingElement(); _session = new ReliableSessionBindingElement(); _compositeDuplex = new CompositeDuplexBindingElement(); _transactionFlow = new TransactionFlowBindingElement(); }
static void Main(string[] args) { ReliableSessionBindingElement reliable = new ReliableSessionBindingElement(); reliable.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding custBinding = new CustomBinding(reliable, httpTransport); EndpointAddress endPointAddress = new EndpointAddress("http://localhost:8000/ImperativeSample/CalculatorService"); ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>(custBinding, endPointAddress); ICalculator calc = channelFactory.CreateChannel(); double result = calc.Add(10, 10); Console.WriteLine(result); Console.WriteLine("Press enter to exit"); Console.ReadLine(); }
internal new static bool TryCreate(SecurityBindingElement sbe, TransportBindingElement transport, PrivacyNoticeBindingElement privacy, ReliableSessionBindingElement rsbe, TransactionFlowBindingElement tfbe, out Binding binding) { bool isReliableSession = (rsbe != null); binding = null; // reverse GetTransport HttpTransportSecurity transportSecurity = new HttpTransportSecurity(); WSFederationHttpSecurityMode mode; if (!WSFederationHttpBinding.GetSecurityModeFromTransport(transport, transportSecurity, out mode)) { return false; } HttpsTransportBindingElement httpsBinding = transport as HttpsTransportBindingElement; if (httpsBinding != null && httpsBinding.MessageSecurityVersion != null) { if (httpsBinding.MessageSecurityVersion.SecurityPolicyVersion != WS2007MessageSecurityVersion.SecurityPolicyVersion) { return false; } } WSFederationHttpSecurity security; if (WS2007FederationHttpBinding.TryCreateSecurity(sbe, mode, transportSecurity, isReliableSession, out security)) { binding = new WS2007FederationHttpBinding(security, privacy, isReliableSession); } if (rsbe != null && rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11) { return false; } if (tfbe != null && tfbe.TransactionProtocol != TransactionProtocol.WSAtomicTransaction11) { return false; } return binding != null; }
internal static bool TryCreate(SecurityBindingElement sbe, TransportBindingElement transport, ReliableSessionBindingElement rsbe, TransactionFlowBindingElement tfbe, out Binding binding) { UnifiedSecurityMode mode; WSHttpSecurity security2; bool isReliableSession = rsbe != null; binding = null; HttpTransportSecurity defaultHttpTransportSecurity = WSHttpSecurity.GetDefaultHttpTransportSecurity(); if (!WSHttpBinding.GetSecurityModeFromTransport(transport, defaultHttpTransportSecurity, out mode)) { return false; } HttpsTransportBindingElement element = transport as HttpsTransportBindingElement; if (((element != null) && (element.MessageSecurityVersion != null)) && (element.MessageSecurityVersion.SecurityPolicyVersion != WS2007MessageSecurityVersion.SecurityPolicyVersion)) { return false; } if (TryCreateSecurity(sbe, mode, defaultHttpTransportSecurity, isReliableSession, out security2)) { bool flag2; WS2007HttpBinding binding2 = new WS2007HttpBinding(security2, isReliableSession); if (!WSHttpBinding.TryGetAllowCookiesFromTransport(transport, out flag2)) { return false; } binding2.AllowCookies = flag2; binding = binding2; } if ((rsbe != null) && (rsbe.ReliableMessagingVersion != ReliableMessagingVersion.WSReliableMessaging11)) { return false; } if ((tfbe != null) && (tfbe.TransactionProtocol != TransactionProtocol.WSAtomicTransaction11)) { return false; } return (binding != null); }
private static void ProcessReliableSessionFeb2005Assertion(XmlElement element, ReliableSessionBindingElement settings) { settings.ReliableMessagingVersion = ReliableMessagingVersion.WSReliableMessagingFebruary2005; IEnumerator nodes = element.ChildNodes.GetEnumerator(); System.Xml.XmlNode node = SkipToNode(nodes); if (IsFeb2005Assertion(node, "InactivityTimeout")) { SetInactivityTimeout(settings, ReadMillisecondsAttribute(node, true), node.LocalName); node = SkipToNode(nodes); } if (IsFeb2005Assertion(node, "BaseRetransmissionInterval")) { ReadMillisecondsAttribute(node, false); node = SkipToNode(nodes); } if (IsFeb2005Assertion(node, "ExponentialBackoff")) { node = SkipToNode(nodes); } if (IsFeb2005Assertion(node, "AcknowledgementInterval")) { SetAcknowledgementInterval(settings, ReadMillisecondsAttribute(node, true), node.LocalName); } }
internal static bool TryCreate(BindingElementCollection elements, out Binding binding) { WSDualHttpSecurity security; binding = null; if (elements.Count > 7) { return false; } SecurityBindingElement securityElement = null; HttpTransportBindingElement transport = null; MessageEncodingBindingElement encoding = null; TransactionFlowBindingElement txFlow = null; ReliableSessionBindingElement session = null; CompositeDuplexBindingElement compositeDuplex = null; OneWayBindingElement oneWay = null; foreach (BindingElement element8 in elements) { if (element8 is SecurityBindingElement) { securityElement = element8 as SecurityBindingElement; } else if (element8 is TransportBindingElement) { transport = element8 as HttpTransportBindingElement; } else if (element8 is MessageEncodingBindingElement) { encoding = element8 as MessageEncodingBindingElement; } else if (element8 is TransactionFlowBindingElement) { txFlow = element8 as TransactionFlowBindingElement; } else if (element8 is ReliableSessionBindingElement) { session = element8 as ReliableSessionBindingElement; } else if (element8 is CompositeDuplexBindingElement) { compositeDuplex = element8 as CompositeDuplexBindingElement; } else if (element8 is OneWayBindingElement) { oneWay = element8 as OneWayBindingElement; } else { return false; } } if (transport == null) { return false; } if (encoding == null) { return false; } if (!encoding.CheckEncodingVersion(System.ServiceModel.EnvelopeVersion.Soap12)) { return false; } if (compositeDuplex == null) { return false; } if (oneWay == null) { return false; } if (session == null) { return false; } if (txFlow == null) { txFlow = GetDefaultTransactionFlowBindingElement(); } if (!TryCreateSecurity(securityElement, out security)) { return false; } WSDualHttpBinding binding2 = new WSDualHttpBinding(transport, encoding, txFlow, session, compositeDuplex, oneWay, security); if (!binding2.IsBindingElementsMatch(transport, encoding, txFlow, session, compositeDuplex, oneWay)) { return false; } binding = binding2; return true; }
private void Initialize() { lock (this) { if (!m_isInitialized) { m_transport = new RabbitMQTransportBindingElement(); m_encoding = new TextMessageEncodingBindingElement(); // new TextMessageEncodingBindingElement(); m_session = new ReliableSessionBindingElement(); m_compositeDuplex = new CompositeDuplexBindingElement(); m_transactionFlow = new TransactionFlowBindingElement(); m_maxMessageSize = DefaultMaxMessageSize; m_isInitialized = true; } } }
private void Initialize() { this.httpTransport = new HttpTransportBindingElement(); this.messageEncoding = WSMessageEncoding.Text; this.txFlow = GetDefaultTransactionFlowBindingElement(); this.session = new ReliableSessionBindingElement(true); this.textEncoding = new TextMessageEncodingBindingElement(); this.textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; this.mtomEncoding = new MtomMessageEncodingBindingElement(); this.mtomEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; this.compositeDuplex = new CompositeDuplexBindingElement(); this.reliableSession = new System.ServiceModel.ReliableSession(this.session); this.oneWay = new OneWayBindingElement(); }
void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session) { // transport this.BypassProxyOnLocal = transport.BypassProxyOnLocal; this.HostNameComparisonMode = transport.HostNameComparisonMode; this.MaxBufferPoolSize = transport.MaxBufferPoolSize; this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize; this.ProxyAddress = transport.ProxyAddress; this.UseDefaultWebProxy = transport.UseDefaultWebProxy; // this binding only supports Text and Mtom encoding if (encoding is TextMessageEncodingBindingElement) { this.MessageEncoding = WSMessageEncoding.Text; TextMessageEncodingBindingElement text = (TextMessageEncodingBindingElement)encoding; this.TextEncoding = text.WriteEncoding; this.ReaderQuotas = text.ReaderQuotas; } else if (encoding is MtomMessageEncodingBindingElement) { messageEncoding = WSMessageEncoding.Mtom; MtomMessageEncodingBindingElement mtom = (MtomMessageEncodingBindingElement)encoding; this.TextEncoding = mtom.WriteEncoding; this.ReaderQuotas = mtom.ReaderQuotas; } this.TransactionFlow = txFlow.Transactions; this.reliableSession.Enabled = session != null; //session if (session != null) { // only set properties that have standard binding manifestations this.session.InactivityTimeout = session.InactivityTimeout; this.session.Ordered = session.Ordered; } }
private bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session, CompositeDuplexBindingElement compositeDuplex, OneWayBindingElement oneWay) { if (!this.httpTransport.IsMatch(transport)) { return false; } if (this.MessageEncoding == WSMessageEncoding.Text) { if (!this.textEncoding.IsMatch(encoding)) { return false; } } else if ((this.MessageEncoding == WSMessageEncoding.Mtom) && !this.mtomEncoding.IsMatch(encoding)) { return false; } if (!this.txFlow.IsMatch(txFlow)) { return false; } if (!this.session.IsMatch(session)) { return false; } if (!this.compositeDuplex.IsMatch(compositeDuplex)) { return false; } if (!this.oneWay.IsMatch(oneWay)) { return false; } return true; }
private void InitializeFrom(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session, CompositeDuplexBindingElement compositeDuplex, OneWayBindingElement oneWay) { this.BypassProxyOnLocal = transport.BypassProxyOnLocal; this.HostNameComparisonMode = transport.HostNameComparisonMode; this.MaxBufferPoolSize = transport.MaxBufferPoolSize; this.MaxReceivedMessageSize = transport.MaxReceivedMessageSize; this.ProxyAddress = transport.ProxyAddress; this.UseDefaultWebProxy = transport.UseDefaultWebProxy; if (encoding is TextMessageEncodingBindingElement) { this.MessageEncoding = WSMessageEncoding.Text; TextMessageEncodingBindingElement element = (TextMessageEncodingBindingElement) encoding; this.TextEncoding = element.WriteEncoding; this.ReaderQuotas = element.ReaderQuotas; } else if (encoding is MtomMessageEncodingBindingElement) { this.messageEncoding = WSMessageEncoding.Mtom; MtomMessageEncodingBindingElement element2 = (MtomMessageEncodingBindingElement) encoding; this.TextEncoding = element2.WriteEncoding; this.ReaderQuotas = element2.ReaderQuotas; } this.TransactionFlow = txFlow.Transactions; this.ClientBaseAddress = compositeDuplex.ClientBaseAddress; if (session != null) { this.session.InactivityTimeout = session.InactivityTimeout; this.session.Ordered = session.Ordered; } }
internal static bool TryCreate(BindingElementCollection elements, out Binding binding) { binding = null; if (elements.Count > 6) return false; // collect all binding elements PrivacyNoticeBindingElement privacy = null; TransactionFlowBindingElement txFlow = null; ReliableSessionBindingElement session = null; SecurityBindingElement security = null; MessageEncodingBindingElement encoding = null; HttpTransportBindingElement transport = null; foreach (BindingElement element in elements) { if (element is SecurityBindingElement) security = element as SecurityBindingElement; else if (element is TransportBindingElement) transport = element as HttpTransportBindingElement; else if (element is MessageEncodingBindingElement) encoding = element as MessageEncodingBindingElement; else if (element is TransactionFlowBindingElement) txFlow = element as TransactionFlowBindingElement; else if (element is ReliableSessionBindingElement) session = element as ReliableSessionBindingElement; else if (element is PrivacyNoticeBindingElement) privacy = element as PrivacyNoticeBindingElement; else return false; } if (transport == null) return false; if (encoding == null) return false; if (!transport.AuthenticationScheme.IsSingleton()) { //multiple authentication schemes selected -- not supported in StandardBindings return false; } HttpsTransportBindingElement httpsTransport = transport as HttpsTransportBindingElement; if ( ( security != null ) && ( httpsTransport != null ) && ( httpsTransport.RequireClientCertificate != TransportDefaults.RequireClientCertificate ) ) { return false; } if (null != privacy || !WSHttpBinding.TryCreate(security, transport, session, txFlow, out binding)) if (!WSFederationHttpBinding.TryCreate(security, transport, privacy, session, txFlow, out binding)) if (!WS2007HttpBinding.TryCreate(security, transport, session, txFlow, out binding)) if (!WS2007FederationHttpBinding.TryCreate(security, transport, privacy, session, txFlow, out binding)) return false; if (txFlow == null) { txFlow = GetDefaultTransactionFlowBindingElement(); if ((binding is WS2007HttpBinding) || (binding is WS2007FederationHttpBinding)) { txFlow.TransactionProtocol = TransactionProtocol.WSAtomicTransaction11; } } WSHttpBindingBase wSHttpBindingBase = binding as WSHttpBindingBase; wSHttpBindingBase.InitializeFrom(transport, encoding, txFlow, session); if (!wSHttpBindingBase.IsBindingElementsMatch(transport, encoding, txFlow, session)) return false; return true; }
// check that properties of the HttpTransportBindingElement and // MessageEncodingBindingElement not exposed as properties on BasicHttpBinding // match default values of the binding elements bool IsBindingElementsMatch(HttpTransportBindingElement transport, MessageEncodingBindingElement encoding, TransactionFlowBindingElement txFlow, ReliableSessionBindingElement session) { if (!this.GetTransport().IsMatch(transport)) return false; if (this.MessageEncoding == WSMessageEncoding.Text) { if (!this.textEncoding.IsMatch(encoding)) return false; } else if (this.MessageEncoding == WSMessageEncoding.Mtom) { if (!this.mtomEncoding.IsMatch(encoding)) return false; } if (!this.txFlow.IsMatch(txFlow)) return false; if (reliableSession.Enabled) { if (!this.session.IsMatch(session)) return false; } else if (session != null) { return false; } return true; }