当前位置: 首页>>代码示例>>C#>>正文


C# ServiceModel.WSHttpBinding类代码示例

本文整理汇总了C#中System.ServiceModel.WSHttpBinding的典型用法代码示例。如果您正苦于以下问题:C# WSHttpBinding类的具体用法?C# WSHttpBinding怎么用?C# WSHttpBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WSHttpBinding类属于System.ServiceModel命名空间,在下文中一共展示了WSHttpBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            try
            {
                ServiceHost dataExchangeService = null;
                Uri httpBaseAddress = new Uri(args.Length == 0 ? "http://127.0.0.1:8080" : args[0]);

                dataExchangeService = new ServiceHost(typeof(Service), httpBaseAddress);
                WSHttpBinding binding = new WSHttpBinding();
                binding.Security = new WSHttpSecurity { Mode = SecurityMode.None };

                binding.Security.Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None };
                binding.MaxBufferPoolSize = 1073741824;
                binding.MaxReceivedMessageSize = 1073741824;
                binding.ReceiveTimeout = TimeSpan.FromHours(1);
                binding.SendTimeout = TimeSpan.FromHours(1);
                binding.ReaderQuotas.MaxArrayLength = 1073741824;
                binding.ReaderQuotas.MaxBytesPerRead = 1073741824;
                binding.ReaderQuotas.MaxDepth = 1073741824;
                binding.ReaderQuotas.MaxStringContentLength = 1073741824;

                dataExchangeService.AddServiceEndpoint(typeof(IDataTranslation), binding, "");
                dataExchangeService.AddServiceEndpoint(typeof(IDataSimulation), binding, "");
                dataExchangeService.Open();
                logger.log("Service is now at: " + httpBaseAddress);
                while (true)
                {
                    Thread.Sleep(10000);
                }
            }
            catch (Exception ex)
            {
                logger.log( ex.Message, Logger.LogType.ERROR);
            }
        }
开发者ID:d4e-uninova,项目名称:dataExchangeSolution,代码行数:35,代码来源:Program.cs

示例2: Main

        private static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof (EvalService));

            WSHttpBinding noSecurityPlusRMBinding = new WSHttpBinding();
            noSecurityPlusRMBinding.Security.Mode = SecurityMode.None;
            noSecurityPlusRMBinding.ReliableSession.Enabled = true;

            host.AddServiceEndpoint(typeof (IEvalService), new BasicHttpBinding(), "http://localhost:8080/evals/basic");
            host.AddServiceEndpoint(typeof(IEvalService), noSecurityPlusRMBinding, "http://localhost:8080/evals/ws");
            //host.AddServiceEndpoint(typeof (IEvalService), new NetTcpBinding(), "net.tcp://localhost:8081/evals");

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.HttpGetUrl = new Uri("http://localhost:8080/evals/basic/meta");
            host.Description.Behaviors.Add(smb);

            try
            {
                host.Open();
                PrintServiceInfo(host);
                Console.ReadLine();
                host.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                host.Abort();
            }

            Console.ReadLine();
        }
开发者ID:JeffMck,项目名称:edu-WCF,代码行数:33,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8773/WSHttpService");

            WSHttpBinding binding = new WSHttpBinding();

            binding.Name = "WSHttp_Binding";
            binding.HostNameComparisonMode = HostNameComparisonMode.WeakWildcard;
            CustomBinding customBinding = new CustomBinding(binding);
            SymmetricSecurityBindingElement securityBinding = (SymmetricSecurityBindingElement)customBinding.Elements.Find<SecurityBindingElement>();

            /// Change the MaxClockSkew to 2 minutes on both service and client settings.
            TimeSpan newClockSkew = new TimeSpan(0, 2, 0);

            securityBinding.LocalServiceSettings.MaxClockSkew = newClockSkew;
            securityBinding.LocalClientSettings.MaxClockSkew = newClockSkew;

            using (ServiceHost host = new ServiceHost(typeof(WSHttpService), baseAddress))
            {
                host.AddServiceEndpoint(typeof(IWSHttpService), customBinding, "http://localhost:8773/WSHttpService/mex");
                // Enable metadata publishing.
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                host.Description.Behaviors.Add(smb);
                host.Open();

                Console.WriteLine("The service is ready at {0}", baseAddress);
                Console.WriteLine("Press <Enter> to stop the service.");
                Console.ReadLine();

                // Close the ServiceHost.
                host.Close();
            }
        }
