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


C# ServiceModel.BasicHttpBinding类代码示例

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


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

示例1: CreateBasicBinding

        public static BasicHttpBinding CreateBasicBinding(Uri uri)
        {

            BasicHttpBinding binding = new BasicHttpBinding()
                {
                    CloseTimeout = TimeSpan.FromMinutes(1),
                    ReceiveTimeout = TimeSpan.FromMinutes(10),
                    SendTimeout = TimeSpan.FromMinutes(5),
                    AllowCookies = false,
                    BypassProxyOnLocal = false,
                    HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                    MaxBufferSize = int.MaxValue,
                    MaxBufferPoolSize = 524288,
                    MaxReceivedMessageSize = int.MaxValue,
                    MessageEncoding = WSMessageEncoding.Text,
                    TextEncoding = Encoding.UTF8,
                    TransferMode = TransferMode.Buffered,
                    UseDefaultWebProxy = true
                };


            var quotas = binding.ReaderQuotas;
            quotas.MaxArrayLength =
                quotas.MaxBytesPerRead =
                quotas.MaxDepth =
                quotas.MaxNameTableCharCount =
                quotas.MaxStringContentLength = int.MaxValue;

            binding.Security.Mode = string.Equals(uri.Scheme, "https", StringComparison.OrdinalIgnoreCase) ? 
                BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.TransportCredentialOnly;

            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            return binding;
        }
开发者ID:aries544,项目名称:eXpand,代码行数:34,代码来源:BindingFactory.cs

示例2: CoreServiceProvider

        public CoreServiceProvider()
        {
            var binding = new BasicHttpBinding
            {
                MaxReceivedMessageSize = 10485760,
                ReaderQuotas = new XmlDictionaryReaderQuotas
                {
                    MaxStringContentLength = 10485760,
                    MaxArrayLength = 10485760
                },
                Security = new BasicHttpSecurity
                {
                    Mode = BasicHttpSecurityMode.TransportCredentialOnly,
                    Transport = new HttpTransportSecurity
                    {
                        ClientCredentialType = HttpClientCredentialType.Windows
                    }
                }
            };

            string coreServiceUrl = ConfigurationManager.AppSettings[Constants.TRIDION_CME_URL] + "/webservices/CoreService2013.svc/basicHttp";
            Console.WriteLine("Connect to CoreService " + coreServiceUrl);

            EndpointAddress endpoint = new EndpointAddress(coreServiceUrl);
            factory = new ChannelFactory<ICoreService>(binding, endpoint);

            string userName = ConfigurationManager.AppSettings[Constants.USER_NAME];
            string password = ConfigurationManager.AppSettings[Constants.PASSWORD];
            factory.Credentials.Windows.ClientCredential = new NetworkCredential(userName, password);

            Client = factory.CreateChannel();

            UserData user = Client.GetCurrentUser();
            Console.WriteLine("Connected as {0} ({1})", user.Description, user.Title);
        }
开发者ID:mitza13,项目名称:yet-another-tridion-blog,代码行数:35,代码来源:CoreServiceClient.cs

示例3: RightNowService

        public RightNowService(IGlobalContext _gContext)
        {
            // Set up SOAP API request to retrieve Endpoint Configuration -
            // Get the SOAP API url of current site as SOAP Web Service endpoint
            EndpointAddress endPointAddr = new EndpointAddress(_gContext.GetInterfaceServiceUrl(ConnectServiceType.Soap));

            // Minimum required
            BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
            binding2.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

            // Optional depending upon use cases
            binding2.MaxReceivedMessageSize = 5 * 1024 * 1024;
            binding2.MaxBufferSize = 5 * 1024 * 1024;
            binding2.MessageEncoding = WSMessageEncoding.Mtom;

            // Create client proxy class
            _rnowClient = new RightNowSyncPortClient(binding2, endPointAddr);
            BindingElementCollection elements = _rnowClient.Endpoint.Binding.CreateBindingElements();
            elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
            _rnowClient.Endpoint.Binding = new CustomBinding(elements);

            // Add SOAP msg inspector behavior
            //_rnowClient.Endpoint.Behaviors.Add(new LogMsgBehavior());

            // Ask the Add-In framework the handle the session logic
            _gContext.PrepareConnectSession(_rnowClient.ChannelFactory);

            // Set up query and set request
            _rnowClientInfoHeader = new ClientInfoHeader();
            _rnowClientInfoHeader.AppID = "Case Management Accelerator Services";
        }
开发者ID:glitch11,项目名称:Accelerators,代码行数:31,代码来源:RightNowService.cs

示例4: GetChannelFactory

        private ChannelFactory<ISharedTextEditorC2S> GetChannelFactory(string host)
        {
            var binding = new BasicHttpBinding();
            var endpoint = new EndpointAddress(host);

            return new ChannelFactory<ISharedTextEditorC2S>(binding, endpoint);
        }
开发者ID:robstoll,项目名称:shared-text-editor,代码行数:7,代码来源:ClientServerCommunication.cs

