static AccessControl.fileTransferInfo Upload(String sessionId, EDMAccessControlService access, String fileToUpload, String fileExtension)
        {
            var transferInfo = access.createTemporaryFile(sessionId, "name", fileExtension, true);
            ManualResetEvent me = new ManualResetEvent(false);

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(transferInfo.uploadOrDownloadUrl + sessionId);
            httpWebRequest.Method = "POST";
            httpWebRequest.KeepAlive = true;
            httpWebRequest.ContentType = "multipart/form-data";
            httpWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;

            FileStream fileStream = new FileStream(fileToUpload, FileMode.Open, FileAccess.Read);

            httpWebRequest.ContentLength = fileStream.Length;
            httpWebRequest.AllowWriteStreamBuffering = false;
            // To prevent timeout error async RequestStream getting is needed
            httpWebRequest.BeginGetRequestStream((getRequestResult) =>
            {
                using (Stream requestStream = httpWebRequest.EndGetRequestStream(getRequestResult))
                {
                    byte[] buffer = new byte[1024];
                    int bytesRead = 0;
                    long totalLength = httpWebRequest.ContentLength;
                    // Loop through whole file uploading parts in a stream.
                    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        requestStream.Write(buffer, 0, bytesRead);
                        requestStream.Flush();
                    }
                    fileStream.Close();
                }

                httpWebRequest.BeginGetResponse((getResponseResult) =>
                {
                    var response = httpWebRequest.EndGetResponse(getResponseResult);
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        string responseText = reader.ReadToEnd();
                    }
                    response.Close();

                    me.Set();
                }, null);

            }, null);

            me.WaitOne();
            return transferInfo;
        }
        /*=======================================================================================*/
        /*=======================================================================================*/
        static void Main(string[] args)
        {
            try
            {
                sessionId = null;
                arguments = new Arguments(args);
                string command = arguments["command"];
                string repository = arguments["repo"];
                string model = arguments["model"];
                string user = arguments["login"];
                string password = arguments["pass"];
                string keystoneSessionId = arguments["keystoneSessionId"];
                string version = "";

                access = new EDMAccessControlService();
                access.Url = SERVER_URL + "/AccessControl?option=LITERAL_ENCODING";
                service = new SIMDM_MASTER_WSDLService();           // Use this service for operations that are dependant on repository and model in the URL
                modelNeutralSrv = new SIMDM_MASTER_WSDLService();   // Use this service for model neutral operations or operations that have model id as parameter
                configSrv = new SimDM_config_supportService();

                service.Url = SERVER_URL + String.Format(MODEL_SERVICE_PARAMS_TEMPLATE, repository, model);
                configSrv.Url = SERVER_URL + CONFIG_URL;
                modelNeutralSrv.Url = SERVER_URL + MASTER_URL;
                //service.Url = "http://api.eu-cloudflow.eu/jotne/EDMWS/earlybinding/options_2097152/SimDM_system/user_management/QEX/SIMDM_MASTER_WSDL";

                if (command != null && (command.Equals("new_node_version") || command.Equals("download_folder") || command.Equals("change_password") || command.Equals("delete_user") || command.Equals("create_user") || command.Equals("model_downloadFile") || command.Equals("model_uploadFile") || command.Equals("plm_node_list") || command.Equals("plm_set_property_value") || command.Equals("plm_define_property") || command.Equals("node_file_list") || command.Equals("move_file") || command.Equals("upload_file") || command.Equals("show_types") || command.Equals("create_pbs") || command.Equals("node_query") || command.Equals("define_properties")))
                {
                    if (keystoneSessionId == null)
                    {
                        sessionId = access.login(user, "sdai-group", password);
                        AccessControl.fileTransferInfo remoteFile = access.createTemporaryFile(sessionId, "myFile", ".txt", true);
                        version = configSrv.system_get_EDM_server_version(sessionId);
                    } else {
                        sessionId = keystoneSessionId;
                    }
                    if (command.Equals("upload_file"))
                    {
                        uploadFile();
                    }
                    else if (command.Equals("create_pbs"))
                    {
                        createProductStructure();
                    }
                    else if (command.Equals("model_uploadFile"))
                    {
                        model_uploadFile();
                    }
                    else if (command.Equals("model_downloadFile"))
                    {
                        model_downloadFile();
                    }
                    else if (command.Equals("plm_define_property"))
                    {
                        plm_define_property();
                    }
                    else if (command.Equals("node_query"))
                    {
                        executeNodeQuery();
                    }
                    else if (command.Equals("plm_set_property_value"))
                    {
                        plm_set_property_value();
                    }
                    else if (command.Equals("plm_node_list"))
                    {
                        plm_node_list();
                    }
                    else if (command.Equals("node_file_list"))
                    {
                        node_file_list();
                    }
                    else if (command.Equals("define_properties"))
                    {
                        define_properties();
                    }
                    else if (command.Equals("show_types"))
                    {
                        show_types();
                    }
                    else if (command.Equals("move_file"))
                    {
                        move_file();
                    }
                    else if (command.Equals("create_user"))
                    {
                        create_user();
                    }
                    else if (command.Equals("change_password"))
                    {
                        change_password();
                    }
                    else if (command.Equals("delete_user"))
                    {
                        delete_user();
                    }
                    else if (command.Equals("download_folder"))
                    {
                        download_folder();
                    }
                    else if (command.Equals("new_node_version"))
                    {
                        new_node_version();
                    }
                    Console.Out.WriteLine("Operation completed successfully.");

                }
                else
                {
                    Console.Out.WriteLine("Operation completed successfully.");
                }
            } catch (Exception ex) {

                Console.Out.WriteLine("Following error was detected:");

                Console.Out.WriteLine(ex.Message);
            }
            if (sessionId != null)
                access.logout(sessionId);
            Console.Out.WriteLine("Press any key to finish.");
            Console.In.Peek();
        }