开发者ID:zabidin901,项目名称:ReplayAttackWCFProtoType,代码行数:35,代码来源:Program.cs

示例4: Main

	public static void Main ()
	{
		ServiceHost host = new ServiceHost (typeof (Foo));
		WSHttpBinding binding = new WSHttpBinding ();
		binding.Security.Message.EstablishSecurityContext = false;
		binding.Security.Message.NegotiateServiceCredential = false;
		binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
		binding.ReceiveTimeout = TimeSpan.FromSeconds (5);
		host.AddServiceEndpoint ("IFoo",
			binding, new Uri ("http://localhost:8080"));
		ServiceCredentials cred = new ServiceCredentials ();
		cred.ServiceCertificate.Certificate =
			new X509Certificate2 ("test.pfx", "mono");
		cred.ClientCertificate.Authentication.CertificateValidationMode =
			X509CertificateValidationMode.None;
		host.Description.Behaviors.Add (cred);
		host.Description.Behaviors.Find<ServiceDebugBehavior> ()
			.IncludeExceptionDetailInFaults = true;
		foreach (ServiceEndpoint se in host.Description.Endpoints)
			se.Behaviors.Add (new StdErrInspectionBehavior ());
		ServiceMetadataBehavior smb = new ServiceMetadataBehavior ();
		smb.HttpGetEnabled = true;
		smb.HttpGetUrl = new Uri ("http://localhost:8080/wsdl");
		host.Description.Behaviors.Add (smb);
		host.Open ();
		Console.WriteLine ("Hit [CR] key to close ...");
		Console.ReadLine ();
		host.Close ();
	}
开发者ID:alesliehughes,项目名称:olive,代码行数:29,代码来源:samplesvc.cs

示例5: Main

        static void Main(string[] args)
        {
            // Configure IoC
            Container.Register(
                Component.For<IStockLookup>()
                .ImplementedBy<StockLookup>());

            // Configure Host
            using (var host = new ServiceHost(
                typeof(StockLookup),
                new Uri("http://localhost:1701/")))
            {
                var binding = new WSHttpBinding();
                var ep = host.AddServiceEndpoint(
                    typeof(IStockLookup),   // Contract
                    binding,                // Binding
                    "Stock");               // Address

                var ioc = new WindsorServiceBehavior();
                host.Description.Behaviors.Add(ioc);

                host.Open();
                Console.WriteLine("Host is now running...");
                Console.WriteLine(">>> Press Enter To Stop <<<");
                Console.ReadLine();
                host.Close();
            }
        }
开发者ID:trayburn,项目名称:Presentations.WcfTopics,代码行数:28,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            var baseAddress = new Uri("https://localhost:44355");

            using (var host = new ServiceHost(typeof(HelloWorldService), baseAddress))
            {
                var binding = new WSHttpBinding(SecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

                host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "localhost");
                host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck;
                host.Credentials.ClientCertificate.Authentication.TrustedStoreLocation = StoreLocation.LocalMachine;
                host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.ChainTrust;

                var endpoint = typeof(IHelloWorldService);
                host.AddServiceEndpoint(endpoint, binding, baseAddress);

                var metaBehavior = new ServiceMetadataBehavior();
                metaBehavior.HttpGetEnabled = true;
                metaBehavior.HttpGetUrl = new Uri("http://localhost:9000/mex");
                metaBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                host.Description.Behaviors.Add(metaBehavior);

                host.Open();

                Console.WriteLine("Service is ready. Hit enter to stop service.");
                Console.ReadLine();

                host.Close();
            }
        }
开发者ID:DeanMaurer,项目名称:SampleTwoWayTLSWithCerts,代码行数:31,代码来源:Program.cs

示例7: ConfigureServiceHost

        public void ConfigureServiceHost(ServiceHost host, ServiceHostConfigurationArgs args)
        {
            WSHttpBinding binding = new WSHttpBinding();
            binding.MaxReceivedMessageSize = args.MaxReceivedMessageSize;
            binding.ReaderQuotas.MaxStringContentLength = args.MaxReceivedMessageSize;
            binding.ReaderQuotas.MaxArrayLength = args.MaxReceivedMessageSize;
            binding.Security.Mode = WebServicesSettings.Default.SecurityMode;
            binding.Security.Message.ClientCredentialType = args.Authenticated
                                                                ? MessageCredentialType.UserName
                                                                : MessageCredentialType.None;
            // establish endpoint
            host.AddServiceEndpoint(args.ServiceContract, binding, "");

            // expose meta-data via HTTP GET
            ServiceMetadataBehavior metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
            if (metadataBehavior == null)
            {
                metadataBehavior = new ServiceMetadataBehavior();
                metadataBehavior.HttpGetEnabled = true;
                host.Description.Behaviors.Add(metadataBehavior);
            }

            // set up the certificate 
            if (WebServicesSettings.Default.SecurityMode == SecurityMode.Message 
                || WebServicesSettings.Default.SecurityMode==SecurityMode.TransportWithMessageCredential)
            {
                host.Credentials.ServiceCertificate.SetCertificate(
                    StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, args.HostUri.Host);
            }
        }
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:30,代码来源:WSHttpConfiguration.cs