示例5: FileTransferServiceProxy

        public FileTransferServiceProxy()
        {
            this.m_BasicHttpBinding = new BasicHttpBinding();
            this.m_EndpointAddress = new EndpointAddress(EndpointAddressUrl);

            this.m_BasicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
            this.m_BasicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            this.m_BasicHttpBinding.MaxReceivedMessageSize = 2147483647;

            XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
            readerQuotas.MaxArrayLength = 25 * 208000;
            readerQuotas.MaxStringContentLength = 25 * 208000;
            this.m_BasicHttpBinding.ReaderQuotas = readerQuotas;

            this.m_ChannelFactory = new ChannelFactory<Contract.IFileTransferService>(this.m_BasicHttpBinding, this.m_EndpointAddress);
            this.m_ChannelFactory.Credentials.UserName.UserName = YellowstonePathology.YpiConnect.Contract.Identity.GuestWebServiceAccount.UserName;
            this.m_ChannelFactory.Credentials.UserName.Password = YellowstonePathology.YpiConnect.Contract.Identity.GuestWebServiceAccount.Password;

            foreach (System.ServiceModel.Description.OperationDescription op in this.m_ChannelFactory.Endpoint.Contract.Operations)
            {
                var dataContractBehavior = op.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>();
                if (dataContractBehavior != null)
                {
                    dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
                }
            }

            this.m_FileTransferServiceChannel = this.m_ChannelFactory.CreateChannel();
        }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:29,代码来源:FileTransferServiceProxy.cs

示例6: Client

 public Client(String URL)
 {
     BasicHttpBinding myBinding = new BasicHttpBinding();
     EndpointAddress  myEndpoint = new EndpointAddress(URL);
     myChannelFactory = new ChannelFactory<Server.IServerService>(myBinding, myEndpoint);
     comInterface = myChannelFactory.CreateChannel();
 }
开发者ID:kimpers,项目名称:school_work,代码行数:7,代码来源:Client.cs

示例7: Main

		static void Main()
		{
			// только не null, ибо возникнет исключение
			//var baseAddress = new Uri("http://localhost:8002/MyService");
			var host = new ServiceHost(typeof(MyContractClient));//, baseAddress);

			host.Open();

			//var otherBaseAddress = new Uri("http://localhost:8001/");
			var otherHost = new ServiceHost(typeof(MyOtherContractClient));//, otherBaseAddress);
			var wsBinding = new BasicHttpBinding();
			var tcpBinding = new NetTcpBinding();
			otherHost.AddServiceEndpoint(typeof(IMyOtherContract), wsBinding, "http://localhost:8001/MyOtherService");
			otherHost.AddServiceEndpoint(typeof(IMyOtherContract), tcpBinding, "net.tcp://localhost:8003/MyOtherService");

			//AddHttpGetMetadata(otherHost);
			AddMexEndpointMetadata(otherHost);

			otherHost.Open();


			// you can access http://localhost:8002/MyService
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new Host());

			otherHost.Close();

			host.Close();

			// you can not access http://localhost:8002/MyService
		}
开发者ID:Helen1987,项目名称:edu,代码行数:32,代码来源:Program.cs

示例8: TextMessageEncoder_WrongContentTypeResponse_Throws_ProtocolException

    public static void TextMessageEncoder_WrongContentTypeResponse_Throws_ProtocolException()
    {
        ChannelFactory<IWcfService> factory = null;
        IWcfService serviceProxy = null;
        string testContentType = "text/blah";
        Binding binding = null;

        try
        {
            // *** SETUP *** \\
            binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic));
            serviceProxy = factory.CreateChannel();

            // *** EXECUTE *** \\
            Assert.Throws<ProtocolException>(() => { serviceProxy.ReturnContentType(testContentType); });

            // *** VALIDATE *** \\

            // *** CLEANUP *** \\
            factory.Close();
            ((ICommunicationObject)serviceProxy).Close();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
        }
    }
开发者ID:weshaggard,项目名称:wcf,代码行数:29,代码来源:TextEncodingTests.cs

示例9: ServiceClientWrapper

 public ServiceClientWrapper()
 {
     this.EndpointUri = UriProvider.GetNextUri();
     // var binding = new BasicHttpBinding("BasicHttpBinding_IRemoteWorkerService");
     var binding = new BasicHttpBinding();
     this.client = new WSClient.RemoteWorkerServiceClient(binding, new EndpointAddress(this.EndpointUri));
 }
开发者ID:pbazydlo,项目名称:NetReduce,代码行数:7,代码来源:ServiceClientWrapper.cs

