public void SubmitEval(Eval eval) { if (eval.Submitter.Equals("Throw")) throw new FaultException("Error when submit eval."); _evals.Add(eval); }
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(); } }