Beispiel #1
0
        static void Main(string[] args)
        {
            var host = new ServiceHost(typeof (Calculator));

            var relayBinding = new WebHttpRelayBinding {MaxReceivedMessageSize = int.MaxValue};
            relayBinding.Security.Mode = EndToEndWebHttpSecurityMode.Transport;
            relayBinding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.RelayAccessToken;

            var sdb = host.Description.Behaviors.Find<ServiceDebugBehavior>();
            if (sdb == null)
            {
                sdb.IncludeExceptionDetailInFaults = true;
                host.Description.Behaviors.Add(sdb);
            }

            var endpoint = host.AddServiceEndpoint(typeof (ICalculator), relayBinding, uri);
            var sharedSecretBehavior = new TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret)
            };
            endpoint.Behaviors.Add(sharedSecretBehavior);
            endpoint.Behaviors.Add(new WebHttpBehavior());

            host.Open();

            Console.WriteLine("Host opened at {0}", uri);
            Console.Read();
        }
        static void Main(string[] args)
        {
            // Before running replace the servicebus namespace (next line) and REPLACESERVICEBUSKEY (app.config)
            string serviceNamespace = "jtarquino";
            string serviceBusKey = "REPLACEKEYHERE";
            Console.Write("Your Service Namespace: ");

            // Tranport level security is required for all *RelayBindings; hence, using https is required
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Timer");

            WebServiceHost host = new WebServiceHost(typeof(ProblemSolver), address);

            WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);

            host.AddServiceEndpoint(
               typeof(IProblemSolver), binding, address)
                .Behaviors.Add(new TransportClientEndpointBehavior
                {
                    TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", serviceBusKey)
                });

            host.Open();
            Console.WriteLine(address + "CurrentTime");
            Console.WriteLine("Press ENTER to close");
            Console.ReadLine();

            host.Close();
        }
Beispiel #3
0
        private static void Two()
        {
            Console.WriteLine("Starting service...");

            // Configure the credentials through an endpoint behavior.
            TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
            relayCredentials.TokenProvider =
              TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "fBLL/4/+rEsCOiTQPNPS6DJQybykqE2HdVBsILrzMLY=");

            // Create the binding with default settings.
            WebHttpRelayBinding binding = new WebHttpRelayBinding();

            binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None;
            // Get the service address.
            // Use the https scheme because by default the binding uses SSL for transport security.
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", "johnsonwangnz", "Rest");

            // Create the web service host.
            WebServiceHost host = new WebServiceHost(typeof(EchoRestService), address);
            // Add the service endpoint with the WS2007HttpRelayBinding.
            host.AddServiceEndpoint(typeof(IEchoRestContract), binding, address);

            // Add the credentials through the endpoint behavior.
            host.Description.Endpoints[0].Behaviors.Add(relayCredentials);

            // Start the service.
            host.Open();

            Console.WriteLine("Listening...");

            Console.ReadLine();
            host.Close();
        }
