Esempio n. 1
0
        public void T_ClientProxyByGW()
        {
            var proxy = SP.GetRequiredService <IApiProxy <IHelloWorldService> >();

            proxy.ApiVersion = "1";
            proxy.RegisterChtSwaggerDoc(useApiGateway: true);
            IHelloWorldService helloSvc = proxy.Svc;
            string             id1      = "*abc*";
            int      id2 = 99;
            DateTime id3 = DateTime.Today;

            var postrlt = helloSvc.HelloPost("CCC", "DDD");

            print($"API={nameof(IHelloWorldService.HelloPost)} result={postrlt}");

            var getrlt = proxy.Svc.HelloGet("EEE", "FFF");

            print($"API={nameof(IHelloWorldService.HelloGet)} result={getrlt}");
        }
        private void CallApi(IApiProxy <IHelloWorldService> proxy)
        {
            IHelloWorldService helloSvc = proxy.Svc;
            string             id1      = "*abc*";
            int      id2 = 99;
            DateTime id3 = DateTime.Today;
            var      id4 = new HelloInput()
            {
                UserName = "******", Date = DateTime.Today
            };
            var rlt = helloSvc.Hello(id1, id2, id3, id4);

            print($"API={nameof(IHelloWorldService.Hello)} User={rlt.UserName}\nDate={rlt.Date}\n{rlt.Summary}");

            var postrlt = helloSvc.HelloPost("CCC", "DDD");

            print($"API={nameof(IHelloWorldService.HelloPost)} result={postrlt}");

            var getrlt = proxy.Svc.HelloGet("EEE", "FFF");

            print($"API={nameof(IHelloWorldService.HelloGet)} result={getrlt}");
        }