Архив за месяц: Ноябрь 2014

b2b mts пример c# soap

Через стандартный soap ПЕРЕДАЧА ТОКЕНА с секюрити в битуби НЕ РАБОТАЕТ! извращаемся через известное место…

 
        public ActionResult Test()
        {
            var token = "";
 
            var url = "https://b2b.locator.ru/mts/ws/me_b2b_54/security.asmx?wsdl";
            var xml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>    
                   <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
                   xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
                   xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
                    <soap:Body>
                    <Login xmlns=""http://locator.ru/LBS"">
                    <login>MyLogin</login>
                    <password>P@SS</password>
                    </Login>
                    </soap:Body>
                   </soap:Envelope>";
 
            var request = (HttpWebRequest)System.Net.WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "text/xml; charset=utf-8";
            request.Headers.Add("SOAPAction", "http://locator.ru/LBS/Login");
 
            using (var writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII))
            {
                writer.Write(xml);
            }
 
            using (var response = (HttpWebResponse)request.GetResponse())
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var res = new ContentResult(); ;
 
 
                var doc = XDocument.Load(reader);
                token = doc.Descendants().Where(la=>la.Name.LocalName == "Token").First().Value;
               
            }
 
 
 
            var urlGetSubscribers = "https://b2b.locator.ru/mts/ws/me_b2b_54/b2b_api.asmx?wsdl";
            var xmlGetSubscribers =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                   <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
                   xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
                   xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
                    <soap:Header>
                    <SecurityHeader xmlns=""http://locator.ru/LBS"">
                    <SessionToken>"+token+@"</SessionToken>
                    </SecurityHeader>
                    </soap:Header>
                    <soap:Body>
                               <GetSubscribers xmlns=""http://locator.ru/LBS"" />
                    </soap:Body>
                   </soap:Envelope>
                   ";
 
            request = (HttpWebRequest)System.Net.WebRequest.Create(urlGetSubscribers);
            request.Method = "POST";
            request.ContentType = "text/xml; charset=utf-8";
            request.Headers.Add("SOAPAction", "http://locator.ru/LBS/GetSubscribers");
 
            using (var writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII))
            {
                writer.Write(xmlGetSubscribers);
            }
 
            using (var response = (HttpWebResponse)request.GetResponse())
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var res = new ContentResult(); ;
 
                return this.Content(reader.ReadToEnd(), "text/xml");
            }
 
 
 
 
            return new EmptyResult();
        }