Exemplo n.º 1
0
        public void TestExecuteWithOutPassword()
        {
            IDemo demo = XmlRpcProxyFactory.Create <IDemo>();

            demo.WebAddress = new Uri("http://localhost:8084/TestRPC/GatewayOffice");
            String res = demo.Add(4, 3.2, "", DateTime.Now, true);

            Assert.IsNotNull(res);
        }
Exemplo n.º 2
0
        public void TestExecute()
        {
            IDemo demo = XmlRpcProxyFactory.Create <IDemo>();

            demo.WebAddress  = new Uri("http://localhost:8084/TestRPC/GatewayOffice");
            demo.Credentials = new System.Net.NetworkCredential("victor", "Lorenzana");
            String res = demo.Add(4, 3.2, "", DateTime.Now, true);

            Assert.IsFalse(String.IsNullOrEmpty(res));
        }
Exemplo n.º 3
0
        public void TestExecuteWithInvalidMethod()
        {
            IDemo demo = XmlRpcProxyFactory.Create <IDemo>();

            demo.WebAddress  = new Uri("http://localhost:8084/TestRPC/GatewayOffice");
            demo.Credentials = new System.Net.NetworkCredential("victor", "Lorenzana");
            String res = demo.Add(4, 3.2, "", DateTime.Now, 1);

            Assert.IsNotNull(res);
        }
Exemplo n.º 4
0
        public void TestExecuteWithBadPath()
        {
            try
            {
                IDemo demo = XmlRpcProxyFactory.Create <IDemo>();

                demo.WebAddress  = new Uri("http://localhost:8084/TestRPC/GatewayOffice2");
                demo.Credentials = new System.Net.NetworkCredential("victor", "Lorenzana");
                String res = demo.Add(4, 3.2, "", DateTime.Now, true);
                Assert.IsNotNull(res);
            }
            catch (UriFormatException e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes the connection to the remote Xml - Rpc wiki server.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param>
 private void BeginConnectToWiki(object sender, DoWorkEventArgs e)
 {
     this.clientProxy = XmlRpcProxyFactory.CreateSecureCommunicationProxy(new Uri(this.activeAccount.WikiUrlRaw), this.activeAccount.LoginName, this.activeAccount.Password);
     clientProxy.ListServerMethods();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Mains the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += DokuWikiClientConsoleApplication.OnUnhandledException;
            XmlConfigurator.Configure();
            IDokuWikiProvider communicationClient;
            IDokuWikiClient   dokuWikiClient = DokuWikiClientFactory.CreateDokuWikiClient();

            Uri    uriToWiki;
            string password = string.Empty;
            string username = string.Empty;

            Console.WriteLine("Connecting to wiki.");
            if (args.Length > 0 && !String.IsNullOrEmpty(args[0]))
            {
                UriBuilder uriConstructor = new UriBuilder(args[0]);

                if (!uriConstructor.Uri.IsWellFormedOriginalString())
                {
                    if (uriConstructor.Scheme != "http" || uriConstructor.Scheme != "https")
                    {
                        uriConstructor.Scheme = "http";
                    }
                    uriConstructor.Host = args[0];
                }

                if (uriConstructor.Path == "/")
                {
                    uriConstructor.Path = "/lib/exe/xmlrpc.php";
                }

                uriToWiki = uriConstructor.Uri;

                if (args.Length == 3 && !String.IsNullOrEmpty(args[1]) && !String.IsNullOrEmpty(args[2]))
                {
                    password            = args[2];
                    username            = args[1];
                    communicationClient = XmlRpcProxyFactory.CreateSecureCommunicationProxy(uriToWiki, username, password);
                }
                else
                {
                    communicationClient = XmlRpcProxyFactory.CreateCommunicationProxy(uriToWiki);
                }
            }
            else
            {
                Console.WriteLine("Usage: DokuWikiClientConsoleApplication <URI of wiki> [username] [password]");
                Console.ReadLine();
                return;
            }

            try
            {
                Console.WriteLine("----------------------------------------------------");
                Console.WriteLine("Listing server capabilites.");

                Capability serverCapability = communicationClient.LoadServerCapabilites();
                if (serverCapability.XmlRpcSpecification != null)
                {
                    Console.WriteLine("Xml-Rpc Version: {0}", serverCapability.XmlRpcSpecification.SpecificationVersion);
                }
                if (serverCapability.IntrospectionSpecification != null)
                {
                    Console.WriteLine("Introspection Version: {0}", serverCapability.IntrospectionSpecification.SpecificationVersion);
                }
                if (serverCapability.MultiCallSpecification != null)
                {
                    Console.WriteLine("Multicall Version: {0}", serverCapability.MultiCallSpecification.SpecificationVersion);
                }
                if (serverCapability.FaultCodesSpecification != null)
                {
                    Console.WriteLine("Fault codes Version: {0}", serverCapability.FaultCodesSpecification.SpecificationVersion);
                }

                Console.WriteLine("----------------------------------------------------");

                Console.WriteLine("Listing server methods.");
                foreach (String serverMethodName in communicationClient.ListServerMethods())
                {
                    Console.WriteLine("Method name: {0}", serverMethodName);
                }
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
                Console.WriteLine("Proceeding ....");
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("Communication error. Cause: {0}", ce.Message);
            }

            Console.WriteLine("----------------------------------------------------");

            StringBuilder menuString = new StringBuilder();

            menuString.AppendLine("Menu: ");

            foreach (CommandName enumValue in Enum.GetValues(typeof(CommandName)))
            {
                menuString.AppendLine(((int)enumValue) + " := " + enumValue.DescriptionOf());
            }
            menuString.AppendLine();

            do
            {
                Console.Write(menuString.ToString());
                string      input        = Console.ReadLine();
                CommandName commandValue = (CommandName)Enum.Parse(typeof(CommandName), input);

                if (commandValue == CommandName.ExitApplication)
                {
                    exitLoop = true;
                }
                else
                {
                    try
                    {
                        CommandFactory.CreateCommand(commandValue, communicationClient, dokuWikiClient).Execute();
                    }
                    catch (NotImplementedException nie)
                    {
                        Console.WriteLine(nie.Message);
                    }
                }

                Console.WriteLine("----------------------------------------------------");
            }while (!exitLoop);
        }