Example #1
0
        static void Main(string[] args)
        {
            var client = new HelloWorldServiceClient();

            Console.WriteLine(client.GetMessage("tapos ghosh"));
            Console.ReadKey();
        }
Example #2
0
        /// <summary>
        /// Demonstrates hosting a service in a console application
        /// Furture demonstrates Consuming the service hosted in a console application
        /// See page 55, Chapter 3, 'Hosting the service in a managed application' - WCF 4.5 Multi-Layer Services Development with Entity Framework
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            /**** HOSTING ****/

            /*
             * ServiceHost host = new ServiceHost(typeof(WCFServices.HelloWorldService),new Uri("http://localhost:18578/HostCmdLineApp/HelloWorldService.svc"));
             * host.Open();
             * Console.WriteLine("HelloWorldService is now running. ");
             *
             * HelloWorldServiceClient client = new HelloWorldServiceClient();
             *
             * Console.WriteLine(client.GetMessage("Paul hosted from cmd line"));
             * Console.WriteLine("Press any key to stop it ...");
             * Console.ReadKey();
             *
             * host.Close();
             */

            /**** CONSUMING ****/
            //HelloWorldServiceClient client = new HelloWorldServiceClient();
            //Console.WriteLine(client.GetMessage("Paul hosted from cmd line"));

            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine(client.GetMessage("Paul hosted from IIS"));
        }
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine(client.GetMessage("Paul"));
            Console.ReadLine();
        }
Example #4
0
        private void LoadWord()
        {
            HelloWorldServiceClient proxy = new HelloWorldServiceClient();

            proxy.GetWordCompleted += ProxyOnGetWordCompleted;
            proxy.GetWordAsync();
        }
Example #5
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();
            Console.WriteLine(client.GetMessage("Gavin McCoy"));
            Console.WriteLine(client.AddTwoNumbers(55, 45));

        }
Example #6
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient x = new HelloWorldServiceClient();

            Console.WriteLine(x.SayHello("Yashwant"));
            Console.ReadKey();
        }
Example #7
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (var proxy = new HelloWorldServiceClient())
     {
         MessageBox.Show(proxy.HelloWorld("StaticProxyClient"));
     }
 }
Example #8
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine(client.SayHello("don fernando"));
            client.Close();
            Console.ReadLine();
        }
Example #9
0
        private void InitializeHelloWorldServiceClient()
        {
            BasicHttpBinding binding = CreateBasicHttp();

            _client = new HelloWorldServiceClient(binding, EndPoint);
            _client.SayHelloToCompleted   += ClientOnSayHelloToCompleted;
            _client.GetHelloDataCompleted += ClientOnGetHelloDataCompleted;
        }
Example #10
0
        private void InitializeHelloWorldServiceClient()
        {
            BasicHttpBinding binding = CreateBasicHttp();

            _client = new HelloWorldServiceClient(binding, EndPoint);
            _client.SayHelloToCompleted += ClientOnSayHelloToCompleted;
            _client.GetHelloDataCompleted += ClientOnGetHelloDataCompleted;
        }
Example #11
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine(client.GetMessage("Mike Liu"));
            client.Close();
            Console.ReadKey();
        }
Example #12
0
        public void Bug36080Test()
        {
            int port = NetworkHelpers.FindFreePort();
            var url  = "http://localhost:" + port + "/HelloWorldService";

            TransportBindingElement element = new HttpTransportBindingElement {
                MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue
            };
            Binding binding = new CustomBinding(new BindingElement[]
            {
                new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8),
                element
            });

#if !MOBILE
            // Init service
            ServiceHost serviceHost = new ServiceHost(typeof(HelloWorldServiceImpl), new Uri(url));
            serviceHost.AddServiceEndpoint(typeof(IHelloWorldService), binding, string.Empty);

            serviceHost.Open();
