Ejemplo n.º 1
0
        public Session GetSessionForAccount(Account account)
        {
            RestClient client = new RestClient(BaseUrl);

            client.UserAgent = "eboks/35 CFNetwork/672.1.15 Darwin/14.0.0";

            var request = new RestRequest("/session", Method.PUT);

            request.RequestFormat = DataFormat.Xml;

            Session session = new Session();

            session.DeviceId = Guid.NewGuid().ToString();

            request.AddHeader("X-EBOKS-AUTHENTICATE", GetAuthHeader(account, session));
            //request.AddHeader("Content-Type", "application/xml");
            request.AddHeader("Accept", "*/*");

            var logon = new Logon();

            logon.App           = new App();
            logon.App.Version   = "1.4.1";
            logon.App.OS        = "iOS";
            logon.App.OSVersion = "9.0.0";
            logon.App.Device    = "iPhone";

            logon.User              = new User();
            logon.User.Identity     = account.UserId;
            logon.User.IdentityType = "P";
            logon.User.Nationality  = "DK";
            logon.User.Pincode      = account.Password;

            //request.AddBody(logon, "urn:eboks:mobile:1.0.0");

            /*
             * string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + Environment.NewLine +
             * "<register-request">" + Environment.NewLine +
             * "    <name=\"someName\"/>" + Environment.NewLine +
             * "</register-request>");
             *
             * request.AddParameter("text/xml", registerSinkRequest, ParameterType.RequestBody);
             */

            string xml;

            var serializer = new XmlSerializer(logon.GetType(), "urn:eboks:mobile:1.0.0");

            var ns = new XmlSerializerNamespaces();

            ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            ns.Add("xsd", "http://www.w3.org/2001/XMLSchema");

            using (StringWriter textWriter = new Utf8StringWriter())
            {
                serializer.Serialize(textWriter, logon, ns);
                xml = textWriter.ToString();
            }



            IRestResponse response;

            response = client.Execute(request);

            return(null);
        }
Ejemplo n.º 2
0
        public Session GetSessionForAccount(Account account)
        {
            RestClient client = new RestClient(BaseUrl);
            client.UserAgent = "eboks/35 CFNetwork/672.1.15 Darwin/14.0.0";

            var request = new RestRequest("/session", Method.PUT);
            request.RequestFormat = DataFormat.Xml;

            Session session = new Session();
            session.DeviceId = Guid.NewGuid().ToString();

            request.AddHeader("X-EBOKS-AUTHENTICATE", GetAuthHeader(account, session));
            //request.AddHeader("Content-Type", "application/xml");
            request.AddHeader("Accept", "*/*");

            var logon = new Logon();
            logon.App = new App();
            logon.App.Version = "1.4.1";
            logon.App.OS = "iOS";
            logon.App.OSVersion = "9.0.0";
            logon.App.Device = "iPhone";

            logon.User = new User();
            logon.User.Identity = account.UserId;
            logon.User.IdentityType = "P";
            logon.User.Nationality = "DK";
            logon.User.Pincode = account.Password;

            //request.AddBody(logon, "urn:eboks:mobile:1.0.0");

            /*
string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + Environment.NewLine +
             "<register-request">" + Environment.NewLine +
             "    <name=\"someName\"/>" + Environment.NewLine +
             "</register-request>");

request.AddParameter("text/xml", registerSinkRequest, ParameterType.RequestBody);
            */

            string xml;

            var serializer = new XmlSerializer(logon.GetType(), "urn:eboks:mobile:1.0.0");

            var ns = new XmlSerializerNamespaces();
            ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            ns.Add("xsd", "http://www.w3.org/2001/XMLSchema");

            using(StringWriter textWriter = new Utf8StringWriter())
            {
                serializer.Serialize(textWriter, logon, ns);
                xml = textWriter.ToString();
            }




            IRestResponse response;

            response = client.Execute(request);

            return null;
        }