本文整理汇总了C#中WebChannelFactory类的典型用法代码示例。如果您正苦于以下问题:C# WebChannelFactory类的具体用法?C# WebChannelFactory怎么用?C# WebChannelFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebChannelFactory类属于命名空间,在下文中一共展示了WebChannelFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例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: 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
示例4: GetTodosFiltered
public void GetTodosFiltered()
{
using (var server = new WebServiceHost(new TodoService(), new Uri(_hostAddress)))
using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
{
server.Open();
client.Open();
var channel = client.CreateChannel();
using (new OperationContextScope((IContextChannel)channel))
{
var todos = channel.GetTodosFiltered(true);
ValidateHttpStatusResponse(HttpStatusCode.OK);
Assert.AreEqual(1, todos.Todo.Length);
}
using (new OperationContextScope((IContextChannel)channel))
{
var todos = channel.GetTodosFiltered(false);
ValidateHttpStatusResponse(HttpStatusCode.OK);
Assert.AreEqual(2, todos.Todo.Length);
}
}
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:26,代码来源:UnitTests.cs
示例5: 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
示例6: CreateWorldGeocoder
/// <summary>
/// Creates a new instance of the <see cref="WorldGeocoder"/> class for the specified
/// service configuration.
/// </summary>
/// <param name="serviceInfo">The instance of the geocoding service configuration
/// specifying World geocoder service to create geocoder for.</param>
/// <param name="exceptionHandler">Exception handler.</param>
/// <returns>A new instance of the <see cref="WorldGeocoder"/> class.</returns>
/// <exception cref="System.ArgumentNullException"><paramref name="serviceInfo"/> is a null
/// reference.</exception>
public static GeocoderBase CreateWorldGeocoder(GeocodingServiceInfo serviceInfo,
IServiceExceptionHandler exceptionHandler)
{
CodeContract.RequiresNotNull("serviceInfo", serviceInfo);
// Create binding for the geocoder REST service.
var webBinding = ServiceHelper.CreateWebHttpBinding("WorldGeocoder");
var binding = new CustomBinding(webBinding);
var messageEncodingElement = binding.Elements.Find<WebMessageEncodingBindingElement>();
messageEncodingElement.ContentTypeMapper = new ArcGisWebContentTypeMapper();
// Create endpoint for the geocoder REST service.
var contract = ContractDescription.GetContract(typeof(IGeocodingService));
var serviceAddress = new EndpointAddress(serviceInfo.RestUrl);
var endpoint = new WebHttpEndpoint(contract, serviceAddress);
endpoint.Binding = binding;
// Replace default endpoint behavior with a customized one.
endpoint.Behaviors.Remove<WebHttpBehavior>();
endpoint.Behaviors.Add(new GeocodingServiceWebHttpBehavior());
// Create the geocoder instance.
var channelFactory = new WebChannelFactory<IGeocodingService>(endpoint);
var client = new GeocodingServiceClient(channelFactory, serviceInfo, exceptionHandler);
return new WorldGeocoder(serviceInfo, client);
}
开发者ID:erindm,项目名称:route-planner-csharp,代码行数:37,代码来源:WorldGeocoder.cs
示例7: CreateServiceManagementChannel
public static IGithubServiceManagement CreateServiceManagementChannel(Uri remoteUri, string username, string password)
{
WebChannelFactory<IGithubServiceManagement> factory;
if (_factories.ContainsKey(remoteUri.ToString()))
{
factory = _factories[remoteUri.ToString()];
}
else
{
factory = new WebChannelFactory<IGithubServiceManagement>(remoteUri);
factory.Endpoint.Behaviors.Add(new GithubAutHeaderInserter() {Username = username, Password = password});
WebHttpBinding wb = factory.Endpoint.Binding as WebHttpBinding;
wb.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
wb.Security.Mode = WebHttpSecurityMode.Transport;
wb.MaxReceivedMessageSize = 10000000;
if (!string.IsNullOrEmpty(username))
{
factory.Credentials.UserName.UserName = username;
}
if (!string.IsNullOrEmpty(password))
{
factory.Credentials.UserName.Password = password;
}
_factories[remoteUri.ToString()] = factory;
}
return factory.CreateChannel();
}
开发者ID:nicopeelen,项目名称:azure-sdk-tools,代码行数:31,代码来源:GithubClient.cs
示例8: 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
示例9: 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
示例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: 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
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: 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
示例18: 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:prodigeni,项目名称:cloudify,代码行数:9,代码来源:ServiceManagementHelper.cs
示例19: Main
static void Main(string[] args)
{
ServiceHost sh = new ServiceHost(typeof(Service),new Uri("http://localhost:8000/"));
sh.AddServiceEndpoint(typeof(IService),new BasicHttpBinding(),"Soap");
ServiceEndpoint endpoint = sh.AddServiceEndpoint(typeof(IService),new WebHttpBinding(),"Web");
endpoint.Behaviors.Add(new WebHttpBehavior());
//endpoint.EndpointBehaviors.Add(new WebHttpBehavior());
foreach (IEndpointBehavior behavior in endpoint.Behaviors)
{
Console.WriteLine("Behavior: {0}", behavior.ToString());
}
sh.Open();
using (WebChannelFactory<IService> wcf = new WebChannelFactory<IService>(new Uri("http://localhost:8000/web")))
{
IService channel = wcf.CreateChannel();
string s;
Console.WriteLine("Calling EchoWithGet by HTTP GET: ");
s = channel.EchoWithGet("Hello, world");
Console.WriteLine(" Output: {0}", s);
Console.WriteLine("");
Console.WriteLine("This can also be accomplished by navigating to");
Console.WriteLine("http://localhost:8000/Web/EchoWithGet?s=Hello, world!");
Console.WriteLine("in a web browser while this sample is running.");
Console.WriteLine("");
Console.WriteLine("Calling EchoWithPost by HTTP POST: ");
s = channel.EchoWithPost("Hello, world");
Console.WriteLine(" Output: {0}", s);
Console.WriteLine();
}
using (ChannelFactory<IService> wcf = new ChannelFactory<IService>(new BasicHttpBinding(), "http://localhost:8000/Soap"))
{
IService channel = wcf.CreateChannel();
string s;
Console.WriteLine("Calling EchoWithGet on SOAP endpoint: ");
s = channel.EchoWithGet("Hello, world");
Console.WriteLine(" Output: {0}", s);
Console.WriteLine("");
Console.WriteLine("Calling EchoWithPost on SOAP endpoint: ");
s = channel.EchoWithPost("Hello, world");
Console.WriteLine(" Output: {0}", s);
Console.WriteLine();
Console.ReadLine();
}
sh.Close();
}
开发者ID:Edward-Zhou,项目名称:GettingStartedWCF,代码行数:56,代码来源:Program.cs
示例20: CallRestService
private static void CallRestService()
{
//Connect to api/RestService
Uri baseAddress = new Uri("http://localhost:58788/api/RestService");
//WebChannelFactory WebHttpBehavior, WebHttpBinding
WebChannelFactory<IRestService> cf = new WebChannelFactory<IRestService>(baseAddress);
IRestService service = cf.CreateChannel();
Person person = service.GetPerson("1");
}
开发者ID:cleancodenz,项目名称:MVC4DEV,代码行数:10,代码来源:Program.cs
注:本文中的WebChannelFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论