Inheritance: System.Web.Services.WebService
Beispiel #1
0
        private async Task <string> GetDataAsync()
        {
            // a very simple async method
            var result = await MyWebService.GetDataAsync();

            return(result.ToString());
        }
    public static MyWebService GetMyWebService()
    {
        MyWebService clientProxy = new MyWebService();

        clientProxy.Url = ConfigurationSettings.AppSettings["webServiceUrl"];
        return(clientProxy);
    }
Beispiel #3
0
        private async Task <string> GetDataAsync()
        {
            // простой вызов асинхронного метода
            var result = await MyWebService.GetDataAsync();

            return(result.ToString());
        }
Beispiel #4
0
 /// <summary>
 /// Wakes up any sleeping processes, and MyWebService chain
 /// </summary>
 /// <returns></returns>
 public virtual async Task WakeServicesAsync()
 {
     if (MyWebService.ToString() == TypeExtension.DefaultString)
     {
         HttpRequestGetString Request = new HttpRequestGetString(MyWebService.ToString());
         Request.ThrowExceptionWithEmptyReponse = false;
         await Request.SendAsync();
     }
 }
Beispiel #5
0
        public void Shoud_return_3_when_N_isEqual_4()
        {
            int    n        = 4;
            double expected = 3;

            MyWebService ws = new MyWebService();

            double res = ws.Fibonacci(n);

            Assert.AreEqual(expected, res);
        }
Beispiel #6
0
        public void Shoud_return_complexJson()
        {
            string xml      = "<TRANS><HPAY><ID>103</ID><STATUS>3</STATUS><EXTRA><IS3DS>0</IS3DS><AUTH>031183</AUTH></EXTRA><INT_MSG/><MLABEL>501767XXXXXX6700</MLABEL><MTOKEN>project01</MTOKEN></HPAY></TRANS>";
            string expected = "{\"TRANS\":{\"HPAY\":{\"ID\":\"103\",\"STATUS\":\"3\",\"EXTRA\":{\"IS3DS\":\"0\",\"AUTH\":\"031183\"},\"INT_MSG\":null,\"MLABEL\":\"501767XXXXXX6700\",\"MTOKEN\":\"project01\"}}}";

            MyWebService ws = new MyWebService();

            string json = ws.XmlToJson(xml, false);

            Assert.AreEqual(expected, json);
        }
Beispiel #7
0
        public void Shoud_return_Bad_Xml_formatL()
        {
            string xml      = "<foo>hello</bar>";
            string expected = "Bad Xml format";

            MyWebService ws = new MyWebService();

            string json = ws.XmlToJson(xml, false);

            Assert.AreEqual(expected, json);
        }
Beispiel #8
0
        public void Shoud_return_simpleJson()
        {
            string xml      = @"<foo>bar</foo>";
            string expected = "{\"foo\":\"bar\"}";

            MyWebService ws = new MyWebService();

            string json = ws.XmlToJson(xml, false);

            Assert.AreEqual(expected, json);
        }
Beispiel #9
0
 /// <summary>
 /// Wakes up any sleeping processes, and MyWebService chain
 /// </summary>
 /// <returns></returns>
 public virtual async Task WakeServicesAsync()
 {
     if (MyWebService.ToString() == Defaults.String)
     {
         var Request = new HttpRequestGetString(MyWebService.ToString())
         {
             ThrowExceptionWithEmptyReponse = false
         };
         await Request.SendAsync();
     }
 }
Beispiel #10
0
        public void Shoud_return_minus1_when_N_isEqual_0()
        {
            int    n        = 0;
            double expected = -1;

            MyWebService ws = new MyWebService();

            double res = ws.Fibonacci(n);

            Assert.AreEqual(expected, res);
        }
Beispiel #11
0
        private void fillBtn_Click(object sender, EventArgs e)
        {
            var service = new MyWebService();

            // sync load
            //var countries = service.GetCountries();
            //countryList.DataSource = countries;

            // async
            service.GetCountriesCompleted += service_GetCountriesCompleted;
            service.GetCountriesAsync();
        }
