當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。