Пример #1
0
        private CustAddressCollection GetShippingAddress(string soldToNumber, string salesOrg)
        {
            // Kunnr SoldToNumber
            // VKorg Sales Organisation

            string          requestURL = string.Format(sapShipToAddressURL, soldToNumber, salesOrg);
            HttpWebRequest  req        = (HttpWebRequest)WebRequest.Create(requestURL);
            HttpWebResponse resp; // No Use

            req.Credentials = new NetworkCredential(sapUserName, sapPassword);
            req.Method      = "GET";
            req.Headers.Add("X-CSRF-Token", "Fetch");
            req.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            cookieJar             = new CookieContainer();
            req.CookieContainer   = cookieJar;
            CustAddressCollection collection = null;

            using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var rawJson = new StreamReader(response.GetResponseStream()).ReadToEnd();
                    collection = JsonConvert.DeserializeObject <CustAddressCollection>(rawJson);

                    // To combine the Zero's into the Shipping Number to make as 10 digit number.
                    // var shippingAddr = PadLeft(10, '0');

                    csrfToken     = response.Headers.GetValues("X-CSRF-TOKEN").FirstOrDefault();
                    setCookie     = response.Headers.Get("Set-Cookie");
                    cookiestopass = response.Cookies;
                }
            }
            return(collection);
        }
Пример #2
0
        public List <ShipTo> GetShippingAddressFromSAP(string soldToNumber, string salesOrg)
        {
            List <ShipTo> shipToList = new List <ShipTo>();

            try
            {
                CustAddressCollection addressCollection = GetShippingAddress(soldToNumber, salesOrg);

                // TODO: Map the SAP address to entity
                shipToList.Add(new ShipTo()
                {
                });
            }
            catch (Exception)
            {
                throw;
            }

            return(shipToList);
        }