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


C# WebChannelFactory.CreateChannel方法代码示例

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


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

示例1: CreateSession

        public string CreateSession(string sessionId)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.Current.Items["SessionId"] = sessionId;
                try
                {
                    var channelFactory =
                        new WebChannelFactory<ISessionServiceRest>(Configuration.SessionServiceConfigurationName);
                    ISessionServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "CreateSession");
                            return channel.CreateSession(sessionId);
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "AddRequestSessionData", Severity.Major);
                }
            }
            return null;
        }
开发者ID:varunupcurve,项目名称:myrepo,代码行数:25,代码来源:SessionService.cs

示例2: GetToken

        public GetTokenResponse GetToken(string sessionId, string tokenId)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.Current.Items["SessionId"] = sessionId;
                try
                {
                    var channelFactory =
                        new WebChannelFactory<ITokenServiceRest>(Configuration.TokenServiceConfigurationName);
                    ITokenServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "GenerateToken");
                            GetTokenResponse response = channel.GetToken(tokenId);
                            return response;
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "GenerateToken", Severity.Major);
                }
            }
            return null;
        }
开发者ID:varunupcurve,项目名称:myrepo,代码行数:26,代码来源:TokenService.cs

示例3: Blip

 public Blip(string user, string password)
 {
     this.user = user;
     this.password = password;
     channelFactory = new WebChannelFactory<IBlipApi>(GetBinding(), new Uri(BlipApiUrl));
     api = channelFactory.CreateChannel();
 }
开发者ID:SkyKnight,项目名称:WcfBlip,代码行数:7,代码来源:Blip.cs

示例4: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Pressione <ENTER> para executar o ws.client...");
            Console.ReadLine();

            // http://localhost:2893/ (URI)

            WebChannelFactory<IProposta> client =
                new WebChannelFactory<IProposta>(
                    new Uri("http://localhost:2893/Proposta.svc"));

            IProposta clientProposta = client.CreateChannel();

            Proposta proposta = new Proposta()
            {
                DescricaoProposta = "Essa proposta foi inserida a partir do console.",
                NomeCliente = "João",
                DataHoraEnviada = DateTime.Now
            };

            Proposta proposta1 = new Proposta()
            {
                DescricaoProposta = "Essa proposta foi inserida a partir do console.",
                NomeCliente = "Maria",
                DataHoraEnviada = DateTime.Now
            };

            clientProposta.EnviarProposta(proposta);
            clientProposta.EnviarProposta(proposta1);

            Console.WriteLine("Chamada Finalizada...");
            Console.ReadLine();
        }
开发者ID:lhlima,项目名称:CollaborationProjects,代码行数:33,代码来源:Program.cs

示例5: ChangeMobile

        public ChangeMobileResponse ChangeMobile(string sessionId, string authenticationId, string mobile)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.SetSessionId(sessionId);
                try
                {
                    var channelFactory =
                        new WebChannelFactory<ILoginServiceRest>(Configuration.LoginServiceConfigurationName);
                    ILoginServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "ChangeMobile");
                            return channel.ChangeMobile(sessionId, authenticationId, mobile);
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "ChangeMobile", Severity.Major);
                }
            }
            return null;
        }
开发者ID:varunupcurve,项目名称:myrepo,代码行数:25,代码来源:LoginService.cs

示例6: CreateSqlDatabaseManagementChannel

 public static ISqlDatabaseManagement CreateSqlDatabaseManagementChannel(Binding binding, Uri remoteUri, X509Certificate2 cert, string requestSessionId)
 {
     WebChannelFactory<ISqlDatabaseManagement> factory = new WebChannelFactory<ISqlDatabaseManagement>(binding, remoteUri);
     factory.Endpoint.Behaviors.Add(new ClientOutputMessageInspector(requestSessionId));
     factory.Credentials.ClientCertificate.Certificate = cert;
     return factory.CreateChannel();
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:SqlDatabaseManagementHelper.cs

示例7: GetVoucherAmount

        public decimal GetVoucherAmount(string sessionId, string voucherCode)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.Current.Items["SessionId"] = sessionId;
                try
                {
                    var channelFactory =
                        new WebChannelFactory<IPaymentServiceRest>(Configuration.PaymentServiceConfigurationName);
                    IPaymentServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "GetVoucherAmount");
                            var response = channel.GetVoucherAmount(sessionId, voucherCode);
                            return response;
                        }
                }
                catch(Exception ex)
                {
                    Logger.LogException(ex, Source, "GetVoucherAmount", Severity.Critical);
                }
            }
            return 0M;
        }
开发者ID:varunupcurve,项目名称:myrepo,代码行数:26,代码来源:PaymentService.cs

示例8: Main

        static void Main(string[] args)
        {
            var factory=new WebChannelFactory<IMachine>(new Uri("http://localhost:8080/wcf"));
            IMachine machine = factory.CreateChannel();

               while (true)
            {
                Console.WriteLine("To submit press 1 \nTo get all machines press 2 \nTo get specific machine name press 3 ");
                string readLine = Console.ReadLine();

                if (readLine == "1")
                {
                    Console.WriteLine("please enter machine name :\n");
                    string machineName = Console.ReadLine();
                    machine.submitMachine(machineName);
                }
                else if (readLine == "2")
                {
                    string allMachines = machine.getAllMachines();

                    Console.WriteLine(allMachines);
                }
                else if (readLine == "3")
                {
                    Console.WriteLine("please enter the machine Id \n");
                    string machineId = Console.ReadLine();
                    string machineName = machine.getMachineName(machineId);
                    Console.WriteLine(machineName);
                }
                else
                {
                    break;
                }
            }
        }
