本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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"
};
}
示例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;
}
示例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));
}
}
示例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;
}