• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Description.WebHttpBehavior类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Инициализация...");
            var properties = ConnectionSettings.Default;
            var baseUrl = new Uri(properties.host);

            var contractType = typeof (IRestBridgeContract);
            var binding = new WebHttpBinding(WebHttpSecurityMode.None);
            binding.ContentTypeMapper = new JsonContentTypeMapper();

            var server = new ServiceHost(typeof (CastDriverBridgeEmulatorImpl));
            var endPoint = server.AddServiceEndpoint(contractType, binding, baseUrl);

            var behavior = new WebHttpBehavior();
            behavior.FaultExceptionEnabled = false;
            behavior.HelpEnabled = true;
            behavior.DefaultOutgoingRequestFormat = WebMessageFormat.Json;
            behavior.DefaultOutgoingResponseFormat = WebMessageFormat.Json;

            endPoint.Behaviors.Add(behavior);

            Console.WriteLine("Инициализация завершена.");

            Console.WriteLine("Запуск сервера...");
            server.Open();
            Console.WriteLine("Сервер запущен. Адрес сервера: {0}\nДля остановки нажмите Enter.", properties.host);

            Console.ReadLine();
            Console.WriteLine("Остановка сервера...");
            server.Close();
            Console.WriteLine("Сервер остановлен.");
            Console.ReadLine();
        }
开发者ID:desla,项目名称:CraneDriver,代码行数:33,代码来源:Program.cs


示例2: OnOpening

 /// <summary>
 /// Configures service endpoint and adds special behaviors to it (WebHttp and CorsSupport)
 /// </summary>
 protected override void OnOpening()
 {
     var securityMode = BaseAddresses.FirstOrDefault().Scheme == "https" ? WebHttpSecurityMode.Transport : WebHttpSecurityMode.None;
     var receiveTimeout = new TimeSpan(1, 0, 0);
     var defaultWebHttpBehavior = new WebHttpBehavior() {
         AutomaticFormatSelectionEnabled = true,
         DefaultBodyStyle = WebMessageBodyStyle.Wrapped,
         DefaultOutgoingRequestFormat = WebMessageFormat.Json,
         HelpEnabled = false
     };
     var endPoint = new ServiceEndpoint(
         ContractDescription.GetContract(Description.ServiceType),
         new WebHttpBinding(securityMode) {
             UseDefaultWebProxy = false,
             ReceiveTimeout = receiveTimeout,
             MaxBufferSize = Config.MaxBufferSize,
             MaxReceivedMessageSize = Config.MaxReceivedMessageSize
         },
         new EndpointAddress(BaseAddresses.FirstOrDefault())
     );
     endPoint.EndpointBehaviors.Add(defaultWebHttpBehavior);
     endPoint.EndpointBehaviors.Add(new CorsSupportBehavior());
     endPoint.EndpointBehaviors.Add(new BrowserCompatibilityBehavior());
     AddServiceEndpoint(endPoint);
     base.OnOpening();
 }
开发者ID:HTD,项目名称:Woof,代码行数:29,代码来源:WebServiceHost.cs


示例3: Main

        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8000/");
            ServiceHost selfHost = new WebServiceHost(typeof(MonitorService), baseAddress);

            try
            {
                // Step 3 Add a service endpoint.
                var t = new WebHttpBinding();

                selfHost.AddServiceEndpoint(typeof(IMonitorService), t, "test");
                WebHttpBehavior whb = new WebHttpBehavior();

                // Step 4 Enable metadata exchange.
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;

                selfHost.Description.Behaviors.Add(smb);

                // Step 5 Start the service.
                selfHost.Open();
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.WriteLine();
                Console.ReadLine();

                // Close the ServiceHostBase to shutdown the service.
                selfHost.Close();
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("An exception occurred: {0}", ce.Message);
                selfHost.Abort();
            }
        }
开发者ID:Shamsterl,项目名称:SimpleSystemMonitor,代码行数:35,代码来源:Program.cs