#endif
            // In Mobile we still run this tests without any server.
            // Issue reported in #36080 was occuring before the connections fails.
            var wait = new ManualResetEvent(false);

            Exception error  = null;
            string    result = null;

            try {
                var client = new HelloWorldServiceClient(binding, new EndpointAddress(url));
                client.SayHelloToCompleted += delegate(object o, SayHelloToCompletedEventArgs e) {
                    try {
                        error  = e.Error;
                        result = e.Error == null ? e.Result : null;
                    } finally {
                        wait.Set();
                    }
                };

                var str = "Xamarin";
                client.SayHelloToAsync(str);

                Assert.IsTrue(wait.WaitOne(TimeSpan.FromSeconds(20)), "timeout");
#if MOBILE
                if (error.GetType() == typeof(EndpointNotFoundException))
                {
                    return;
                }
#endif

                Assert.IsNull(error, "#1, inner exception: {0}", error);
                Assert.AreEqual(str, result, "#2");
            }  finally {
#if !MOBILE
                serviceHost.Close();
#endif
            }
        }
Example #13
0
        public static string Run()
        {
            TodaysDataRequest       request  = new TodaysDataRequest();
            TodaysDataResponse      response = new TodaysDataResponse();
            HelloWorldServiceClient client   = new HelloWorldServiceClient();

            response = client.GetTodaysData(request);
            return(response.Message);
        }
Example #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Waiting service start(5 seconds)");
            Thread.Sleep(5000);

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            var helloWorldServiceClient = new HelloWorldServiceClient();

            Console.WriteLine(helloWorldServiceClient.SayHello("Alberto"));
        }
Example #15
0
        private void InitializeHelloWorldServiceClient()
        {
            BasicHttpBinding binding = CreateBasicHttp();

            _client = new HelloWorldServiceClient(binding, EndPoint);
            _client.SayHelloToCompleted   += ClientOnSayHelloToCompleted;
            _client.GetHelloDataCompleted += ClientOnGetHelloDataCompleted;

            getHelloWorldDataButton.TouchUpInside += GetHelloWorldDataButtonTouchUpInside;
            sayHelloWorldButton.TouchUpInside     += SayHelloWorldDataButtonTouchUpInside;
        }
Example #16
0
        public ActionResult Show(HelloWorldViewModel model)
        {
            string result = string.Empty;

            using (HelloWorldServiceClient client = new HelloWorldServiceClient())
            {
                result = client.Hello(model.Name);
            }

            return(Content(result));
        }
Example #17
0
        static void Main(string[] args)
        {
            ILogService             logService = new FileLogService(typeof(Program));
            HelloWorldServiceClient client     = new HelloWorldServiceClient();

            logService.Info("Preparing to call the Hello World Service");
            Console.WriteLine(client.GetMessage("Console Client App"));
            logService.Info("Hello World Service has returned");
            Console.WriteLine("Log has been written");
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
Example #18
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient("WSHttpBinding_IHelloWorldService");
            Name first = new Name()
            {
                firstName = "Lakhan",
                lastName  = "Bisht"
            };

            Console.WriteLine(client.SayHello(first));
            Console.ReadLine();
        }
Example #19
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine("Write your nickname: ");
            string name = Console.ReadLine();

            Console.WriteLine("Waiting for response from service...");
            Console.WriteLine(client.SayHelloWorld(name));
            client.Close();
            Console.ReadLine();
        }
Example #20
0
        public void GetMessageTest()
        {
            // Create return models for dependencies
            string expectedValue = "Hello World... sent from TEST";

            HelloWorldServiceClient client = new HelloWorldServiceClient();

            // Call the method to test
            var response = client.GetMessage("TEST");

            // Check value
            Assert.AreEqual(response, expectedValue);
        }
Example #21
0
        static void Main(string[] args)
        {
            var client = new HelloWorldServiceClient();

            Console.WriteLine(client.GetMessage("Tom Whitner"));

            try
            {
            } finally
            {
                return;
            }
        }
Example #22
0
        static void Main(string[] args)
        {
            var client = new HelloWorldServiceClient();
            Console.WriteLine(client.GetMessage("Tom Whitner"));

            try
            {

            } finally
            {
                return;
            }
        }
Example #23
0
        static void Main(string[] args)
        {
            var url = args[0];
            HelloWorldServiceClient client = new HelloWorldServiceClient("BasicHttpBinding_IHelloWorldService", url);
            var greeting = client.FindFirstGreetingUsingSqlAzure();
            Console.WriteLine("We got the greeting below via long path ConsoleApp <-> Azure WCF <-> Azure SQL:");
            Console.WriteLine(greeting);

            Console.WriteLine("Okay, lets check out the speed with 20 hits!");
            var start = DateTime.Now;
            for (int i = 0; i < 20; i++)
            {
                client.FindFirstGreetingUsingSqlAzure();
            }
            var duration = DateTime.Now - start;
            Console.WriteLine("On average, each hit is " + duration.TotalSeconds / 20 + " seconds.");
        }
