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


C# ServiceMetadataBehavior.ToString方法代码示例

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


在下文中一共展示了ServiceMetadataBehavior.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartService

        private void StartService()
        {
            try
            {
                //Address
                string hostName = Dns.GetHostName();
                urlService = "net.tcp://" + hostName.ToString() + ":8000/MyService";
                host = new ServiceHost(typeof(BShipServiceLib.BShipServiceClass));

                NetTcpBinding tcpBinding = new NetTcpBinding();
                tcpBinding.TransactionFlow = false;
                tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
                tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial

                //Binding - add endpoint
                host.AddServiceEndpoint(typeof(BShipServiceLib.IBShipService), tcpBinding, urlService);

                //Channel
                ServiceMetadataBehavior metadataBehavior;
                metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
                if (metadataBehavior == null)
                {
                    //Gonna remove the app.config file by doing this, enabling meta data
                    metadataBehavior = new ServiceMetadataBehavior();
                    metadataBehavior.HttpGetUrl = new Uri("http://" + hostName.ToString() + ":8001/MyService");
                    metadataBehavior.HttpGetEnabled = true;
                    metadataBehavior.ToString();
                    host.Description.Behaviors.Add(metadataBehavior);
                    urlMeta = metadataBehavior.HttpGetUrl.ToString();
                }

                host.Open();
            }
            catch (Exception ex) { }
        }
开发者ID:brittharris,项目名称:funbattleship,代码行数:36,代码来源:Form1.cs

示例2: ConfigureService

        private void ConfigureService()
        {
            // Returns a list of ipaddress configuration
            IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName());
            IPAddress ipAddress = ips.AddressList[0]; // Select the first entry. I hope it's this maschines IP
            
            // Create the url that is needed to specify where the service should be started
            urlService = "net.tcp://" + ipAddress + ":8000/AlarmServer";
            host = new ServiceHost(typeof(AlarmServer));

            NetTcpBinding tcpBinding = new NetTcpBinding();
            tcpBinding.TransactionFlow = false;
            tcpBinding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
            tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
            tcpBinding.Security.Mode = SecurityMode.None;
            // <- Very crucial

            // Add a endpoint
            host.AddServiceEndpoint(typeof(IAlarmServer), tcpBinding, urlService);
            
            // A channel to describe the service. Used with the proxy scvutil.exe tool
            ServiceMetadataBehavior metadataBehavior;
            metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
            if (metadataBehavior == null)
            {
                // This is how I create the proxy object that is generated via the svcutil.exe tool
                metadataBehavior = new ServiceMetadataBehavior();
                metadataBehavior.HttpGetUrl = new Uri("http://" + ipAddress + ":8001/AlarmServer");
                metadataBehavior.HttpGetEnabled = true;
                metadataBehavior.ToString();
                host.Description.Behaviors.Add(metadataBehavior);
                urlMeta = metadataBehavior.HttpGetUrl.ToString();
            }

            //forProxy
            //host.AddServiceEndpoint(typeof(AlarmServer), )
            host.Open();
        }
开发者ID:MichalGrzegorzak,项目名称:Ylvis,代码行数:38,代码来源:Form1.cs


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