Ejemplo n.º 1
0
        public void TestReadXmlUri()
        {
            ObixResult <XElement> lobby;

            TestConnect();

            Assert.IsNotNull(client, "Client is not initialized.");
            Assert.IsTrue(client.IsConnected, "Client is not connected.");

            lobby = client.ReadUriXml(client.LobbyUri);
            Assert.IsNotNull(lobby, "ReadUriXml failed, lobby is null.");
            Assert.IsTrue(lobby.ResultSucceeded, "ReadUriXml failed with result " + lobby.ToString());

            Assert.IsFalse(lobby.Result.IsNullOrNullContract(), "object returned is null or an obix:Null contract.");

            Console.Out.WriteLine("Lobby output:");
            Console.Out.WriteLine(lobby.ToString());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string Server   = "<server>";
            string Username = "******";
            string Password = "******";

            using (var obixClient = new XmlObixClient(new Uri(Server)))
            {
                obixClient.WebClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue
                                                                           (
                    "Basic",
                    Convert.ToBase64String(
                        Encoding.ASCII.GetBytes(
                            string.Format("{0}:{1}", Username, Password))));

                var connectResult = obixClient.Connect();
                if (connectResult != ObixResult.kObixClientSuccess)
                {
                    throw new Exception("Connection to server failed: " +
                                        ObixResult.Message(connectResult));
                }

                var readResult = obixClient.ReadUriXml(new Uri(Server + "histories/"));
                if (readResult.ResultSucceeded)
                {
                    var element = readResult.Result;
                    System.Console.WriteLine(element.ToString());
                }
                else
                {
                    throw new Exception("Error reading from server: " + ObixResult.Message(readResult));
                }

                System.Console.ReadKey();
            }
        }