示例4: QueryServiceHost

 public QueryServiceHost(Uri address, object service)
 {
     host = new WebServiceHost(service);
     host.AddServiceEndpoint(typeof(IQueryService), new WebHttpBinding(), address);
     WebHttpBehavior behavior = new WebHttpBehavior();
     host.Description.Endpoints[0].Behaviors.Add(behavior);
 }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:7,代码来源:QueryServiceHost.cs


示例5: GetServiceHost

 public static ServiceHost GetServiceHost(Uri baseAddress)
 {
     ServiceHost host = new ServiceHost(typeof(KORTService), baseAddress);
     ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IService), GetBinding(), baseAddress);
     WebHttpBehavior httpBehavior = new WebHttpBehavior {DefaultBodyStyle = WebMessageBodyStyle.Bare };
     endpoint.Behaviors.Add(httpBehavior);
     return host;
 }
开发者ID:jovijovi,项目名称:kort,代码行数:8,代码来源:Server.cs


示例6: AddBiningParameters

		public void AddBiningParameters ()
		{
			var se = CreateEndpoint ();
			var b = new WebHttpBehavior ();
			var pl = new BindingParameterCollection ();
			b.AddBindingParameters (se, pl);
			Assert.AreEqual (0, pl.Count, "#1");
		}
开发者ID:carrie901,项目名称:mono,代码行数:8,代码来源:WebHttpBehaviorTest.cs