开发者ID:JohanWe,项目名称:Code-Sample,代码行数:35,代码来源:Program.cs

示例9: Main

        /// <summary>
        /// </summary>
        public static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Gathering files");
                var files = new List<FileDescriptor>();
                if (args != null)
                {
                    files.AddRange(
                        args
                        .Where(File.Exists)
                        .Select(a => new FileDescriptor { Name = a, Contents = File.ReadAllBytes(a) }));
                }

                Console.WriteLine("Send files");
                using (var f = new WebChannelFactory<IFileTracker>(new Uri("http://localhost/samplewcf/Call.svc/FileTracker")))
                {
                    var c = f.CreateChannel();
                    var i = c.Track(files.ToArray());
                    Console.WriteLine("Server said:");
                    Console.Write(i);
                }
                Console.WriteLine("Done");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ResetColor();
            }
        }
开发者ID:visionwang,项目名称:SampleWcf,代码行数:34,代码来源:Program.cs

示例10: CreateGatewayManagementChannel

 public static IGatewayServiceManagement CreateGatewayManagementChannel(Binding binding, Uri remoteUri, X509Certificate2 cert)
 {
     WebChannelFactory<IGatewayServiceManagement> factory = new WebChannelFactory<IGatewayServiceManagement>(binding, remoteUri);
     factory.Endpoint.Behaviors.Add(new ServiceManagementClientOutputMessageInspector());
     factory.Credentials.ClientCertificate.Certificate = cert;
     return factory.CreateChannel();
 }
开发者ID:bueti,项目名称:azure-sdk-tools,代码行数:7,代码来源:GatewayManagementHelper.cs

示例11: Main

        static void Main(string[] args)
        {
            Console.ReadLine();
             //var client = new EvalServiceClient("BasicHttpBinding_IEvalService");

             WebChannelFactory<IEvalService> cf =
            new WebChannelFactory<IEvalService>(new Uri("http://localhost:8080/evalservice"));

             IEvalService client = cf.CreateChannel();

             client.SubmitEval(new Eval
             {
            Comments = "This came from code",
            Submitter = "Sean",
            TimeSubmitted = DateTime.Now
             });
             Console.WriteLine("Save success");
             Console.WriteLine("Load Evals");
             var evals = client.GetEvals();
             foreach (var eval in evals)
             {
            Console.WriteLine(eval.Comments);
             }
             Console.WriteLine("End load Evals");
             Console.Read();
        }
开发者ID:xujihui1985,项目名称:WCFFundamental,代码行数:26,代码来源:Program.cs

示例12: GetReservationListing

        public ReservationListingResponse GetReservationListing(string sessionId, RequestParams requestParams)
        {
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.SetSessionId(sessionId);
                try
                {
                    var channelFactory =
                        new WebChannelFactory<IAirlinesAdminServiceRest>(
                            Configuration.AirlinesAdminServiceConfigurationName);
                    IAirlinesAdminServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName",
                                                                                    "GetReservationListing");
                            ReservationListingResponse response = channel.GetReservationListing(sessionId, requestParams);
                            if (response != null && response.IsSuccess)
                            {
                                return response;
                            }
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "GetReservationListing", Severity.Major);
                }
            }
            return new ReservationListingResponse
                       {
                           IsSuccess = false,
                           ErrorMessage = "Failed to get Reservation Listing. Please try again after some time"
                       };
        }
开发者ID:varunupcurve,项目名称:myrepo,代码行数:35,代码来源:AirlinesAdminService.cs

示例13: CreateServiceManagementChannel

		public static IServiceManagement CreateServiceManagementChannel(string endpointConfigurationName, Uri remoteUri, X509Certificate2 cert)
		{
			WebChannelFactory<IServiceManagement> webChannelFactory = new WebChannelFactory<IServiceManagement>(endpointConfigurationName, remoteUri);
			webChannelFactory.Endpoint.Behaviors.Add(new ClientOutputMessageInspector());
			webChannelFactory.Credentials.ClientCertificate.Certificate = cert;
			IServiceManagement serviceManagement = webChannelFactory.CreateChannel();
			return serviceManagement;
		}
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:ServiceManagementHelper.cs

示例14: CanCallRestfulHostedService

		public void CanCallRestfulHostedService()
		{
			using (var factory = new WebChannelFactory<IAmUsingWindsor>(
				new Uri("http://localhost:27197/UsingWindsorRest.svc")))
			{
				Assert.AreEqual(126, factory.CreateChannel().MultiplyValueFromWindsorConfig(3));
			}
		}
开发者ID:dohansen,项目名称:Windsor,代码行数:8,代码来源:RestClientFixture.cs

示例15: CreateServiceManagementChannel

        public static IServiceManagement CreateServiceManagementChannel(X509Certificate2 cert)
        {
            WebChannelFactory<IServiceManagement> factory = new WebChannelFactory<IServiceManagement>();
            factory.Endpoint.Behaviors.Add(new ClientOutputMessageInspector());
            factory.Credentials.ClientCertificate.Certificate = cert;

            var channel = factory.CreateChannel();
            return channel;
        }
开发者ID:chandermani,项目名称:deployToAzureTFS2013,代码行数:9,代码来源:ServiceManagementHelper.cs


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