Beispiel #4
0
        public async Task Run(string httpAddress, string listenToken)
        {
            using (var host = new WebServiceHost(this.GetType()))
            {
                var webHttpRelayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport,
                                                                  RelayClientAuthenticationType.RelayAccessToken)
                {
                    IsDynamic = false
                };
                host.AddServiceEndpoint(this.GetType(),
                                        webHttpRelayBinding,
                                        httpAddress)
                .EndpointBehaviors.Add(
                    new TransportClientEndpointBehavior(
                        TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken)));

                host.Open();

                Console.WriteLine("Copy the following address into a browser to see the image: ");
                Console.WriteLine(httpAddress + "/Image");
                Console.WriteLine();
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            // Before running replace the servicebus namespace (next line) and REPLACESERVICEBUSKEY (app.config)
            string serviceNamespace = "jtarquino";
            string serviceBusKey    = "REPLACEKEYHERE";

            Console.Write("Your Service Namespace: ");


            // Tranport level security is required for all *RelayBindings; hence, using https is required
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Timer");

            WebServiceHost host = new WebServiceHost(typeof(ProblemSolver), address);


            WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);

            host.AddServiceEndpoint(
                typeof(IProblemSolver), binding, address)
            .Behaviors.Add(new TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", serviceBusKey)
            });

            host.Open();
            Console.WriteLine(address + "CurrentTime");
            Console.WriteLine("Press ENTER to close");
            Console.ReadLine();

            host.Close();
        }
        public ReverseWebProxy(Uri upstreamUri, Uri downstreamUri, TransportClientEndpointBehavior credentials)
        {
            this.upstreamUri = upstreamUri;
            this.downstreamUri = downstreamUri;

            this.upstreamBasePath = this.upstreamUri.PathAndQuery;
            if (this.upstreamBasePath.EndsWith("/"))
            {
                this.upstreamBasePath = this.upstreamBasePath.Substring(0, this.upstreamBasePath.Length - 1);
            }

            ServicePointManager.DefaultConnectionLimit = 50;

            WebHttpRelayBinding relayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);
            relayBinding.MaxReceivedMessageSize = int.MaxValue;
            relayBinding.TransferMode = TransferMode.Streamed;
            relayBinding.AllowCookies = false;
            relayBinding.ReceiveTimeout = TimeSpan.MaxValue;
            relayBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            relayBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            this.upstreamBinding = relayBinding;

            WebMessageEncodingBindingElement encoderBindingElement = new WebMessageEncodingBindingElement();
            encoderBindingElement.ReaderQuotas.MaxArrayLength = int.MaxValue;
            encoderBindingElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            encoderBindingElement.ContentTypeMapper = new RawContentTypeMapper();
            encoder = encoderBindingElement.CreateMessageEncoderFactory().Encoder;

            this.credentials = credentials;
        }
        public async Task Run(string httpAddress, string listenToken)
        {
            using (var host = new WebServiceHost(this.GetType()))
            {
                var webHttpRelayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport,
                                                                  RelayClientAuthenticationType.RelayAccessToken)
                                                                 {IsDynamic = false};
                host.AddServiceEndpoint(this.GetType(),
                    webHttpRelayBinding,
                    httpAddress)
                    .EndpointBehaviors.Add(
                        new TransportClientEndpointBehavior(
                            TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken)));

                host.Open();

                Console.WriteLine("Copy the following address into a browser to see the image: ");
                Console.WriteLine(httpAddress + "/Image");
                Console.WriteLine();
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
 public Binding GetBinding()
 {
     var b = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);
     var elems = b.CreateBindingElements();
     var ee = elems.Find<WebMessageEncodingBindingElement>();
     ee.ContentTypeMapper = new RawContentTypeMapper();
     return new CustomBinding(elems);
 }
Beispiel #9
0
        private Binding GetBinding()
        {
            var b     = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport, RelayClientAuthenticationType.RelayAccessToken);
            var elems = b.CreateBindingElements();
            var ee    = elems.Find <WebMessageEncodingBindingElement>();
            var encc  = ee.CreateMessageEncoderFactory();

            return(new CustomBinding(elems));
        }
        private Binding GetBinding()
        {
            var b     = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);
            var elems = b.CreateBindingElements();
            var ee    = elems.Find <WebMessageEncodingBindingElement>();

            ee.ContentTypeMapper = new RawContentTypeMapper();
            return(new CustomBinding(elems));
        }
