protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding) { httpBinding.Security.Mode = HttpBindingSecurityMode.TransportCredentialOnly; httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; this.UserNamePasswordValidator = _functionalUserNamePasswordValidator; return(base.OnConfigureBinding(httpBinding)); }
private static void BeginOpenListener(HttpSelfHostServer server) { Contract.Assert(server != null); try { // Create WCF HTTP transport channel HttpBinding binding = new HttpBinding(); // 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 Error.InvalidOperation(SRResources.InvalidChannelListener, 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); } }
public void HttpSelfHostConfiguration_Settings_PropagateToBinding() { // Arrange HttpBinding binding = new HttpBinding(); binding.ConfigureTransportBindingElement = ConfigureTransportBindingElement; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost") { MaxBufferSize = 10, MaxReceivedMessageSize = 11, ReceiveTimeout = new TimeSpan(1, 0, 0), SendTimeout = new TimeSpan(1, 0, 0), TransferMode = TransferMode.StreamedResponse, HostNameComparisonMode = HostNameComparisonMode.WeakWildcard }; // Act config.ConfigureBinding(binding); // Assert Assert.Equal(10, binding.MaxBufferSize); Assert.Equal(11, binding.MaxReceivedMessageSize); Assert.Equal(new TimeSpan(1, 0, 0), binding.ReceiveTimeout); Assert.Equal(new TimeSpan(1, 0, 0), binding.SendTimeout); Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode); Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode); Assert.Equal(Net.AuthenticationSchemes.Ntlm, binding.CreateBindingElements().Find <HttpTransportBindingElement>().AuthenticationScheme); }
public void HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding( string address, HttpBindingSecurityMode mode ) { // Arrange HttpBinding binding = new HttpBinding(); UserNamePasswordValidator validator = new Mock <UserNamePasswordValidator>().Object; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address) { UserNamePasswordValidator = validator }; // Act BindingParameterCollection parameters = config.ConfigureBinding(binding); // Assert Assert.NotNull(parameters); ServiceCredentials serviceCredentials = parameters.Find <ServiceCredentials>(); Assert.NotNull(serviceCredentials); Assert.Equal( HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType ); Assert.Equal(mode, binding.Security.Mode); }
public void SetResponse_ActionResultConverted_Succeeded() { FieldInfo fieldInfo = typeof(HttpBinding).GetField("isActionResultHandlingEnabled", BindingFlags.NonPublic | BindingFlags.Static); bool oldValue = (bool)fieldInfo.GetValue(null); fieldInfo.SetValue(null, true); try { var httpContext1 = new DefaultHttpContext(); ActionResult <string> result1 = new ActionResult <string>("test"); HttpBinding.SetResponse(httpContext1.Request, result1); Assert.Equal("test", ((ObjectResult)httpContext1.Request.HttpContext.Items[ScriptConstants.AzureFunctionsHttpResponseKey]).Value); var httpContext2 = new DefaultHttpContext(); ActionResult <DummyClass> result2 = new ActionResult <DummyClass>(new DummyClass { Value = "test" }); HttpBinding.SetResponse(httpContext2.Request, result2); var resultObject = ((ObjectResult)httpContext2.Request.HttpContext.Items[ScriptConstants.AzureFunctionsHttpResponseKey]).Value; Assert.IsType <DummyClass>(resultObject); Assert.Equal("test", ((DummyClass)resultObject).Value); } finally { fieldInfo.SetValue(null, oldValue); } }
static void Main(string[] args) { Uri listenUri = new Uri("http://127.0.0.1:3721"); Binding binding = new HttpBinding(); //创建、开启信道监听器 IChannelListener <IReplyChannel> channelListener = binding.BuildChannelListener <IReplyChannel>(listenUri); channelListener.Open(); //创建、开启回复信道 IReplyChannel channel = channelListener.AcceptChannel(TimeSpan.MaxValue); channel.Open(); //开始监听 while (true) { //接收输出请求消息 RequestContext requestContext = channel.ReceiveRequest(TimeSpan.MaxValue); PrintRequestMessage(requestContext.RequestMessage); //消息回复 requestContext.Reply(CreateResponseMessage()); } }
protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding) { httpBinding.Security.Mode = HttpBindingSecurityMode.Transport; httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; httpBinding.ConfigureTransportBindingElement = element => element.AuthenticationScheme = AuthenticationSchemes.Negotiate; return(base.OnConfigureBinding(httpBinding)); }
public static void ListenerThread() { while (true) { HttpListenerContext context = Listener.GetContext(); HttpListenerRequest request = context.Request; HttpListenerResponse response = context.Response; Stream strm = response.OutputStream; HttpBinding binding = Bindings.Find(bind => bind.Path == request.Url.AbsolutePath); lock (Intrp) { Intrp.State.MainStack.Push(binding.Function); Intrp.State.Call("[Unknown]"); LuaValue ret = Intrp.State.MainStack.Pop(); byte[] bytes = Encoding.UTF8.GetBytes(ret.String()); strm.Write(bytes, 0, bytes.Length); strm.Close(); } } }
protected override DeviceClient CreateClient() { HttpBinding binding = (HttpBinding)CreateBinding(true); DeviceClient client = new DeviceClient(binding, new EndpointAddress(CameraAddress)); return(client); }
/// <summary> /// 网络监听任务ChannelListener管道创建的消息处理管道最终实现了对请求的接收和响应的发送 /// </summary> /// <param name="args"></param> public static void Main(string[] args) { //1、httpselfhost openAsync开启之后逻辑 Uri listenUri = new Uri("http://127.0.0.1:3721"); Binding binding = new HttpBinding(); //创建 开启 信道监听器 IChannelListener <IReplyChannel> channelListener = binding.BuildChannelListener <IReplyChannel>(listenUri); //可以使用异步的方式开启 //channelListener.BeginOpen(); channelListener.Open(); //创建 开启 回复信道 IReplyChannel channel = channelListener.AcceptChannel(TimeSpan.FromDays(24)); channel.Open(); while (true) { RequestContext requestContext = channel.ReceiveRequest(TimeSpan.MaxValue); PrintRequestMessage(requestContext.RequestMessage); //消息回复 requestContext.Reply(CreateResponseMessage()); } }
/// <summary> /// Creates client. /// </summary> void CreateClient() { Data.DeviceEnvironment info = Controllers.ContextController.GetDeviceEnvironment(); EndpointController controller = new EndpointController(new EndpointAddress(_serviceAddress)); CredentialsProvider credentialsProvider = new CredentialsProvider(); credentialsProvider.Username = info.Credentials.UserName; credentialsProvider.Password = info.Credentials.Password; Binding binding = new HttpBinding(new IChannelController[] { this, controller, credentialsProvider }); _client = CreateClient(binding, new EndpointAddress(_serviceAddress)); System.Net.ServicePointManager.Expect100Continue = false; SecurityBehavior securityBehavior = new SecurityBehavior(); securityBehavior.UserName = info.Credentials.UserName; securityBehavior.Password = info.Credentials.Password; securityBehavior.UseUTCTimestamp = info.Credentials.UseUTCTimeStamp; _client.Endpoint.Behaviors.Add(securityBehavior); _client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, 0, _messageTimeout); }
public void Open() { HttpBinding binding = new HttpBinding(); this.ChannelListener = binding.BuildChannelListener <IReplyChannel>(this.BaseAddress); this.ChannelListener.Open(); IReplyChannel channnel = this.ChannelListener.AcceptChannel(); channnel.Open(); while (true) { RequestContext requestContext = channnel.ReceiveRequest(TimeSpan.MaxValue); Message message = requestContext.RequestMessage; MethodInfo method = message.GetType().GetMethod("GetHttpRequestMessage"); HttpRequestMessage request = (HttpRequestMessage)method.Invoke(message, new object[] { true }); Task <HttpResponseMessage> processResponse = base.SendAsync(request, new CancellationTokenSource().Token); processResponse.ContinueWith(task => { string httpMessageTypeName = "System.Web.Http.SelfHost.Channels.HttpMessage, System.Web.Http.SelfHost"; Type httpMessageType = Type.GetType(httpMessageTypeName); Message reply = (Message)Activator.CreateInstance(httpMessageType, new object[] { task.Result }); requestContext.Reply(reply); }); } }
static ArrayList GetBindingTypes(ServiceDescriptionCollection col) { ServiceDescription doc = col [0]; ArrayList list = new ArrayList(); foreach (Service s in doc.Services) { foreach (Port p in s.Ports) { Binding bin = col.GetBinding(p.Binding); if (bin.Extensions.Find(typeof(System.Web.Services.Description.SoapBinding)) != null) { if (!list.Contains("Soap")) { list.Add("Soap"); } } HttpBinding ext = (HttpBinding)bin.Extensions.Find(typeof(HttpBinding)); if (ext != null) { if (ext.Verb == "POST") { list.Add("HttpPost"); } else { list.Add("HttpGet"); } } } } return(list); }
/// <summary> /// Asserts that an <see cref="HttpRequestMessage"/> sent to the self-hosted HTTP <paramref name="serviceSingleton"/> /// results in the actual <see cref="HttpResponseMessage"/> given by the <paramref name="onGetActualResponse"/> <see cref="Action<>"/>. /// </summary> /// <param name="serviceSingleton">The singleton for the self-hosted HTTP service. Should not be <c>null</c>.</param> /// <param name="behavior">The <see cref="HttpBehavior"/> to use with the HTTP service.</param> /// <param name="binding">The <see cref="HttpBinding"/> to use with the HTTP service.</param> /// <param name="request">The <see cref="HttpRequestMessage"/> instance to send to the self-hosted HTTP service. Should not be <c>null</c>.</param> /// <param name="onGetActualResponse">The actual <see cref="HttpResponseMessage"/> instance provided as an <see cref="Action<>"/>. Should not be <c>null</c>.</param> public static void Execute(object serviceSingleton, HttpBehavior behavior, HttpBinding binding, HttpRequestMessage request, Action <HttpResponseMessage> onGetActualResponse) { Assert.IsNotNull(serviceSingleton, "The 'serviceSingleton' parameter should not be null."); Assert.IsNotNull(request, "The 'request' parameter should not be null."); Assert.IsNotNull(onGetActualResponse, "The 'onGetActualResponse' parameter should not be null."); ServiceHostAssert.Execute((baseAddress) => GetServiceHost(serviceSingleton, behavior, binding, baseAddress), request, onGetActualResponse); }
public void HttpBinding_Correctly_Configured_With_Empty_Name_Configuration() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBindingTest.config", () => { HttpBinding binding = new HttpBinding(""); Assert.AreEqual(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode, "Binding.HostNameComparisonMode should have been HostNameComparisonMode.WeakWildcard."); }); }
protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding) { httpBinding.ConfigureTransportBindingElement = element => { element.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous | System.Net.AuthenticationSchemes.Ntlm; }; return(base.OnConfigureBinding(httpBinding)); }
/// <summary> /// Asserts that an <see cref="HttpRequestMessage"/> sent to the self-hosted HTTP <paramref name="serviceType"/> /// results in a response that is equivalent to the expected <see cref="HttpResponseMessage"/>. /// </summary> /// <param name="serviceType">The service type to use for the self-hosted HTTP service. Should not be <c>null</c>.</param> /// <param name="behavior">The <see cref="HttpBehavior"/> to use with the HTTP service.</param> /// <param name="binding">The <see cref="HttpBinding"/> to use with the HTTP service.</param> /// <param name="request">The <see cref="HttpRequestMessage"/> instance to send to the self-hosted HTTP service. Should not be <c>null</c>.</param> /// <param name="expectedResponse">The expected <see cref="HttpResponseMessage"/>. Should not be <c>null</c>.</param> public static void Execute(Type serviceType, HttpBehavior behavior, HttpBinding binding, HttpRequestMessage request, HttpResponseMessage expectedResponse) { Assert.IsNotNull(serviceType, "The 'serviceType' parameter should not be null."); Assert.IsNotNull(request, "The 'request' parameter should not be null."); Assert.IsNotNull(expectedResponse, "The 'expectedResponse' parameter should not be null."); ServiceHostAssert.Execute((baseAddress) => GetServiceHost(serviceType, behavior, binding, baseAddress), request, expectedResponse); }
/// <summary> /// Called to apply the configuration on the endpoint level. /// </summary> /// <param name="httpBinding">Http endpoint.</param> /// <returns>The <see cref="BindingParameterCollection"/> to use when building the <see cref="IChannelListener"/> or null if no binding parameters are present.</returns> protected virtual BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding) { if (httpBinding == null) { throw Error.ArgumentNull("httpBinding"); } if (_clientCredentialType != HttpClientCredentialType.Basic && _credentials.UserNameAuthentication.CustomUserNamePasswordValidator != null) { throw Error.InvalidOperation(SRResources.CannotUseOtherClientCredentialTypeWithUserNamePasswordValidator); } if (_clientCredentialType != HttpClientCredentialType.Certificate && _credentials.ClientCertificate.Authentication.CustomCertificateValidator != null) { throw Error.InvalidOperation(SRResources.CannotUseOtherClientCredentialTypeWithX509CertificateValidator); } httpBinding.MaxBufferSize = MaxBufferSize; httpBinding.MaxReceivedMessageSize = MaxReceivedMessageSize; httpBinding.TransferMode = TransferMode; httpBinding.HostNameComparisonMode = HostNameComparisonMode; httpBinding.ReceiveTimeout = ReceiveTimeout; httpBinding.SendTimeout = SendTimeout; // Set up binding parameters if (_baseAddress.Scheme == Uri.UriSchemeHttps) { // we need to use SSL httpBinding.Security = new HttpBindingSecurity() { Mode = HttpBindingSecurityMode.Transport, }; } if (_clientCredentialType != HttpClientCredentialType.None) { if (httpBinding.Security == null || httpBinding.Security.Mode == HttpBindingSecurityMode.None) { // Basic over HTTP case httpBinding.Security = new HttpBindingSecurity() { Mode = HttpBindingSecurityMode.TransportCredentialOnly, }; } httpBinding.Security.Transport.ClientCredentialType = _clientCredentialType; } if (UserNamePasswordValidator != null || X509CertificateValidator != null) { // those are the only two things that affect service credentials return(AddCredentialsToBindingParameters()); } else { return(null); } }
private string GetProtocol (Binding binding) { if (binding.Extensions.Find (typeof(SoapBinding)) != null) return "Soap"; HttpBinding hb = (HttpBinding) binding.Extensions.Find (typeof(HttpBinding)); if (hb == null) return ""; if (hb.Verb == "POST") return "HttpPost"; if (hb.Verb == "GET") return "HttpGet"; return ""; }
protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding) { if (BaseAddress.ToString().ToLower().Contains("https://")) { httpBinding.Security.Mode = HttpBindingSecurityMode.Transport; } return(base.OnConfigureBinding(httpBinding)); }
public override EventPortTypeClient CreateClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress address) { EndpointController controller = new EndpointController(new EndpointAddress(_serviceAddress)); controller.WsaEnabled = true; Binding binding1 = new HttpBinding(new IChannelController[] { this, controller, _credentialsProvider }); return(new EventPortTypeClient(binding1, address)); }
public override EventPortTypeClient CreateClient(Binding binding, EndpointAddress address) { EndpointController controller = new EndpointController(new EndpointAddress(_serviceAddress)); WsaController wsaController = new WsaController(); Binding eventBinding = new HttpBinding(new IChannelController[] { this, controller, wsaController, _credentialsProvider }); return(new EventPortTypeClient(eventBinding, address)); }
protected override DeviceClient CreateClient() { HttpBinding binding = (HttpBinding)CreateBinding(true, new IChannelController[] { new SoapValidator(DeviceManagementSchemasSet.GetInstance()) }); DeviceClient client = new DeviceClient(binding, new EndpointAddress(_cameraAddress)); return(client); }
public static ServiceHost CreateHost <T>(bool asynchronousSendEnabled, bool customBinding, bool faultDetail, bool streamed, HttpMessageHandlerFactory httpMessageHandlerFactory) where T : TestServiceBase { var webHost = new WebServiceHost(typeof(T), TestServiceCommon.ServiceAddress); if (faultDetail && webHost.Description.Behaviors.Contains(typeof(ServiceDebugBehavior))) { var debug = webHost.Description.Behaviors[typeof(ServiceDebugBehavior)] as ServiceDebugBehavior; debug.IncludeExceptionDetailInFaults = true; } Binding httpBinding = null; if (customBinding) { var bindingElement = new HttpMessageHandlerBindingElement(); bindingElement.MessageHandlerFactory = httpMessageHandlerFactory; var httpMsgBinding = new HttpBinding(); if (streamed) { httpMsgBinding.TransferMode = TransferMode.Streamed; } var bindingElements = httpMsgBinding.CreateBindingElements(); bindingElements.Insert(0, bindingElement); httpBinding = new CustomBinding(bindingElements); } else { var httpMsgBinding = new HttpBinding() { MessageHandlerFactory = httpMessageHandlerFactory }; if (streamed) { httpMsgBinding.TransferMode = TransferMode.Streamed; } httpBinding = httpMsgBinding; } var endpoint = webHost.AddServiceEndpoint(typeof(ITestServiceContract), httpBinding, ""); ServiceDebugBehavior debugBehavior = webHost.Description.Behaviors.Find <ServiceDebugBehavior>(); DispatcherSynchronizationBehavior synchronizationBehavior = new DispatcherSynchronizationBehavior() { AsynchronousSendEnabled = asynchronousSendEnabled }; endpoint.Behaviors.Add(synchronizationBehavior); endpoint.Behaviors.Add(new TestHttpBindingParameterBehavior(debugBehavior, synchronizationBehavior)); webHost.Open(); return(webHost); }
public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("MimeXmlBinding_Part_3_Input_CS.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); // Initialize 'Name' property of 'Binding' class. myBinding.Name = "MimeXmlBinding_Part_3_ServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:MimeXmlBinding_Part_3_ServiceHttpPost"); myBinding.Type = myXmlQualifiedName; // Create the 'HttpBinding' object. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; // Add the 'HttpBinding' to the 'Binding'. myBinding.Extensions.Add(myHttpBinding); // Create the 'OperationBinding' object. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding(); myHttpOperationBinding.Location = "/AddNumbers"; // Add the 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myHttpOperationBinding); // Create the 'InputBinding' object. InputBinding myInputBinding = new InputBinding(); MimeContentBinding myMimeContentBinding = new MimeContentBinding(); myMimeContentBinding.Type = "application/x-www-form-urlencoded"; myInputBinding.Extensions.Add(myMimeContentBinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; // Create an OutputBinding. OutputBinding myOutputBinding = new OutputBinding(); MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding(); // Initialize the Part property of the MimeXmlBinding. myMimeXmlBinding.Part = "Body"; // Add the MimeXmlBinding to the OutputBinding. myOutputBinding.Extensions.Add(myMimeXmlBinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutputBinding; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("MimeXmlBinding_Part_3_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'MimeXmlBinding_Part_3_Output_CS.wsdl' is" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
static void HostWithHttpsAndNoneClientCredential() { using (var host = new HttpServiceHost(typeof(TheResourceClass), new string[0])) { var binding = new HttpBinding(HttpBindingSecurityMode.Transport); binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; host.AddServiceEndpoint(typeof(TheResourceClass), binding, "https://localhost:8435/greet"); host.Open(); Console.WriteLine("Service is opened, press any key to continue"); Console.ReadKey(); } }
public void AddResponseHeader_ContentDisposition_AddsExpectedHeader() { HttpResponseMessage response = new HttpResponseMessage() { Content = new StringContent("Test") }; var cd = "attachment; filename=\"test.txt\""; var header = new KeyValuePair <string, object>("content-disposition", cd); HttpBinding.AddResponseHeader(response, header); Assert.Equal(cd, response.Content.Headers.ContentDisposition.ToString()); }
/// <summary> /// Initializes the <see cref="HttpBindingElement"/> from an /// <see cref="Microsoft.ApplicationServer.Http.HttpBinding">HttpBinding</see> instance. /// </summary> /// <param name="binding"> /// The <see cref="Microsoft.ApplicationServer.Http.HttpBinding">HttpBinding</see> instance from which /// the <see cref="HttpBindingElement"/> will be initialized. /// </param> protected override void InitializeFrom(Binding binding) { base.InitializeFrom(binding); HttpBinding httpBinding = (HttpBinding)binding; SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, httpBinding.HostNameComparisonMode); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, httpBinding.MaxBufferSize); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferPoolSize, httpBinding.MaxBufferPoolSize); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReceivedMessageSize, httpBinding.MaxReceivedMessageSize); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, httpBinding.TransferMode); this.Security.InitializeFrom(httpBinding.Security); }
/// <summary> /// Creates PullPointSubscription client using address passed. /// </summary> /// <param name="address">Service address.</param> /// <returns></returns> protected PullPointSubscriptionClient CreatePullPointSubscriptionClient(EndpointReferenceType endpointReference) { HttpBinding binding = CreateEventServiceBinding(endpointReference.Address.Value); _pullPointSubscriptionClient = new PullPointSubscriptionClient(binding, new EndpointAddress(endpointReference.Address.Value)); AddSecurityBehaviour(_pullPointSubscriptionClient.Endpoint); AttachAddressing(_pullPointSubscriptionClient.Endpoint, endpointReference); SetupTimeout(_pullPointSubscriptionClient.InnerChannel); return(_pullPointSubscriptionClient); }
public static void Listen(IndexStack <LuaValue> Stack) { LuaFunction func = (LuaFunction)Stack.Pop(); LuaValue val = Stack.Pop(); HttpBinding binding = new HttpBinding(); binding.Path = val.String(); binding.Function = func; Bindings.Add(binding); }
public void HttpBindingElement_Ctor_Initializes_All_Properties() { HttpBindingElement element = new HttpBindingElement(); HttpBinding binding = new HttpBinding(); Assert.AreEqual(binding.CloseTimeout, element.CloseTimeout, "The HttpBinding and HttpBindingElement should have the same default CloseTimeout"); Assert.AreEqual(binding.HostNameComparisonMode, element.HostNameComparisonMode, "The HttpBinding and HttpBindingElement should have the same default HostNameComparisonMode"); Assert.AreEqual(binding.MaxBufferPoolSize, element.MaxBufferPoolSize, "The HttpBinding and HttpBindingElement should have the same default MaxBufferPoolSize"); Assert.AreEqual(binding.MaxBufferSize, element.MaxBufferSize, "The HttpBinding and HttpBindingElement should have the same default MaxBufferSize"); Assert.AreEqual(binding.MaxReceivedMessageSize, element.MaxReceivedMessageSize, "The HttpBinding and HttpBindingElement should have the same default MaxReceivedMessageSize"); Assert.AreEqual(binding.OpenTimeout, element.OpenTimeout, "The HttpBinding and HttpBindingElement should have the same default OpenTimeout"); Assert.AreEqual(binding.ReceiveTimeout, element.ReceiveTimeout, "The HttpBinding and HttpBindingElement should have the same default ReceiveTimeout"); Assert.AreEqual(binding.SendTimeout, element.SendTimeout, "The HttpBinding and HttpBindingElement should have the same default ReceiveTimeout"); Assert.AreEqual(binding.TransferMode, element.TransferMode, "The HttpBinding and HttpBindingElement should have the same default TransferMode"); }
public void HttpBinding_Correctly_Configured_With_Name_Configuration() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBindingTest.config", () => { HttpBinding binding = new HttpBinding("configuredBinding"); Assert.AreEqual(HostNameComparisonMode.Exact, binding.HostNameComparisonMode, "Binding.HostNameComparisonMode should have been HostNameComparisonMode.Exact."); Assert.AreEqual(500, binding.MaxBufferPoolSize, "Binding.MaxBufferPoolSize should have been 500."); Assert.AreEqual(100, binding.MaxReceivedMessageSize, "Binding.MaxReceivedMessageSize should have been 100."); Assert.AreEqual(200, binding.MaxBufferSize, "Binding.MaxBufferSize should have been 200."); Assert.AreEqual(TransferMode.StreamedResponse, binding.TransferMode, "Binding.TransferMode should have been TransferMode.StreamedResponse."); Assert.AreEqual(HttpBindingSecurityMode.Transport, binding.Security.Mode, "Binding.Security.Mode should have been HttpBindingSecurityMode.Transport."); Assert.AreEqual("someConfigRealm", binding.Security.Transport.Realm, "Binding.Security.Transport.Realm should have been 'someConfigRealm'."); Assert.AreEqual(HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType, "Binding.Security.Transport.ClientCredentialType should have been HttpClientCredentialType.Basic."); Assert.AreEqual(HttpProxyCredentialType.Ntlm, binding.Security.Transport.ProxyCredentialType, "Binding.Security.Transport.ProxyCredentialType should have been HttpProxyCredentialType.Ntlm."); Assert.AreEqual(PolicyEnforcement.WhenSupported, binding.Security.Transport.ExtendedProtectionPolicy.PolicyEnforcement, "Binding.Transport.ExtendedProtectionPolicy.PolicyEnforcement should have been PolicyEnforcement.WhenSupported"); }); }
public void Validate_Throws_With_Non_ManualAddressing() { HttpBehavior behavior = new HttpBehavior(); ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(CustomerService))); BindingElementCollection bindingElements = new HttpBinding().CreateBindingElements(); (bindingElements[bindingElements.Count - 1] as HttpTransportBindingElement).ManualAddressing = false; endpoint.Binding = new CustomBinding(bindingElements); endpoint.Address = new EndpointAddress("http://somehost"); ExceptionAssert.Throws<InvalidOperationException>( "Non-manual addressing should throw", Http.SR.InvalidManualAddressingValue(endpoint.Address.Uri.AbsoluteUri), () => behavior.Validate(endpoint)); }