示例10: Create

 public Binding Create(Endpoint serviceInterface)
 {
     if (Utilities.Utilities.GetDisableCertificateValidation().EqualsCaseInsensitive("true"))
         System.Net.ServicePointManager.ServerCertificateValidationCallback =
             ((sender, certificate, chain, sslPolicyErrors) => true);
     var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
     {
         Name = serviceInterface.EndpointName,
         AllowCookies = false,
         HostNameComparisonMode = serviceInterface.HostNameComparisonMode.ParseAsEnum(HostNameComparisonMode.StrongWildcard),
         MaxBufferPoolSize = serviceInterface.MaxBufferPoolSize,
         MaxReceivedMessageSize = serviceInterface.MaxReceivedSize,
         MessageEncoding = serviceInterface.MessageFormat.ParseAsEnum(WSMessageEncoding.Text),
         TextEncoding = Encoding.UTF8,
         ReaderQuotas = XmlDictionaryReaderQuotas.Max,
         BypassProxyOnLocal = true,
         UseDefaultWebProxy = false
     };
     if (ConfigurationManagerHelper.GetValueOnKey("stardust.UseDefaultProxy") == "true")
     {
         binding.BypassProxyOnLocal = false;
         binding.UseDefaultWebProxy = true;
     }
     binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
     return binding;
 }
开发者ID:JonasSyrstad,项目名称:Stardust,代码行数:26,代码来源:WindowsAuthenticatedWsBindingCreator.cs

示例11: Unrecordingvoters

        public ActionResult Unrecordingvoters()
        {
            var unrecordingCitizens = new List<NufusMudurluguService.Citizen>();
            var myBinding = new BasicHttpBinding();
            var myEndpoint = new EndpointAddress("http://192.168.1.222:9999/TCNufusMudurlugu/GetCitizens");
            var myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);

            NufusMudurluguService.IService1 client = null;
            try
            {
                client = myChannelFactory.CreateChannel();
                var citizens = client.GetCitizens();
                foreach (var citizen in citizens)
                {
                    if (!m_internetDc.Voters.Any(f => f.IdentityNo == citizen.IdentityNo))
                    {
                        unrecordingCitizens.Add(citizen);
                    }
                }
                ViewData["Unrecording"] = unrecordingCitizens;
            }
            catch (Exception exp)
            {
            }
            return View();
        }
开发者ID:kirti-zare,项目名称:EOS,代码行数:26,代码来源:StatisticsController.cs

示例12: CreateServiceHost

        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            try
            {
                String factoryClass = this.GetType().Name;
                String endpointName =
                    String.Format("{0}HttpEndpoint",
                            factoryClass.Substring(0, factoryClass.IndexOf("ServiceHostFactory")));
                String externalEndpointAddress =
                    string.Format("http://{0}/{1}.svc",
                    RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[endpointName].IPEndpoint,
                    serviceType.Name);

                var host = new ServiceHost(serviceType, new Uri(externalEndpointAddress));

                var basicBinding = new BasicHttpBinding(String.Format("{0}Binding", serviceType.Name));
                foreach (var intf in serviceType.GetInterfaces())
                    host.AddServiceEndpoint(intf, basicBinding, String.Empty);

                return host;
            }
            catch (Exception e)
            {
                Trace.TraceError("ServiceFactory: {0}{4}Exception: {1}{4}Message: {2}{4}Trace: {3}",
                               this.GetType().Name,
                               e.GetType(),
                               e.Message,
                               e.StackTrace,
                               Environment.NewLine);
                throw new SystemException(String.Format("Unable to activate service: {0}", serviceType.FullName), e);
            }
        }
开发者ID:jimoneil,项目名称:Azure-Photo-Mosaics,代码行数:32,代码来源:AzureServiceHostFactory.cs

示例13: GetHttpBinding

        private Binding GetHttpBinding()
        {
            var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

            return binding;
        }
开发者ID:RecordLion,项目名称:information-lifecycle-sdk,代码行数:7,代码来源:DefaultSecurityTokenRequestor.cs

示例14: TimetableServiceConfiguration

        public TimetableServiceConfiguration()
        {
            BasicHttpBinding httpBinding = new BasicHttpBinding();

            TimetableServiceClient =
                new TimetableServiceClient(httpBinding, EndPoints.TimetableService);
        }
开发者ID:PatrykOlejniczak,项目名称:WPK.TransportSystem,代码行数:7,代码来源:TimetableServiceConfiguration.cs

示例15: DefaultSettings_Echo_RoundTrips_String

    public static void DefaultSettings_Echo_RoundTrips_String()
    {
        ChannelFactory<IWcfService> factory = null;
        IWcfService serviceProxy = null;
        string testString = "Hello";
        Binding binding = null;

        try
        {
            // *** SETUP *** \\
            binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic));
            serviceProxy = factory.CreateChannel();

            // *** EXECUTE *** \\
            string result = serviceProxy.Echo(testString);

            // *** VALIDATE *** \\
            Assert.True(result == testString, String.Format("Error: expected response from service: '{0}' Actual was: '{1}'", testString, result));

            // *** CLEANUP *** \\
            factory.Close();
            ((ICommunicationObject)serviceProxy).Close();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
        }
    }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:30,代码来源:BasicHttpBindingTests.cs


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