public List <string> getList()
        {
            GetListRequest req = new GetListRequest();

            req.user       = new User();
            req.user.login = conf.Login;
            req.user.pass  = Utils.GetMD5String(conf.Soap_pass);
            GetListResponse resp = (GetListResponse)Soap.GetList <GetListResponse>(req);

            if (resp.errorCode != 0)
            {
                throw new Exception(resp.errorMessage);
            }
            return(resp.list);
        }
Beispiel #2
0
        public Program(String[] args)
        {
            Program.conf = DFSHelper.GetAppConfiguration("configuration.xml");
            Logger.loadConfig();
            controller = new Controller();
            switch (args[0])
            {
            case "-allcerts":
                // testing crypto etc.
                testCrypto();
                break;

            case "-infocert":
                ExCert cert = null;
                try
                {
                    cert = controller.GetExCertificate(args[1]);
                    Console.WriteLine("certificate info:");
                    Console.WriteLine(cert.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                break;

            case "-testcert":
                String sign       = null;
                String base64data = Utils.Base64DecodeToString(Encoding.GetEncoding("UTF-8").GetBytes("somedata"), "UTF-8");
                try
                {
                    sign = controller.Sign(args[1], base64data);
                    if (sign != null)
                    {
                        Console.WriteLine("signing O.K.");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                break;

            case "-testrestFULLDEBUG":
                AuthorizeRequest debugReq = new AuthorizeRequest(conf.Login, conf.Api_pass);
                Console.WriteLine("request body:");
                Console.WriteLine(Utils.ToJson(debugReq));
                AuthorizeResponse debugResp = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", debugReq);
                Console.WriteLine("response body:");
                Console.WriteLine(Utils.ToJson(debugResp));
                if (debugResp != null)
                {
                    Console.WriteLine("rest O.K.");
                }
                break;

            case "-testrest":
                AuthorizeResponse response = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", new AuthorizeRequest(conf.Login, conf.Api_pass));
                if (response != null)
                {
                    Console.WriteLine("rest O.K.");
                }
                break;

            case "-testsoap":
                GetListRequest req = new GetListRequest();
                req.user       = new User();
                req.user.login = conf.Login;
                req.user.pass  = Utils.GetMD5String(conf.Soap_pass);
                GetListResponse resp = (GetListResponse)Soap.GetList <GetListResponse>(req);
                if (resp != null)
                {
                    Console.WriteLine("soap O.K.");
                }
                break;
            }
        }