Example #24
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine(client.Greet(new Person {
                Name = "Roger"
            }));
            client.Close();

            ProductServiceClient client2 = new ProductServiceClient();

            Console.WriteLine(client2.GetPrice(new Product {
                Name = "potato", Price = 0.55
            }));
            client2.Close();
            Console.ReadLine();
        }
Example #25
0
        //private static EventWaitHandle ewh;

        static void Main(string[] args)
        {
            //    Stopwatch sw = new Stopwatch();

            //    //using (var client = new HelloWorldServiceClient("ElsePipe"))
            //    //{
            //    //    client.Ping();
            //    //}



            //    sw.Start();
            //    //Console.WriteLine(client.GetMessage("Per Gustafsson"));
            //    //var client = new HelloWorldServiceClient("netTCPElseBinding");
            for (int i = 0; i < 30; i++)
            {
                var client = new HelloWorldServiceClient("ElseBasicHttp");

                Thread.Sleep(1000);
                client.Ping();
                Console.WriteLine("Pinged {0}", i);
            }
            //    sw.Stop();
            //    Console.WriteLine("Elapsed={0}", sw.Elapsed)

            //}

            //static void Main(string[] args)
            //{
            //    Stopwatch sw = new Stopwatch();

            //    ewh = new EventWaitHandle(false, EventResetMode.AutoReset, "elseReset");
            //    sw.Start();
            //    for (int i = 0; i < 100000; i++)
            //    {
            //        Thread.Sleep(1);
            //        ewh.Set();
            //    }
            //    sw.Stop();
            //    Console.WriteLine("Elapsed={0}", sw.Elapsed);


            //}
        }
Example #26
0
        private static void Main(string[] args)
        {
            using (HelloWorldServiceClient client = new HelloWorldServiceClient())
            {
                string result = client.SayHelloTo("Kilroy");
                Console.WriteLine(result);
                Debug.WriteLine(result);

                HelloWorldData data = new HelloWorldData
                {
                    SayHello = true,
                    Name     = "Mr. Chad"
                };
                HelloWorldData newData = client.GetHelloData(data);
                Console.WriteLine(newData.Name);
                Debug.WriteLine(newData.Name);

                Console.ReadKey();
            }
        }
Example #27
0
        private static void Main(string[] args)
        {
            using (HelloWorldServiceClient client = new HelloWorldServiceClient())
            {
                string result = client.SayHelloTo("Kilroy");
                Console.WriteLine(result);
                Debug.WriteLine(result);

                HelloWorldData data = new HelloWorldData
                                          {
                                              SayHello = true,
                                              Name = "Mr. Chad"
                                          };
                HelloWorldData newData = client.GetHelloData(data);
                Console.WriteLine(newData.Name);
                Debug.WriteLine(newData.Name);

                Console.ReadKey();
            }
        }
Example #28
0
 static void Main(string[] args)
 {
     HelloWorldServiceClient client = new HelloWorldServiceClient();
     Console.WriteLine(client.GetMessage("Mike Liu"));
 }
        void InitializeHelloWorldServiceClient()
        {
            BasicHttpBinding binding = CreateBasicHttpBinding();

            _client = new HelloWorldServiceClient(binding, Endpoint);
        }
Example #30
0
        static void Main(string[] args)
        {
            HelloWorldServiceClient client = new HelloWorldServiceClient();

            Console.WriteLine(client.GetMessage("Cheng Hong Low"));
        }