示例8: CreateSGDatabase_HClient

 public static SGDatabase_HClient CreateSGDatabase_HClient()
 {
     WSHttpBinding BINDING = new WSHttpBinding();
     WcfClientConfig.ReadBindingConfig(BINDING, "WSHttpBinding_SGDatabase_H");//从配置文件(app.config)读取配置。
     string endpoint = WcfClientConfig.GetWcfRemoteAddress("WSHttpBinding_SGDatabase_H");
     return new SGDatabase_HClient(BINDING, new EndpointAddress(endpoint));
 }
开发者ID:wuhuayun,项目名称:JieLi_Cord,代码行数:7,代码来源:WcfClientFactory.cs

示例9: GetHttpBinding

        public static WSHttpBinding GetHttpBinding()
        {
            var binding = new WSHttpBinding
            {
                MaxBufferPoolSize = 2147483647,
                MaxReceivedMessageSize = 2147483647,
                MessageEncoding = WSMessageEncoding.Mtom,
                TextEncoding = System.Text.Encoding.UTF8,
                ReceiveTimeout = new TimeSpan(0, 0, 1, 0),
                SendTimeout = new TimeSpan(0, 0, 1, 0),
                OpenTimeout = new TimeSpan(0, 0, 1, 0),
                ReaderQuotas =
                {
                    MaxArrayLength = 2147483647,
                    MaxDepth = 2147483647,
                    MaxStringContentLength = 2147483647,
                    MaxBytesPerRead = 2147483647,
                    MaxNameTableCharCount = 2147483647
                },
                ReliableSession = { Enabled = true, InactivityTimeout = new TimeSpan(0, 0, 1, 0) },
                Security = { Mode = SecurityMode.None , Transport = {ClientCredentialType = HttpClientCredentialType.None}}
            };

            return binding;
        }
开发者ID:serkovigor1985,项目名称:RemoteViewer,代码行数:25,代码来源:Utils.cs

示例10: CreateChannel

 static IFileService CreateChannel(string url)
 {
     WSHttpBinding binding = new WSHttpBinding();
       EndpointAddress address = new EndpointAddress(url);
       ChannelFactory<IFileService> factory = new ChannelFactory<IFileService>(binding, address);
       return factory.CreateChannel();
 }
开发者ID:bizarreWizard,项目名称:dependency_analyzer,代码行数:7,代码来源:Client.cs

示例11: Start

        public void Start()
        {
            this.host = new ServiceHost(typeof(NotificationService));

            var binding = new WSHttpBinding
                          {
                              Security =
                              {
                                  Mode = SecurityMode.None
                              }
                          };

            var behavior = new ServiceMetadataBehavior
                           {
                               HttpGetEnabled = true,
                               HttpGetUrl = configuration.Uri
                           };

            this.host.AddServiceEndpoint(typeof(INotificationService), binding, configuration.Uri);

            this.host.AddDependencyInjectionBehavior<NotificationService>(this.container);

            this.host.Description.Behaviors.Add(behavior);

            this.host.Open();
        }
开发者ID:Firebuild,项目名称:Firebuild,代码行数:26,代码来源:NotificationServiceHost.cs

示例12: CanProvideInstanceForHost

        public void CanProvideInstanceForHost()
        {
            using (var container = new UnityContainer())
            {
                //var serviceMock = new Mock<ITestService>();
                //container.RegisterInstance<ITestService>(serviceMock.Object);
                container.RegisterInstance<TestService>(new TestService("Test"));

                var serviceHost = new ServiceHost(typeof(TestService), new Uri("http://localhost:55551/TestService"));
                serviceHost.Description.Behaviors.Add(new UnityServiceBehavior(container));

                Binding binding = new WSHttpBinding();
                var address = new EndpointAddress("http://localhost:55551/TestService/MyService");
                var endpoint = serviceHost
                    .AddServiceEndpoint(typeof(ITestService), binding, address.Uri);

                var smb = new ServiceMetadataBehavior { HttpGetEnabled = true };
                serviceHost.Description.Behaviors.Add(smb);

                var proxy = ChannelFactory<ITestService>.CreateChannel(binding, endpoint.Address);

                serviceHost.Open();

                var result = proxy.TestOperation();

                serviceHost.Close();

                Assert.AreEqual("Test", result);
            }
        }