Beispiel #11
0
        private static Binding GetBinding(long maxReceivedMessageSize)
        {
            var webHttpRelayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None)
            {
                MaxReceivedMessageSize = maxReceivedMessageSize
            };
            var bindingElements = webHttpRelayBinding.CreateBindingElements();
            var webMessageEncodingBindingElement = bindingElements.Find <WebMessageEncodingBindingElement>();

            webMessageEncodingBindingElement.ContentTypeMapper = new RawContentTypeMapper();
            return(new CustomBinding(bindingElements));
        }
        protected override void InitializeRuntime()
        {
            TransportClientEndpointBehavior credentials = new TransportClientEndpointBehavior();
            credentials.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);

            var policyBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);
            var clientAccessPolicyXml = AddServiceEndpoint(typeof(IClientAccessPolicyXml), policyBinding, ServiceBusEnvironment.CreateServiceUri("http", this.serviceNameSpace, "ClientAccessPolicy.xml"));
            clientAccessPolicyXml.Behaviors.Add(credentials);
            var crossDomainXml = AddServiceEndpoint(typeof(ICrossDomainXml), policyBinding, ServiceBusEnvironment.CreateServiceUri("http", this.serviceNameSpace, "crossdomain.xml"));
            crossDomainXml.Behaviors.Add(credentials);

            base.InitializeRuntime();
        }
        public void ConfigureBinding_BindingPassed_ReturnsBindingsParameters()
        {
            // Arrange
            var config = new AzureServiceBusConfiguration();

            var binding = new WebHttpRelayBinding();

            // Act
            var bindingsParameters = config.ConfigureBinding(binding);
            var bindingParameter = bindingsParameters.Find<TransportClientEndpointBehavior>();

            // Assert
            Assert.NotNull(bindingParameter);
        }
        private static void Main()
        {
            Console.Write("Your Service Namespace Domain (ex. https://<DOMAIN>.servicebus.windows.net/): ");
            string serviceNamespaceDomain = Console.ReadLine();

            // By setting EndToEndWebHttpSecurityMode.Transport we use HTTPS.
            // If you want to use HTTP please set EndToEndWebHttpSecurityMode.None.
            // In this sample we need to authenticate client via Access Control Service so
            // RelayClientAuthenticationType.RelayAccessToken is set. You can set RelayClientAuthenticationType.None
            // If you don't want to authenticate client via Access Control Service.
            WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport, RelayClientAuthenticationType.RelayAccessToken);
            // Replace above code with the following one to test in browser
            // WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport, RelayClientAuthenticationType.None);

            // Initialize ServiceHost using custom binding
            Uri            address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespaceDomain, "DataService");
            WebServiceHost host    = new WebServiceHost(typeof(NorthwindDataService), address);

            host.AddServiceEndpoint("System.Data.Services.IRequestHandler", binding, address);
            var eb = new TransportClientEndpointBehavior()
            {
                CredentialType = TransportClientCredentialType.SharedSecret
            };

            eb.Credentials.SharedSecret.IssuerName   = "owner";
            eb.Credentials.SharedSecret.IssuerSecret = "[Your Secret]";
            host.Description.Endpoints[0].Behaviors.Add(eb);

            // The following behavior is used to work around exception caused by PUT/POST
            // requests when exposing via Service Bus
            MyBehavior mb = new MyBehavior();

            host.Description.Endpoints[0].Behaviors.Add(mb);

            // Start service
            host.Open();
            Console.WriteLine("Test the following URI in browser: ");
            Console.WriteLine(address + "Customers");
            Console.WriteLine("Use the following URI if you want to generate client proxy for this service");
            Console.WriteLine(address);
            Console.WriteLine();
            Console.WriteLine("Press [Enter] to exit");
            Console.ReadLine();

            host.Close();
        }
Beispiel #15
0
        protected override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding);
            WebHttpRelayBinding webHttpRelayBinding = (WebHttpRelayBinding)binding;

            this.MaxBufferSize          = webHttpRelayBinding.MaxBufferSize;
            this.MaxBufferPoolSize      = webHttpRelayBinding.MaxBufferPoolSize;
            this.MaxReceivedMessageSize = webHttpRelayBinding.MaxReceivedMessageSize;
            if (webHttpRelayBinding.ProxyAddress != null)
            {
                this.ProxyAddress = webHttpRelayBinding.ProxyAddress;
            }
            this.WriteEncoding      = webHttpRelayBinding.WriteEncoding;
            this.TransferMode       = webHttpRelayBinding.TransferMode;
            this.UseDefaultWebProxy = webHttpRelayBinding.UseDefaultWebProxy;
            this.AllowCookies       = webHttpRelayBinding.AllowCookies;
            this.Security.InitializeFrom(webHttpRelayBinding.Security);
            this.InitializeReaderQuotas(webHttpRelayBinding.ReaderQuotas);
            this.IsDynamic = webHttpRelayBinding.IsDynamic;
        }
        protected override void OnOpen(TimeSpan timeout)
        {
            var instancing = Description.Behaviors.Find <DelegateInstanceProviderServiceBehavior>();

            if (instancing == null)
            {
                instancing = new Func <object>(() => new RelayService(_server.CreateClient(), _loggerFactory));
                Description.Behaviors.Add(instancing);
            }

            var mode    = BaseAddresses.Single().Scheme == Uri.UriSchemeHttps ? EndToEndWebHttpSecurityMode.Transport : EndToEndWebHttpSecurityMode.None;
            var binding = new WebHttpRelayBinding(mode, RelayClientAuthenticationType.None);
            //binding.TransferMode = TransferMode.Streamed;

            var endpoint = AddServiceEndpoint(typeof(RelayService), binding, string.Empty);

            endpoint.Behaviors.Add(new WebHttpBehavior());
            endpoint.Behaviors.Add(new TransportClientEndpointBehavior(_serverOptions.SharedAccessKey));

            base.OnOpen(timeout);
        }
Beispiel #17
0
        protected override void OnApplyConfiguration(Binding binding)
        {
            WebHttpRelayBinding maxBufferPoolSize = (WebHttpRelayBinding)binding;

            maxBufferPoolSize.MaxBufferPoolSize      = this.MaxBufferPoolSize;
            maxBufferPoolSize.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            maxBufferPoolSize.WriteEncoding          = this.WriteEncoding;
            maxBufferPoolSize.TransferMode           = this.TransferMode;
            maxBufferPoolSize.UseDefaultWebProxy     = this.UseDefaultWebProxy;
            maxBufferPoolSize.IsDynamic    = this.IsDynamic;
            maxBufferPoolSize.AllowCookies = this.AllowCookies;
            if (this.ProxyAddress != null)
            {
                maxBufferPoolSize.ProxyAddress = this.ProxyAddress;
            }
            if (base.ElementInformation.Properties["maxBufferSize"].ValueOrigin != PropertyValueOrigin.Default)
            {
                maxBufferPoolSize.MaxBufferSize = this.MaxBufferSize;
            }
            this.Security.ApplyConfiguration(maxBufferPoolSize.Security);
            this.ApplyReaderQuotasConfiguration(maxBufferPoolSize.ReaderQuotas);
        }
        public void Run(string sbNamespace, string path, string keyName, string keyValue)
        {
            string httpsAddress = new UriBuilder("https", sbNamespace, -1, path).ToString();

            using (var host = new WebServiceHost(GetType()))
            {
                // Add an endpoint to receive requests over HTTPS without requiring Auth at the Relay Service
                var webBinding        = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport, RelayClientAuthenticationType.None);
                var tokenProvider     = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, keyValue);
                var transportBehavior = new TransportClientEndpointBehavior(tokenProvider);
                var endpoint          = host.AddServiceEndpoint(typeof(GridServiceListener), webBinding, httpsAddress);
                endpoint.EndpointBehaviors.Add(transportBehavior);

                host.Open();
                Console.WriteLine($"Listening at: {httpsAddress}?code={sbKeyValue}");

                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
        /// <summary>
        /// Prompts for required information and hosts a service until the user ends the
        /// session.
        /// </summary>
        public void Run()
        {
            //<snippetRestListener1>
            ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

            Console.Write("Enter your Azure service namespace: ");
            string serviceNamespace = Console.ReadLine();

            // The service namespace issuer name to use.  If one hasn't been setup
            // explicitly it will be the default issuer name listed on the service
            // namespace.
            Console.Write("Enter your service namespace issuer name: ");
            string issuerName = Console.ReadLine();

            // Issuer secret is the Windows Azure Service Bus namespace current management key.
            Console.Write("Enter your service namespace issuer key: ");
            string issuerKey = Console.ReadLine();

            // Input the same path that was specified in the Service Bus Configuration dialog
            // when registering the Azure-aware plug-in with the Plug-in Registration tool.
            Console.Write("Enter your endpoint path: ");
            string servicePath = Console.ReadLine();

            // Leverage the Azure API to create the correct URI.
            Uri address = ServiceBusEnvironment.CreateServiceUri(
                Uri.UriSchemeHttps,
                serviceNamespace,
                servicePath);

            Console.WriteLine("The service address is: " + address);

            // Create the shared secret credentials object for the endpoint matching the
            // Azure access control services issuer
            var sharedSecretServiceBusCredential = new TransportClientEndpointBehavior()
            {
                TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey)
            };

            // Using an HTTP binding instead of a SOAP binding for this RESTful endpoint.
            WebHttpRelayBinding binding = new WebHttpRelayBinding();

            binding.Security.Mode = EndToEndWebHttpSecurityMode.Transport;

            // Create the service host for Azure to post messages to.
            WebServiceHost host = new WebServiceHost(typeof(RestServiceEndPoint));

            host.AddServiceEndpoint(typeof(IWebHttpServiceEndpointPlugin), binding, address);

            // Create the ServiceRegistrySettings behavior for the endpoint.
            var serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public);

            // Add the service bus credentials to all endpoints specified in configuration.

            foreach (var endpoint in host.Description.Endpoints)
            {
                endpoint.Behaviors.Add(serviceRegistrySettings);
                endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
            }

            // Begin listening for messages posted to Azure.
            host.Open();

            Console.WriteLine(Environment.NewLine + "Listening for messages from Azure" +
                              Environment.NewLine + "Press [Enter] to exit");

            // Keep the listener open until Enter is pressed.
            Console.ReadLine();

            Console.Write("Closing the service host...");
            host.Close();
            Console.WriteLine(" done.");
            //</snippetRestListener1>
        }