Example #31
0
        public async Task <ActionResult> Register([Bind(Exclude = "ProfilePic")] RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                byte[] imageData = null;
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase poImgFile = Request.Files["ProfilePic"];

                    using (var binary = new BinaryReader(poImgFile.InputStream))
                    {
                        imageData = binary.ReadBytes(poImgFile.ContentLength);
                    }
                }

                model.ProfilePic = imageData;

                var user = new ApplicationUser {
                    UserName   = model.Email,
                    Email      = model.Email,
                    Name       = model.Name,
                    Dob        = model.Dob,
                    CarType    = model.CarType,
                    IdProof    = model.IdProof,
                    Address    = model.Address,
                    PhoneNum   = model.PhoneNum,
                    ProfilePic = model.ProfilePic
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //Sending Welcome Mail for new user registration
                    string webServiceMsg = "";
                    try
                    {
                        String subject = "Welcome " + model.Name + " !!!!!!";
                        String content = "Hi " + model.Name + ",\n\tWe hope you are having an amazing day!\n\nTo help you make the most of your time on wheelshare, we would like to remind you of our core features:\n1.Creating a pool\n2.Making a pool request\n3.Creating a private group.\nThanks for Joining and Happy sharing!\nThe WheelShare Team";
                        webServiceMsg += model.Email + "#" + subject + "#" + content;
                        HelloWorldServiceClient client = new HelloWorldServiceClient();
                        client.GetMessage(webServiceMsg);
                    }
                    catch (Exception e)
                    {
                        //do nothing
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #32
0
        static void Main(string[] args)
        {
            var client = HelloWorldServiceClient.GetInstance("http://localhost:13337");


            //var response = client.Hello(new HelloRequestType { Name = "World" });

            //if (response.ResponseStatus.Ack == AckCodeType.Success)
            //{
            //    Console.WriteLine("Response : {0}", response.Result);
            //}
            //else
            //{
            //    Console.WriteLine("Error : {0}", response.ResponseStatus.Errors[0].Message);
            //}

            ////新加的方法,返回服务器当前的时间
            //int i = 1;
            //while (i++ < 20)
            //{
            //    System.Threading.Thread.Sleep(1000);

            //    var latestResponse = client.GetLatestTime(new GetLatestTimeType());
            //    if (latestResponse.ResponseStatus.Ack == AckCodeType.Success)
            //    {
            //        Console.WriteLine(latestResponse.Result);
            //    }
            //}

            ////工具生成的方法,计算数字之和
            //int n1 = 10; int n2 = 5;
            //var addResponse = client.AddNumber(new AddNumberRequestType { num1 = n1, num2 = n2 });

            //Console.WriteLine(addResponse.Result);

            //int n1 = 20;
            //PersonModel p = new PersonModel() { Name = "yrs", Age = 30 };
            //var personResponse = client.AddPersonAge(new AddPersonAgeRequestType { num1 = n1, Person = p });

            //Console.WriteLine(personResponse.IsPersonOlder);
            //Console.WriteLine(personResponse.Person.Name);

            //int n2 = 31;
            //PersonModel p2 = new PersonModel() { Name = "yrs", Age = 30 };
            //var personResponse2 = client.AddPersonAge(new AddPersonAgeRequestType { num1 = n2, Person = p2 });

            //Console.WriteLine(personResponse2.IsPersonOlder);
            //Console.WriteLine(personResponse2.Person.Name);

            List <PersonModel> lstPerson = new List <PersonModel>();

            for (int i = 0; i < 4; i++)
            {
                PersonModel p = new PersonModel();
                p.Age  = 25 + i;
                p.Name = "lyn" + i * 2;
                lstPerson.Add(p);
            }

            var response4 = client.SavePersonList(new SavePersonListRequestType {
                PersonList = lstPerson
            });

            Console.WriteLine(response4.AvgAge);

            Console.ReadKey();
        }
Example #33
0
        private void button1_Click(object sender, EventArgs e)
        {
            HelloWorldServiceClient x = new HelloWorldServiceClient();

            MessageBox.Show(x.SayHello("Yashwant"));
        }
        private void InitializeHelloWorldServiceClient()
        {
            BasicHttpBinding binding = CreateBasicHttp();

            _client = new HelloWorldServiceClient(binding, EndPoint);
            _client.SayHelloToCompleted += ClientOnSayHelloToCompleted;
            _client.GetHelloDataCompleted += ClientOnGetHelloDataCompleted;

            getHelloWorldDataButton.TouchUpInside += GetHelloWorldDataButtonTouchUpInside;
            sayHelloWorldButton.TouchUpInside += SayHelloWorldDataButtonTouchUpInside;
        }