Beispiel #12
0
        private async Task StartServer()
        {
            var server = new MyWebService();

            await ThreadPool.RunAsync(operation =>
            {
                //  MyWebserver.Start();
                //rasp.message = server.query;
                //textBox.Text = server.query;
                 server.Listenear();
                // SetTextBox();
            });
        }
Beispiel #13
0
        public static TResult Run <TResult>(MySession session, MyWebService service, ICommand <TResult> command)
        {
            //Reconnect
            service.Connect(session.Site);
            service.Login(session.User, session.Pass);

            //Execute the webserivce call
            TResult result = command.Execute();

            //Disconnect
            service.Disconnect();

            return(result);
        }
Beispiel #14
0
        public static TResult Run <TResult>(MySession session, MyWebService service, Func <TResult> function)
        {
            //Reconnect
            service.Connect(session.Site);
            service.Login(session.User, session.Pass);

            //Execute the webserivce call
            TResult result = function.Invoke();

            //Disconnect
            service.Disconnect();

            return(result);
        }
Beispiel #15
0
        public void UsingCommands()
        {
            //Save user/pass in session
            MySession session = new MySession {
                User = "******", Pass = "******", Site = "541"
            };

            //Get webservice from session
            MyWebService service = new MyWebService("www.telerik.com");

            //New up a search patient command
            var searchCommand = new SearchPatientCommand(service, "Z0001");

            //Use the command runner to deal with the ceremony of connect/login/disconnect
            IEnumerable <PatientTO> patients = CommandRunner.Run(session, service, searchCommand);
        }
Beispiel #16
0
    public static void Main()
    {
        MyWebService ws = new MyWebService();

        try {
            MyHeader customHeader = new MyHeader();
            customHeader.MyValue        = "Header Value for MyValue";
            customHeader.MustUnderstand = true;
            ws.myHeader = customHeader;

            int results = ws.MyWebMethod(3, 5);
        }
        catch (Exception e) {
            Console.WriteLine("Exception: {0}", e.ToString());
        }
    }
    public static bool MyMethod(this MyWebService svc, params string[] a)
    {
        //The code below assumes you can pass in null if the parameter
        //is not specified. If you have to pass in string.Empty or something
        //similar then initialize all elements in the p array before doing
        //the CopyTo
        if (a.Length > 10)
        {
            throw new ArgumentException("Cannot pass more than 10 parameters.");
        }
        var p = new string[10];

        a.CopyTo(p, 0);
        return(svc.MyMethod(p[0], p[1], p[2], p[3], p[4], p[5],
                            p[6], p[7], p[8], p[9]));
    }
Beispiel #18
0
    public static void Main()
    {
        MyWebService ws = new MyWebService();

        try {
            MyHeader customHeader = new MyHeader();
            customHeader.MyValue = "Header Value for MyValue";
            customHeader.Actor   = "http://www.contoso.com/MySoapHeaderHandler";
            ws.myHeader          = customHeader;

            int results = ws.MyWebMethod(3, 5);
        }
        catch (Exception e) {
            Console.WriteLine("Exception: {0}", e.ToString());
        }
    }
Beispiel #19
0
        public void UsingDelegates()
        {
            //Save user/pass in session
            MySession session = new MySession {
                User = "******", Pass = "******", Site = "541"
            };

            //Get webservice from session
            MyWebService service = new MyWebService("www.telerik.com");

            Func <IEnumerable <PatientTO> > searchAction = () =>
            {
                return(service.Search("Z0001"));
            };

            IEnumerable <PatientTO> patients = CommandRunner.Run(session, service, searchAction);
        }
Beispiel #20
0
    public void CallService()
    {
        MyWebService client = new MyWebService();

        client.DoSomething();
    }
    public void CallSomeWebMethod()
    {
        var someService = new MyWebService();

        someService.SomeWebMethod();
    }
    public string DoSomething()
    {
        MyWebService client = new MyWebService();

        client.DoSomething();
    }
Beispiel #23
0
 public SearchPatientCommand(MyWebService service, string criteria)
 {
     this._service  = service;
     this._criteria = criteria;
 }