Beispiel #20
0
        /// <summary>
        /// Prompts for required information and hosts a service until the user ends the 
        /// session.
        /// </summary>
        public void Run()
        {
            //<snippetRestListener1>
            ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

            Console.Write("Enter your Azure service namespace: ");
            string serviceNamespace = Console.ReadLine();

            // The service namespace issuer name to use.  If one hasn't been setup
            // explicitly it will be the default issuer name listed on the service
            // namespace.
            Console.Write("Enter your service namespace issuer name: ");
            string issuerName = Console.ReadLine();

            // Issuer secret is the Windows Azure Service Bus namespace current management key.
            Console.Write("Enter your service namespace issuer key: ");
            string issuerKey = Console.ReadLine();

            // Input the same path that was specified in the Service Bus Configuration dialog
            // when registering the Azure-aware plug-in with the Plug-in Registration tool.
            Console.Write("Enter your endpoint path: ");
            string servicePath = Console.ReadLine();

            // Leverage the Azure API to create the correct URI.
            Uri address = ServiceBusEnvironment.CreateServiceUri(
                Uri.UriSchemeHttps,
                serviceNamespace,
                servicePath);

            Console.WriteLine("The service address is: " + address);

            // Create the shared secret credentials object for the endpoint matching the 
            // Azure access control services issuer 
            var sharedSecretServiceBusCredential = new TransportClientEndpointBehavior() 
            {
                TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey)
            };
           
            // Using an HTTP binding instead of a SOAP binding for this RESTful endpoint.
            WebHttpRelayBinding binding = new WebHttpRelayBinding();
            binding.Security.Mode = EndToEndWebHttpSecurityMode.Transport;

            // Create the service host for Azure to post messages to.
            WebServiceHost host = new WebServiceHost(typeof(RestServiceEndPoint));
            host.AddServiceEndpoint(typeof(IWebHttpServiceEndpointPlugin), binding, address);

            // Create the ServiceRegistrySettings behavior for the endpoint.
            var serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public);

            // Add the service bus credentials to all endpoints specified in configuration.

            foreach (var endpoint in host.Description.Endpoints)
            {
                endpoint.Behaviors.Add(serviceRegistrySettings);
                endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
            }

            // Begin listening for messages posted to Azure.
            host.Open();

            Console.WriteLine(Environment.NewLine + "Listening for messages from Azure" +
                Environment.NewLine + "Press [Enter] to exit");

            // Keep the listener open until Enter is pressed.
            Console.ReadLine();

            Console.Write("Closing the service host...");
            host.Close();
            Console.WriteLine(" done.");
            //</snippetRestListener1>
        }
        private void BeginOpenListener(AzureServiceBusHttpServer server)
        {
            Contract.Assert(server != null);

            try
            {
                // Create WCF HTTP transport channel
                var binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);

                // Get it configured
                BindingParameterCollection bindingParameters = server._configuration.ConfigureBinding(binding);
                if (bindingParameters == null)
                {
                    bindingParameters = new BindingParameterCollection();
                }

                // Build channel listener
                server._listener = binding.BuildChannelListener<IReplyChannel>(server._configuration.BaseAddress, bindingParameters);

                if (server._listener == null)
                {
                    throw new InvalidOperationException(string.Format("Error creating '{0}' instance using '{1}'.", typeof(IChannelListener).Name, typeof(IReplyChannel).Name));
                }

                IAsyncResult result = server._listener.BeginOpen(_onOpenListenerComplete, server);

                if (result.CompletedSynchronously)
                {
                    OpenListenerComplete(result);
                }
            }
            catch (Exception e)
            {
                FaultTask(server._openTaskCompletionSource, e);
            }
        }