static void Main(string[] args) { //ChannelFactory<IEvalService> factory = new ChannelFactory<IEvalService>("BasicHttpBinding_IEvalService"); //IEvalService channel = factory.CreateChannel(); var channel = new EvalServiceClient("BasicHttpBinding_IEvalService"); try { channel.SubmitEval(new Eval { Comments = "hepp", Submitter = "hopp", Timesent = DateTime.Now }); foreach (var item in channel.GetEvals()) { Console.WriteLine(item.Comments + " " + item.Submitter + " " + item.Timesent); } Console.ReadKey(); channel.Close(); } catch (TimeoutException ex) { Console.WriteLine(ex.Message); } //((IClientChannel)channel).Close(); }
static void Main(string[] args) { EvalServiceClient evalServiceClient = new EvalServiceClient(); Eval eval; eval = new Eval { Comments = "CommentsField1", Submitter = "Submitter1", TimeSubmitted = DateTime.Now }; evalServiceClient.SubmitEval(eval); eval = new Eval { Comments = "CommentsField2", Submitter = "Submitter2", TimeSubmitted = DateTime.Now }; evalServiceClient.SubmitEval(eval); eval = new Eval { Comments = "CommentsField3", Submitter = "Submitter3", TimeSubmitted = DateTime.Now }; evalServiceClient.SubmitEval(eval); Eval[] evals = evalServiceClient.GetEvals(); foreach (Eval e in evals) { Console.WriteLine("{0}\t{1}\t{2}", e.Id, e.Submitter, e.TimeSubmitted); } evalServiceClient.Close(); Console.ReadLine(); }
static void WorkViaGeneratedProxy() { Console.WriteLine("Retrieving endpoints vis MEX..."); ServiceEndpointCollection endpoints = MetadataResolver.Resolve(typeof(IEvalService), new EndpointAddress("http://localhost:8080/evals/mex")); Console.WriteLine("Endpoints retrieved"); foreach (var endpoint in endpoints) { Console.WriteLine(endpoint.Address.Uri); var client = new EvalServiceClient(endpoint.Binding, endpoint.Address); try { WorkWithService(client); client.Close(); } catch (FaultException fe) { Console.WriteLine($"Fault exception: {fe.GetType()}"); client.Abort(); } catch (CommunicationException ce) { Console.WriteLine($"Communication exception: {ce.GetType()}"); client.Abort(); } catch (TimeoutException te) { Console.WriteLine($"Timeout exception: {te.GetType()}"); client.Abort(); } } }
static void Main(string[] args) { EvalServiceClient evalServiceClient = new EvalServiceClient("NetTcpBinding_IEvalService"); DetailedEval eval; eval = new DetailedEval(); eval.From = "SJain"; eval.Timespent = System.DateTime.Now.ToString(); eval.What = "1.From Client"; eval.additional = "1. Additional comments from Client"; evalServiceClient.SubmitEvals(eval); eval = new DetailedEval(); eval.From = "KJain"; eval.Timespent = System.DateTime.Now.ToString(); eval.What = "2. From Client "; eval.additional = "2. Additional comments from Client"; evalServiceClient.SubmitEvals(eval); List <Evaluation> evalList = evalServiceClient.GetEvals(); foreach (var Evaluation in evalList) { Console.WriteLine($"{Evaluation.What}"); } Console.ReadLine(); }
static void Main(string[] args) { var client = new EvalServiceClient("WSHttpBinding_IEvalService"); var cb = new MessageInspectorBehavior(); // Add the custom behaviour to the list of service behaviours. client.Endpoint.Behaviors.Add(cb); cb.OnMessageInspected += (src, e) => { //if (e.MessageInspectionType == eMessageInspectionType.Request) request = e.Message; //else response = e.Message; }; var eval = new Eval { Comments = "InterOP", Id = Guid.NewGuid().ToString(), Submitter = "Daniel", TimeSubmitted = DateTime.Now }; client.SubmitEval(eval); var allEvall = client.GetEvals(); var test = 0; }
static void Main(string[] args) { #region example using ChannelFactory<T> directly //ChannelFactory<IEvalService> cf = // new ChannelFactory<IEvalService>("WSHttpBinding_IEvalService"); //IEvalService channel = cf.CreateChannel(); #endregion Console.WriteLine("Retrieving endpoints via MEX..."); ServiceEndpointCollection endpoints = MetadataResolver.Resolve(typeof(IEvalService), new EndpointAddress("http://localhost:8080/evals/mex")); foreach (ServiceEndpoint se in endpoints) { EvalServiceClient channel = new EvalServiceClient(se.Binding, se.Address); try { EvalServiceLibrary.Eval eval = new EvalServiceLibrary.Eval("Aaron", "I'm really liking this"); channel.SubmitEval(eval); channel.SubmitEval(eval); List<EvalServiceLibrary.Eval> evals = channel.GetEvals(); Console.WriteLine("Number of evals: {0}", evals.Count); #region async example //channel.GetEvalsCompleted += new EventHandler<GetEvalsCompletedEventArgs>(channel_GetEvalsCompleted); //channel.GetEvalsAsync(); //Console.WriteLine("Waiting..."); //Console.ReadLine(); #endregion channel.Close(); } catch (FaultException fe) { Console.WriteLine("FaultException handler: {0}", fe.GetType()); channel.Abort(); } catch (CommunicationException ce) { Console.WriteLine("CommunicationException handler: {0}", ce.GetType()); channel.Abort(); } catch (TimeoutException te) { Console.WriteLine("TimeoutException handler: {0}", te.GetType()); channel.Abort(); } } }
static void Main(string[] args) { #region example using ChannelFactory<T> directly //ChannelFactory<IEvalService> cf = // new ChannelFactory<IEvalService>("WSHttpBinding_IEvalService"); //IEvalService channel = cf.CreateChannel(); #endregion Console.WriteLine("Retrieving endpoints via MEX..."); ServiceEndpointCollection endpoints = MetadataResolver.Resolve(typeof(IEvalService), new EndpointAddress("http://localhost:8080/evals/mex")); foreach (ServiceEndpoint se in endpoints) { EvalServiceClient channel = new EvalServiceClient(se.Binding, se.Address); try { EvalServiceLibrary.Eval eval = new EvalServiceLibrary.Eval("Aaron", "I'm really liking this"); channel.SubmitEval(eval); channel.SubmitEval(eval); List <EvalServiceLibrary.Eval> evals = channel.GetEvals(); Console.WriteLine("Number of evals: {0}", evals.Count); #region async example //channel.GetEvalsCompleted += new EventHandler<GetEvalsCompletedEventArgs>(channel_GetEvalsCompleted); //channel.GetEvalsAsync(); //Console.WriteLine("Waiting..."); //Console.ReadLine(); #endregion channel.Close(); } catch (FaultException fe) { Console.WriteLine("FaultException handler: {0}", fe.GetType()); channel.Abort(); } catch (CommunicationException ce) { Console.WriteLine("CommunicationException handler: {0}", ce.GetType()); channel.Abort(); } catch (TimeoutException te) { Console.WriteLine("TimeoutException handler: {0}", te.GetType()); channel.Abort(); } } }
private static void GetAll(EvalServiceClient evalServiceClient) { List <Evaluation> evalList = evalServiceClient.GetEvals(); foreach (var Evaluation in evalList) { Console.WriteLine($"{Evaluation.What}"); } }
private static void Submit(EvalServiceClient evalServiceClient, string submitter, string comment) { Evaluation eval; eval = new Evaluation(); eval.From = submitter; eval.Timespent = System.DateTime.Now.ToString(); eval.What = comment; evalServiceClient.SubmitEvals(eval); }
static void Main(string[] args) { EvalServiceClient esc = new EvalServiceClient("WSHttpBinding_IEvalService"); esc.SubmitEval(new Eval() { Comments = "Coming from code behind", Submitter = "Semih", TimeSubmitted = DateTime.Now }); Eval[] evals = esc.GetEvals(); foreach (Eval item in evals) { Console.WriteLine(item.Comments + " - " + item.Submitter); } Console.ReadKey(); }
static void Main(string[] args) { EvalServiceClient client = new EvalServiceClient("NetTcpBinding_IEvalService"); Eval eval = new Eval(); eval.Submitter = "Bob"; eval.Timesent = DateTime.Now; eval.Comments = "Hope this works!"; client.SubmitEval(eval); Console.WriteLine("Number of evals: {0}", client.GetEvals().Length); }
public static void Main(string[] args) { // var cf = new ChannelFactory<IEvalServiceChannel>("NetNamedPipeBinding_IEvalService"); // var channel = cf.CreateChannel(); var endpoints = MetadataResolver.Resolve( typeof(IEvalService), new EndpointAddress("http://localhost:8080/evals/mex")); foreach (var se in endpoints) { var channel = new EvalServiceClient(se.Binding, se.Address); // var channel = new EvalServiceClient("WSHttpBinding_IEvalService"); try { var eval = new Eval(); eval.Submitter = "Howard"; eval.Timesent = DateTime.Now; eval.Comments = "I'm thinking this..."; channel.SubmitEval(eval); channel.SubmitEval(eval); var evals = channel.GetEvals(); Console.WriteLine("Number of evals: {0}", evals.Count); channel.Close(); } catch (FaultException fe) { Console.WriteLine("FaultException handler: {0}", fe.GetType()); channel.Abort(); } catch (CommunicationException ce) { Console.WriteLine("CommunicationException handler: {0}", ce.GetType()); channel.Abort(); } catch (TimeoutException te) { Console.WriteLine("TimeoutException handler: {0}", te.GetType()); channel.Abort(); } } Console.ReadLine(); }
static void Main(string[] args) { var client = new EvalServiceClient("BasicHttpBinding_IEvalService"); client.SubmitEval(new Eval { Comments = "This came from code", Submitter = "Sean", TimeSubmitted = DateTime.Now }); Console.WriteLine("Save success"); Console.WriteLine("dfffsdf"); Console.WriteLine("Load Evals"); var evals = client.GetEvals(); foreach (var eval in evals) { Console.WriteLine(eval.Comments); } Console.WriteLine("End load Evals"); Console.Read(); }
static void Main(string[] args) { var clientEval = new EvalServiceClient("CustomBinding_IEvalService"); var eval = new Eval { Comments = "InterOP", Id = Guid.NewGuid().ToString(), Submitter = "Korvus", TimeSubmitted = DateTime.Now }; try { clientEval.SubmitEval(eval); Console.WriteLine("uspesno!"); } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { Console.WriteLine("Press <Enter> to run the client..."); Console.ReadLine(); EvalServiceClient client = new EvalServiceClient("BasicHttpBinding_IEvalService"); Eval eval = new Eval(); eval.Comments = "This came from code!"; eval.Submitter = "Aaron"; eval.TimeSubmitted = DateTime.Now; client.SubmitEval(eval); Eval[] evals = client.GetEvals(); foreach (Eval ev in evals) { Console.WriteLine(ev.Comments); } Console.ReadLine(); }
static void Main(string[] args) { // create a factory /////////////////////////////////////////////////// // factory by name ChannelFactory<IEvalService> factory1 = new ChannelFactory<IEvalService>("BasicHttpBinding_IEvalService"); // factory by endpoint ChannelFactory<IEvalService> factory2 = new ChannelFactory<IEvalService>(new WSHttpBinding(), "http://localhost:8080/evals/wsconfig"); // channel - basic, hidden IClientChannel /////////////////////////////////////////////////// IEvalService channel1 = factory1.CreateChannel(); try { channel1.GetEvals(); Eval eval = new Eval(); eval.Submitter = "Jay"; eval.Timesent = DateTime.Now; eval.Comments = "One eval to rule them alll!!!!!!!!!"; channel1.SubmitEval(eval); channel1.SubmitEval(eval); Console.ReadLine(); ((IClientChannel)channel1).Close(); } catch (Exception) { ((IClientChannel)channel1).Abort(); } // channel client - integrated IClientChannel /////////////////////////////////////////////////// ChannelFactory<IEvalServiceChannel> factory3 = new ChannelFactory<IEvalServiceChannel>("BasicHttpBinding_IEvalService"); IEvalServiceChannel channel2 = factory3.CreateChannel(); try { Eval[] evals = channel2.GetEvals(); Console.WriteLine("Number of evals: {0}", evals.Length); Console.ReadLine(); channel2.Close(); } catch (Exception) { channel2.Abort(); } // proxy client /////////////////////////////////////////////////// EvalServiceClient client1 = new EvalServiceClient("BasicHttpBinding_IEvalService"); try { Eval[] evals = client1.GetEvals(); Console.WriteLine("Number of evals: {0}", evals.Length); Console.ReadLine(); client1.Close(); } catch (Exception) { client1.Abort(); } }
static void Main(string[] args) { Console.WriteLine("########################################"); Console.WriteLine("# WCF Simple Client 1.0 by HarryGG"); Console.WriteLine("########################################" + Environment.NewLine); string selection = "Type: 1 to add comment, 2 to view comments, 3 to exit"; Console.WriteLine(selection); Console.Write(">"); string action = Console.ReadLine(); string comment = null; string name = null; //EvalServiceClient WSHttpBinding_client = new EvalServiceClient("WSHttpBinding_IEvalService"); EvalServiceClient WSHttpBinding_client = new EvalServiceClient(); try { while (action != "3" && action != "exit") { switch (action) { case "1": Console.WriteLine("Write comment and hit <Enter> to submit:"); comment = Console.ReadLine(); Console.WriteLine("Write your name and hit <Enter> to submit:"); name = Console.ReadLine(); Eval eval = new Eval(); eval.Comments = comment; eval.Submitter = name; eval.TimeSubmitted = DateTime.Now; System.ServiceModel.Configuration.ClientSection clientSection = (System.ServiceModel.Configuration.ClientSection)ConfigurationManager.GetSection("system.serviceModel/client"); System.ServiceModel.Configuration.ChannelEndpointElement endpoint = clientSection.Endpoints[0]; //string endpointStr = endpoint.Address.ToString(); Console.WriteLine("Submitting comment to endpoint "); // + endpointStr); WSHttpBinding_client.SubmitEval(eval); Console.WriteLine("Comment submitted!" + Environment.NewLine); Console.WriteLine(selection); Console.Write(">"); action = Console.ReadLine(); break; case "2": Console.WriteLine("Getting list of submitted comments..."); Eval[] evals = WSHttpBinding_client.GetEvals(); int i = 0; if (evals.Length > 0) { Console.WriteLine(evals.Length + " comments retrieved successfully:"); Console.WriteLine(Environment.NewLine); foreach (Eval ev in evals) { Console.WriteLine(++i + ": " + ev.Comments + " from user " + ev.Submitter); } } else { Console.WriteLine(Environment.NewLine); Console.WriteLine("No comments found! I suggest you first add some comments!"); } Console.WriteLine(Environment.NewLine); Console.WriteLine(selection); Console.Write(">"); action = Console.ReadLine(); break; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine("*********************************************************"); //Console.WriteLine(selection); //Console.Write(">"); //action = Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("*** Evaluation Client Application ***\n"); EvalServiceClient client = new EvalServiceClient("BasicHttpBinding_IEvalService"); Console.WriteLine("Please enter a command: "); string command = Console.ReadLine(); while (!command.Equals("exit")) { switch (command) { case "submit": Console.WriteLine("Please enter your name:"); string name = Console.ReadLine(); Console.WriteLine("Please enter your comments:"); string comments = Console.ReadLine(); Eval eval = new Eval(); eval.TimeSent = DateTime.Now; eval.Submitter = name; eval.Comments = comments; client.SubmitEval(eval); Console.WriteLine("Evaluation submitted! \n"); break; case "get": Console.WriteLine("Please enter the eval id:"); string id = Console.ReadLine(); Eval fe = client.GetEval(id); Console.WriteLine("{0} -- {1} said: {2} (id {3}) \n", fe.TimeSent, fe.Submitter, fe.Comments, fe.Id); break; case "list": Console.WriteLine("Please enter the submitter name:"); name = Console.ReadLine(); List <Eval> evals = client.GetEvalBySubmitter(name); evals.ForEach(e => Console.WriteLine("{0} -- {1} said: {2} (id {3})", e.TimeSent, e.Submitter, e.Comments, e.Id)); Console.WriteLine(); break; case "remove": Console.WriteLine("Please enter the eval id:"); id = Console.ReadLine(); client.RemoveEval(id); Console.WriteLine("Evaluation {0} removed! \n", id); break; default: Console.WriteLine("Unsupported command."); break; } Console.WriteLine("Please eneter a command: "); command = Console.ReadLine(); } }
static void Main(string[] args) { Console.WriteLine("Enter Command to Execute Submit/Get, <Exit> to exit"); string command = Console.ReadLine(); if (command.Equals("Exit")) { goto close; } //EvalServiceClient evalServiceClient = new EvalServiceClient("BasicHttpBinding_IEvalService"); EvalServiceClient evalServiceClient = new EvalServiceClient("NetTcpBinding_IEvalService"); while (!command.Equals("Exit")) { try { switch (command.ToLower()) { case "submit": Console.WriteLine("Enter Submitter"); string submitter = Console.ReadLine(); Console.WriteLine("Enter Comments"); string comments = Console.ReadLine(); Submit(evalServiceClient, submitter, comments); break; case "get": GetAll(evalServiceClient); break; default: Console.WriteLine("Incorrect input Enter Submit/Get"); break; } } catch (FaultException <BadEvalSubmission> bad) { Console.WriteLine("FaultException<BadEvalSubmission> is called"); Console.WriteLine(bad.Message); } catch (FaultException e) { Console.WriteLine("FaultException handler is called"); Console.WriteLine(e.Message); } catch (CommunicationException ce) { Console.WriteLine("CommunicationException handler is called"); Console.WriteLine(ce.Message); } catch (TimeoutException te) { Console.WriteLine("Timeout handler is called"); Console.WriteLine(te.Message); } catch (Exception e) { Console.WriteLine("General Exception is called"); Console.WriteLine(e.Message); } finally { if (evalServiceClient.State == CommunicationState.Faulted) { Console.WriteLine("Clinet Channel has faulted...Creating new channel"); } evalServiceClient.Abort(); evalServiceClient = new EvalServiceClient("NetTcpBinding_IEvalService"); } Console.WriteLine("\n Enter Command to Execute Submit/Get, <Exit> to exit"); if (command.Equals("Exit")) { goto close; } command = Console.ReadLine(); } Console.ReadLine(); close : Console.WriteLine("........."); }
static void Main(string[] args) { //var cf = new ChannelFactory<IEvalServiceChannel>("End4"); //var service = cf.CreateChannel(); var endpoints = MetadataResolver.Resolve(typeof (IEvalService), new EndpointAddress("http://localhost:8085/evals/mex")); foreach (var endpoint in endpoints) { var service = new EvalServiceClient(endpoint.Binding, endpoint.Address); try { var newEval = new Eval { Comments = "Testing", Submitter = "Rafael", Timesent = DateTime.Now }; service.SubmitEval(newEval); service.SubmitEval(newEval); //var evals = service.GetEvals(); service.GetEvalsCompleted += service_GetEvalsCompleted; service.GetEvalsAsync(); Console.WriteLine("Waiting..."); //Thread.Sleep(10000); Console.WriteLine("Waiting More..."); //Console.ReadLine(); //foreach (var eval in evals) //{ // Console.WriteLine(eval.Submitter + " " + eval.Comments); //} service.Close(); } catch (FaultException exception) { Console.WriteLine("Ops... Something went wrong"); Console.WriteLine(exception); service.Abort(); } catch (CommunicationException exception) { Console.WriteLine("Ops... Something went wrong"); Console.WriteLine(exception); service.Abort(); } catch (TimeoutException exception) { Console.WriteLine("Ops... Something went wrong"); Console.WriteLine(exception); service.Abort(); } Console.ReadLine(); } }