public async void postXMLData1() { string uri = "http://111.93.131.112/biws/buswebservice"; // some xml string Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute); //string stringXml = "<soapenv:Envelope xmlns:com=\"com.busindia.webservices\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><com:GetPlaceList xmls =\"\"><arg0><franchUserID>?</franchUserID><password>biteam</password><userID>474</userID><userKey>?</userKey><userName>[email protected]</userName><userRole>?</userRole><userStatus>?</userStatus><userType>101</userType></arg0></com:GetPlaceList></soapenv:Body></soapenv:Envelope>"; string franchUserID = "?"; string password = "******"; int userID = 474; string userKey = "?"; string username = "******"; string userRole = "?"; string userStatus = "?"; int usertype = 101; WebServiceClassLiberary.Class1 listings = new WebServiceClassLiberary.Class1(); XDocument element = listings.getList(franchUserID, password, userID, userKey, username, userRole, userStatus, usertype); string file = element.ToString(); var httpClient = new Windows.Web.Http.HttpClient(); var info = "biwstest:biwstest"; var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info)); httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token); httpClient.DefaultRequestHeaders.Add("SOAPAction", ""); Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url); httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0"); IHttpContent content = new HttpStringContent(file, Windows.Storage.Streams.UnicodeEncoding.Utf8); httpRequestMessage.Content = content; Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage); string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync(); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(strXmlReturned); XDocument loadedData = XDocument.Parse(strXmlReturned); var sdata = loadedData.Descendants("PlaceList"). Select(x => new PlaceList { PlaceID = x.Element("placeID").Value, PlaceCode = x.Element("placeCode").Value, PlaceName = x.Element("placeName").Value }); foreach (var item in sdata) { PlaceList pl = new PlaceList(); pl.PlaceID = item.PlaceID; pl.PlaceName = item.PlaceName; pl.PlaceCode = item.PlaceCode; CityList.Add(pl); } ListMenuItems.ItemsSource = sdata; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> /// public async void postXMLData1() { string uri = "http://111.93.131.112/biws/buswebservice"; // some xml string Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute); string franchUserID = "?"; string password = "******"; int userID = 474; string userKey = "?"; string username = "******"; string userRole = "?"; string userStatus = "?"; int usertype = 101; string FromplaceName = txtBFromLocationT.Text; string ToplaceName = txtBToLocationT.Text; string placeIDFrom = txtBFromID.Text; string placeCodeFrom = txtBFromCode.Text; string placeIDTo = txtBToID.Text; string placeCodeTo = txtBToCode.Text; string d = txtBDateTab.Text; System.DateTime dt = System.DateTime.ParseExact(d, "dd MMM yyyy", CultureInfo.InvariantCulture); txtBDateTab.Text = dt.ToString("dd/MM/yyyy"); string Date = txtBDateTab.Text; WebServiceClassLiberary.Class1 listings = new WebServiceClassLiberary.Class1(); XDocument element = listings.getservice(franchUserID, password, userID, userKey, username, userRole, userStatus, usertype, placeIDFrom, placeCodeFrom, FromplaceName, placeIDTo, placeCodeTo, ToplaceName, Date); string stringXml = element.ToString(); var httpClient = new Windows.Web.Http.HttpClient(); var info = "biwstest:biwstest"; var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info)); httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token); httpClient.DefaultRequestHeaders.Add("SOAPAction", ""); Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url); httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0"); IHttpContent content = new HttpStringContent(stringXml, Windows.Storage.Streams.UnicodeEncoding.Utf8); httpRequestMessage.Content = content; Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage); string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync(); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(strXmlReturned); XDocument loadedData = XDocument.Parse(strXmlReturned); var sdata = loadedData.Descendants("service"). Select(x => new GetAvailableService { arrivalDate = x.Element("arrivalDate").Value, arrivalTime = x.Element("arrivalTime").Value, classID = x.Element("classID").Value, classLayoutID = x.Element("classLayoutID").Value, className = x.Element("className").Value, corpCode = x.Element("corpCode").Value, departureTime = x.Element("departureTime").Value, destination = x.Element("destination").Value, fare = x.Element("fare").Value, journeyDate = x.Element("journeyDate").Value, journeyHours = x.Element("journeyHours").Value, maxSeatsAllowed = x.Element("maxSeatsAllowed").Value, origin = x.Element("origin").Value, //placeIDFrom = x.Element("biFromPlace").Attribute("placeID").Value, //placeIDto = x.Element("biToPlace").Attribute("placeID").Value, refundStatus = x.Element("refundStatus").Value, routeNo = x.Element("routeNo").Value, seatsAvailable = x.Element("seatsAvailable").Value, seatStatus = x.Element("seatStatus").Value, serviceID = x.Element("serviceID").Value, startPoint = x.Element("startPoint").Value, stuID = x.Element("stuID").Value, tripCode = x.Element("tripCode").Value }); foreach (var item in sdata) { GetAvailableService gas = new GetAvailableService(); gas.arrivalDate = item.arrivalDate; gas.arrivalTime = item.arrivalTime; gas.classID = item.classID; gas.classLayoutID = item.classLayoutID; gas.className = item.className; gas.corpCode = item.corpCode; gas.departureTime = item.departureTime; gas.destination = item.destination; gas.fare = item.fare; gas.journeyDate = item.journeyDate; gas.journeyHours = item.journeyHours; gas.maxSeatsAllowed = item.maxSeatsAllowed; gas.origin = item.origin; gas.placeIDFrom = item.placeIDFrom; gas.placeIDto = item.placeIDto; gas.refundStatus = item.refundStatus; gas.routeNo = item.routeNo; gas.seatsAvailable = item.seatsAvailable; gas.seatStatus = item.seatStatus; gas.serviceID = item.serviceID; gas.startPoint = item.startPoint; gas.stuID = item.stuID; gas.tripCode = item.tripCode; gas.viaPlaces = item.viaPlaces; availableservice.Add(gas); } ListMenuItems.ItemsSource = sdata; }