开发者ID:Detroier,项目名称:playground,代码行数:30,代码来源:UnityServiceBehaviorTest.cs

示例13: soapClient

        /// <summary>
        /// A private function to create the soapclient to communicate with ServiceNOW
        /// </summary>
        /// <param name="UserName">The API Username</param>
        /// <param name="Password">The API Password</param>
        /// <returns>A ServiceNow SoapClient object</returns>
        private static ServiceNowSoapClient soapClient(string UserName, string Password, string ServiceNowUrl)
        {
            try
            {
                EndpointAddress endpoint = new EndpointAddress(new Uri(ServiceNowUrl));
                WSHttpBinding binding = new WSHttpBinding();

                binding.Name = "ServiceNowSoap";
                binding.MaxReceivedMessageSize = 65536;
                binding.Security.Mode = SecurityMode.Transport;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
                binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

                ServiceNowSoapClient soapClient = new ServiceNowSoapClient(binding, endpoint);
                soapClient.ClientCredentials.UserName.UserName = UserName;
                soapClient.ClientCredentials.UserName.Password = Password;

                return soapClient;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
        }
开发者ID:jeffpatton1971,项目名称:mod-ServiceNOW,代码行数:32,代码来源:incident.cs

示例14: CreateSGDatabase_WClient

 public static SGDatabase_WClient CreateSGDatabase_WClient()
 {
     WSHttpBinding BINDING = new WSHttpBinding();
     SoapClientConfig.ReadBindingConfig(BINDING, "http_ISGDatabase_W");//从配置文件(app.config)读取配置。
     string endpoint = SoapClientConfig.GetSoapRemoteAddress("http_ISGDatabase_W");
     return new SGDatabase_WClient(BINDING, new EndpointAddress(endpoint));//构建WCF客户端实例
 }
开发者ID:wuhuayun,项目名称:JieLi_Cord,代码行数:7,代码来源:SoapClientFactory.cs

示例15: ConfigureServiceHost

		/// <summary>
		/// Configures the specified service host, according to the specified arguments.
		/// </summary>
		/// <param name="host"></param>
		/// <param name="args"></param>
		public void ConfigureServiceHost(ServiceHost host, ServiceHostConfigurationArgs args)
		{
			var binding = new WSHttpBinding();
			binding.MaxReceivedMessageSize = args.MaxReceivedMessageSize;
			if (args.SendTimeoutSeconds > 0)
				binding.SendTimeout = TimeSpan.FromSeconds(args.SendTimeoutSeconds);

			binding.ReaderQuotas.MaxStringContentLength = args.MaxReceivedMessageSize;
			binding.ReaderQuotas.MaxArrayLength = args.MaxReceivedMessageSize;
			binding.Security.Mode = SecurityMode.Message;
			binding.Security.Message.ClientCredentialType = args.Authenticated ?
				MessageCredentialType.UserName : MessageCredentialType.None;

			// establish endpoint
			host.AddServiceEndpoint(args.ServiceContract, binding, "");

			// expose meta-data via HTTP GET
			var metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
			if (metadataBehavior == null)
			{
				metadataBehavior = new ServiceMetadataBehavior();
				metadataBehavior.HttpGetEnabled = true;
				host.Description.Behaviors.Add(metadataBehavior);
			}

			//TODO (Rockstar): remove this after refactoring to do per-sop edits
			foreach (var endpoint in host.Description.Endpoints)
				foreach (var operation in endpoint.Contract.Operations)
					operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = args.MaxReceivedMessageSize;

			// set up the certificate - required for WSHttpBinding
			host.Credentials.ServiceCertificate.SetCertificate(
				args.CertificateSearchDirective.StoreLocation, args.CertificateSearchDirective.StoreName,
				args.CertificateSearchDirective.FindType, args.CertificateSearchDirective.FindValue);
		}
开发者ID:jfphilbin,项目名称:ClearCanvas,代码行数:40,代码来源:WSHttpConfiguration.cs


注:本文中的System.ServiceModel.WSHttpBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。