示例7: DefaultValues

		public void DefaultValues ()
		{
			var b = new WebHttpBehavior ();
			Assert.AreEqual (WebMessageBodyStyle.Bare, b.DefaultBodyStyle, "#1");
			Assert.AreEqual (WebMessageFormat.Xml, b.DefaultOutgoingRequestFormat, "#2");
			Assert.AreEqual (WebMessageFormat.Xml, b.DefaultOutgoingResponseFormat, "#3");
			Assert.IsFalse (b.AutomaticFormatSelectionEnabled, "#11");
			Assert.IsFalse (b.FaultExceptionEnabled, "#12");
			Assert.IsFalse (b.HelpEnabled, "#13");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:10,代码来源:WebHttpBehaviorTest.cs


示例8: HelpPage

 public HelpPage(WebHttpBehavior behavior, ContractDescription description)
 {
     this.operationInfoDictionary = new Dictionary<string, OperationHelpInformation>();
     this.operationPageCache = new NameValueCache<string>();
     this.helpPageCache = new NameValueCache<string>();
     foreach (OperationDescription od in description.Operations)
     {
         operationInfoDictionary.Add(od.Name, new OperationHelpInformation(behavior, od));
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:HelpPage.cs


示例9: Main

        static void Main(string[] args)
        {
            const String soapServiceEndpointAddress = "SOAP";
            const String restServiceEndpointAddress = "REST";

            Uri soapBaseAddress = new Uri("http://localhost:5000/OraclePermissionGeneratorWebServiceAPI");
            Uri restBaseAddress = new Uri("http://localhost:5001/OraclePermissionGeneratorWebServiceAPI");

            // Create and start the service host
            using (FileTrackingDataLogger trackingDataLogger = new FileTrackingDataLogger(@"C:\Temp\"))
            {
                Dictionary<string, OraclePermissionGeneratorDataInterfaceLayer> userDataRespository = new Dictionary<string, OraclePermissionGeneratorDataInterfaceLayer>();
                SoapWebServiceApi soapApiInstance = new SoapWebServiceApi(userDataRespository, trackingDataLogger);
                RestWebServiceApi restApiInstance = new RestWebServiceApi(userDataRespository, trackingDataLogger);
                soapApiInstance.AddUser("[email protected]");
                soapApiInstance.LoadDataModelFromFile("[email protected]", @"..\..\..\Resources\Tutorial 2.xml", @"..\..\..\Resources\ORACLE_PERMISSION_GENERATOR_CONFIG.xsd");

                using (ServiceHost soapServiceHost = new ServiceHost(soapApiInstance, soapBaseAddress))
                using (ServiceHost restServiceHost = new ServiceHost(restApiInstance, restBaseAddress))
                {
                    // Set SOAP service host settings
                    ServiceMetadataBehavior soapServiceMetadataBehavior = new ServiceMetadataBehavior();
                    soapServiceMetadataBehavior.HttpGetEnabled = true;
                    soapServiceMetadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                    soapServiceHost.Description.Behaviors.Add(soapServiceMetadataBehavior);
                    BasicHttpBinding soapBinding = new BasicHttpBinding();
                    ServiceEndpoint soapEndpoint = soapServiceHost.AddServiceEndpoint(typeof(ISoapWebServiceApi), soapBinding, soapServiceEndpointAddress);
                    // Set single instance
                    soapServiceHost.Description.Behaviors.Find<ServiceBehaviorAttribute>().InstanceContextMode = InstanceContextMode.Single;
                    // Turn on option to include exception in any web service interface errors
                    soapServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;

                    // Set REST service host settings
                    ServiceMetadataBehavior restServiceMetadataBehavior = new ServiceMetadataBehavior();
                    restServiceMetadataBehavior.HttpGetEnabled = true;
                    restServiceMetadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                    restServiceHost.Description.Behaviors.Add(restServiceMetadataBehavior);
                    WebHttpBinding restBinding = new WebHttpBinding();
                    ServiceEndpoint restEndpoint = restServiceHost.AddServiceEndpoint(typeof(IRestWebServiceApi), restBinding, restServiceEndpointAddress);
                    WebHttpBehavior restBehavior = new WebHttpBehavior();
                    restEndpoint.Behaviors.Add(restBehavior);
                    restServiceHost.Description.Behaviors.Find<ServiceBehaviorAttribute>().InstanceContextMode = InstanceContextMode.Single;
                    restServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;

                    // Start the services
                    soapServiceHost.Open();
                    restServiceHost.Open();
                    Console.WriteLine("Press [Enter] to stop the service.");
                    Console.ReadLine();
                    restServiceHost.Close();
                    soapServiceHost.Close();
                }
            }
        }
开发者ID:alastairwyse,项目名称:OraclePermissionGeneratorAndroid,代码行数:54,代码来源:Program.cs


示例10: WebMessageFormatter

		public WebMessageFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
		{
			this.operation = operation;
			this.endpoint = endpoint;
			this.converter = converter;
			this.behavior = behavior;
			ApplyWebAttribute ();
			// This is a hack for WebScriptEnablingBehavior
			var jqc = converter as JsonQueryStringConverter;
			if (jqc != null)
				BodyName = jqc.CustomWrapperName;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:WebMessageFormatter.cs


示例11: OpenRESTfulTestHost

        public static void OpenRESTfulTestHost()
        {
            ServiceHost host = new ServiceHost(typeof(RESTfulTest), new Uri("http://localhost:8088/"));

            ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IRESTfulTest), new WebHttpBinding(), "restful");
            WebHttpBehavior httpBehavior = new WebHttpBehavior();
            endpoint.Behaviors.Add(httpBehavior);

            //ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
            //behavior.HttpGetEnabled = true;
            //host.Description.Behaviors.Add(behavior);

            host.Open();
        }
开发者ID:weibin268,项目名称:Zhuang.BPM,代码行数:14,代码来源:ServiceHostManager.cs


示例12: CreateServiceHost

        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            // Check security requirement.
            bool integratedSecurity = (Service.GetAuthenticationSchemes(baseAddresses[0]) & AuthenticationSchemes.Anonymous) != AuthenticationSchemes.Anonymous;

            // Initialize host and binding.
            ServiceHost host = new ServiceHost(serviceType, baseAddresses);

            // Enable metadata publishing.
            ServiceMetadataBehavior serviceBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
            if (serviceBehavior == null)
            {
                serviceBehavior = new ServiceMetadataBehavior();
                host.Description.Behaviors.Add(serviceBehavior);
            }
            serviceBehavior.HttpGetEnabled = true;

            // Add REST endpoint.
            WebHttpBinding restBinding = new WebHttpBinding();
            WebHttpBehavior restBehavior = new WebHttpBehavior();
            ServiceEndpoint restEndpoint = host.AddServiceEndpoint(typeof(ISecurityService), restBinding, "rest");

            if (integratedSecurity)
            {
                // Enable security on the binding.
                restBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
                restBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            }

#if !MONO
            restBehavior.HelpEnabled = true;
#endif
            restEndpoint.Behaviors.Add(restBehavior);

            // Add SOAP endpoint.
            BasicHttpBinding soapBinding = new BasicHttpBinding();
            if (integratedSecurity)
            {
                // Enable security on the binding.
                soapBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                soapBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            }
            host.AddServiceEndpoint(typeof(ISecurityService), soapBinding, "soap");
            host.AddServiceEndpoint(typeof(IMetadataExchange), soapBinding, "soap/mex");

            return host;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:47,代码来源:SecurityServiceHostFactory.cs


示例13: StartHost

        public static WebHost StartHost()
        {
            Trace.TraceInformation("Starting host..");
            WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.None);
            ServiceEndpoint endPoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(BlocksOptimizationServices)),
            binding, new EndpointAddress(WebHostAdress));
            WebHttpBehavior webBehavior = new WebHttpBehavior();
            endPoint.Behaviors.Add(webBehavior);

            ServiceHost serviceHost = new ServiceHost(typeof(BlocksOptimizationServices));

            serviceHost.AddServiceEndpoint(endPoint);

            serviceHost.Open();
            Trace.TraceInformation("Service Host Started.");
            return new WebHost(serviceHost);
        }
开发者ID:pkonovalov-softheme,项目名称:SmartOptimizer,代码行数:17,代码来源:WebHost.cs


示例14: ApplyDispatchBehavior

		public void ApplyDispatchBehavior ()
		{
			var se = CreateEndpoint ();
			var od = se.Contract.Operations [0];
			// in .NET 3.5 it adds "OperationSelectorBehavior"
			int initCB = ContractDescription.GetContract (typeof (IMyService)).Behaviors.Count;
			// in .NET 3.5 it adds
			// - OperationInvokeBehavior, 
			// - OperationBehaviorAttribute, 
			// - DataContractSerializerOperationBehavior and 
			// - DataContractSerializerOperationGenerator
			int initOB = od.Behaviors.Count;
			// Assert.AreEqual (1, initCB, "#0-1");
			// Assert.AreEqual (4, initOB, "#0-2");

			var b = new WebHttpBehavior ();
			se.Behaviors.Add (b);
			var ed = new EndpointDispatcher (se.Address, se.Contract.Name, se.Contract.Namespace);
			IChannelListener l = new WebHttpBinding ().BuildChannelListener<IReplyChannel> (new BindingParameterCollection ());
			var cd = new ChannelDispatcher (l);
			cd.Endpoints.Add (ed); // without it this test results in NRE (it blindly adds IErrorHandler).
			Assert.AreEqual (0, cd.ErrorHandlers.Count, "#1-1");
			Assert.IsNull (ed.DispatchRuntime.OperationSelector, "#1-2");
			Assert.AreEqual (1, se.Behaviors.Count, "#1-3-1");
			Assert.AreEqual (initCB, se.Contract.Behaviors.Count, "#1-3-2");
			Assert.AreEqual (initOB, od.Behaviors.Count, "#1-3-3");

			Assert.IsTrue (ed.AddressFilter is EndpointAddressMessageFilter, "#1-4");

			b.ApplyDispatchBehavior (se, ed);
			// FIXME: implement and enable it later
			//Assert.AreEqual (1, cd.ErrorHandlers.Count, "#2-1");
			Assert.AreEqual (typeof (WebHttpDispatchOperationSelector),
					 ed.DispatchRuntime.OperationSelector.GetType (), "#2-2");
			Assert.AreEqual (1, se.Behaviors.Count, "#3-1");
			Assert.AreEqual (initCB, se.Contract.Behaviors.Count, "#3-2");
			Assert.AreEqual (initOB, od.Behaviors.Count, "#3-3");
			// ... i.e. nothing is added.

			Assert.IsTrue (ed.AddressFilter is PrefixEndpointAddressMessageFilter, "#3-4");

			Assert.AreEqual (0, ed.DispatchRuntime.Operations.Count, "#4-0"); // hmm... really?
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:43,代码来源:WebHttpBehaviorTest.cs


示例15: UProveThreadWorkerProver

    public UProveThreadWorkerProver()
    {
      WebHttpBinding binding = new WebHttpBinding();
      UProveRestServiceProver instance = UProveRestServiceProver.Instance;
      _host = new WebServiceHost(instance, new Uri(ParseConfigManager.GetAddress(), ParseConfigManager.GetProverApiPath()));
      _serviceEndPoint = _host.AddServiceEndpoint(typeof(IUProveRestServiceProver), binding, "");

      WebHttpBehavior enableHelp = new WebHttpBehavior();
      enableHelp.HelpEnabled = true;
      enableHelp.DefaultOutgoingResponseFormat = WebMessageFormat.Json;
      enableHelp.DefaultOutgoingRequestFormat = WebMessageFormat.Json;
      _serviceEndPoint.EndpointBehaviors.Add(enableHelp);

      if (ParseConfigManager.SetupTimeProfiles())
      {
        _serviceEndPoint.Behaviors.Add(new WcfTimeProfileEndPointLogger());
      }

    }
开发者ID:Fiware,项目名称:security.P2abcengine,代码行数:19,代码来源:UProveThreadWorkerProver.cs


示例16: FormatSelectingMessageInspector

        public FormatSelectingMessageInspector(WebHttpBehavior webHttpBehavior, List<MultiplexingFormatMapping> mappings)
        {
            if (webHttpBehavior == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("webHttpBehavior");
            }
            if (mappings == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("mappings");
            }

            this.automaticFormatSelectionEnabled = webHttpBehavior.AutomaticFormatSelectionEnabled;
            
            this.formatters = new Dictionary<string, MultiplexingDispatchMessageFormatter>();

            this.caches = new Dictionary<string, NameValueCache<FormatContentTypePair>>();

            this.mappings = mappings;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:19,代码来源:FormatSelectingMessageInspector.cs


示例17: CreateServiceHost

        /// <summary>
        /// The create service host.
        /// </summary>
        /// <param name="serviceType">
        /// The service type.
        /// </param>
        /// <param name="baseAddresses">
        /// The base addresses.
        /// </param>
        /// <returns>
        /// The <see cref="ServiceHost"/>.
        /// </returns>
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            try
            {
                _log.DebugFormat("Creating REST service host for {0} for uri : {1}", serviceType, baseAddresses[0]);
                ServiceHost serviceHost = base.CreateServiceHost(serviceType, baseAddresses);

                var webBehavior = new WebHttpBehavior { AutomaticFormatSelectionEnabled = false, HelpEnabled = true, FaultExceptionEnabled = false, DefaultBodyStyle = WebMessageBodyStyle.Bare };
                var binding = new WebHttpBinding { TransferMode = TransferMode.Streamed, ContentTypeMapper = new SdmxContentMapper()};
                var endpoint = serviceHost.AddServiceEndpoint(this._type, binding, baseAddresses[0]);

                endpoint.Behaviors.Add(webBehavior);

                return serviceHost;
            }
            catch (Exception e)
            {
                _log.Error("While creating service host", e);
                throw;
            }
        }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:33,代码来源:SdmxRestServiceHostFactory.cs


示例18: CreateService

        static ServiceHost CreateService(Uri[] serviceAddresses, Type serviceType, Type serviceContract)
        {
            // Create ServiceHost
            var host = new ServiceHost(serviceType, serviceAddresses);
            // var host = new WebServiceHost(serviceType, serviceAddresses);

            // Add service endpoint(s)
            // http://wcftutorial.net/WCF-Types-of-Binding.aspx
            // host.AddServiceEndpoint(serviceContract, new WSHttpBinding(), "/ws");
            // host.AddServiceEndpoint(serviceContract, new BasicHttpBinding(), "/basic");
            // host.AddServiceEndpoint(serviceContract, new NetTcpBinding(), "/tcp");
            // host.AddServiceEndpoint(serviceContract, new NetNamedPipeBinding(), "/pipe");
            // host.AddServiceEndpoint(serviceContract, new NetPeerTcpBinding(), "/peer");
            // host.AddServiceEndpoint(serviceContract, new WebHttpBinding(), "/web");

            var endpoint = host.AddServiceEndpoint(serviceContract, new WebHttpBinding(), "/rest");
            var webBehavior = new WebHttpBehavior
                                {
                                    AutomaticFormatSelectionEnabled = true,
                                    DefaultBodyStyle = WebMessageBodyStyle.Bare,
                                    DefaultOutgoingRequestFormat = WebMessageFormat.Json,
                                    DefaultOutgoingResponseFormat = WebMessageFormat.Json,
                                    FaultExceptionEnabled = true,
                                    HelpEnabled = true
                                };
            endpoint.Behaviors.Add(webBehavior);
            /*
            */

            // Enable metadata exchange
            var metadataBehavior = new ServiceMetadataBehavior { HttpGetEnabled = true };
            // metadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
            host.Description.Behaviors.Add(metadataBehavior);

            // Adding metadata exchange endpoint
            var mexBinding = MetadataExchangeBindings.CreateMexHttpBinding();
            host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex");

            return host;
        }
开发者ID:JoakimBrannstrom,项目名称:SimpleWcf,代码行数:40,代码来源:Program.cs


示例19: CreateServiceHost

        public static ServiceHost CreateServiceHost(ISimplexConfigUpdaterContract instance,
                                                     Uri baseAddress)
        {
            ServiceHost service = new ServiceHost(instance, baseAddress);
            var contract = ContractDescription.GetContract(typeof(ISimplexConfigUpdaterContract));

            var webBinding = new WebHttpBinding();

            var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(baseAddress));
            WebHttpBehavior webBehaviour = new WebHttpBehavior();
            webBehaviour.HelpEnabled = true;
            webEndPoint.EndpointBehaviors.Add(webBehaviour);

            service.AddServiceEndpoint(webEndPoint);

              // service.Description.Behaviors.Add(new ServiceMetadataBehavior());
               //var metaBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
               //metaBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.InheritedFromHost;
               //service.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

            return service;
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:22,代码来源:ConfigUpdaterWebService.cs


示例20: Start

        public void Start()
        {
            if (_serviceHost != null)
                throw new InvalidOperationException("_serviceHost already started");

            if (_automationController != null)
                throw new InvalidOperationException("_automationController already created");

            InvokeTrace("building host...");

            // build the service
            var phoneAutomationService = new PhoneAutomationService();
            phoneAutomationService.Trace += (sender, args) => InvokeTrace(args);
            var serviceHost = new ServiceHost(phoneAutomationService, BindingAddress);

            // Enable metadata publishing
            var smb = new ServiceMetadataBehavior
            {
                HttpGetEnabled = true,
                MetadataExporter = { PolicyVersion = PolicyVersion.Policy15 }
            };
            serviceHost.Description.Behaviors.Add(smb);

            // build SOAP ServiceEndpoint
            serviceHost.AddServiceEndpoint(
                                            typeof(IPhoneAutomationService),
                                            GetHttpBinding(),
                                            BindingAddress + "/automate");

            // build JSON ServiceEndpoint
            var jsonServiceEndpoint = serviceHost.AddServiceEndpoint(
                                                        typeof(IPhoneAutomationService),
                                                        GetWebHttpBinding(),
                                                        BindingAddress + "/jsonAutomate");
            var webHttpBehavior = new WebHttpBehavior()
                                      {
                                          DefaultOutgoingRequestFormat = WebMessageFormat.Json,
                                          DefaultOutgoingResponseFormat = WebMessageFormat.Json,
                                          DefaultBodyStyle = WebMessageBodyStyle.Wrapped
                                      };
            jsonServiceEndpoint.Behaviors.Add(webHttpBehavior);

            // open the host
            InvokeTrace("opening host...");
            serviceHost.Open();
            InvokeTrace("host open");

            _automationController = new PhoneAutomationController(phoneAutomationService, AutomationIdentification);
            _serviceHost = serviceHost;
        }
开发者ID:K2DaC,项目名称:WindowsPhoneTestFramework,代码行数:50,代码来源:ServiceHostController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Description.WsdlContractConversionContext类代码示例发布时间:2022-05-26
下一篇:
C# Description.ServiceMetadataBehavior类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap