public XDocument getBoardingPoint(getBoardingPointsRequest _objgetBoardingPointsRequest) { XDocument doc = null; XElement root = null; string servicename = "GetBoardingPoints"; XmlDocument servicesNames = new XmlDocument(); try { XNamespace fc = AppStatic.BusIndiaWebService; XNamespace soapenv = AppStatic.XmlSoapSchema; doc = new XDocument(new XDeclaration("1.0", "utf-16", "yes"), root = new XElement(soapenv + "Envelope", new XAttribute(XNamespace.Xmlns + "com", fc.NamespaceName), new XAttribute(XNamespace.Xmlns + "soapenv", soapenv.NamespaceName), new XElement(soapenv + "Header"), new XElement(soapenv + "Body", new XElement(fc + servicename, new XElement("arg0", new XElement("biFromPlace", new XElement("placeCode", _objgetBoardingPointsRequest.placeCodeFrom), new XElement("placeID", _objgetBoardingPointsRequest.placeIDFrom), new XElement("placeName", _objgetBoardingPointsRequest.placeNameFrom) ), new XElement("biToPlace", new XElement("placeCode", _objgetBoardingPointsRequest.placeCodeTo), new XElement("placeID", _objgetBoardingPointsRequest.placeIDto), new XElement("placeName", _objgetBoardingPointsRequest.placeNameTo) ), new XElement("journeyDate", _objgetBoardingPointsRequest.journeyDate), new XElement("serviceID", _objgetBoardingPointsRequest.serviceID), new XElement("stuFromPlace", new XElement("placeCode", _objgetBoardingPointsRequest.placeCodestuFromPlace), new XElement("placeID", _objgetBoardingPointsRequest.placeIDstuFromPlace), new XElement("placeName", _objgetBoardingPointsRequest.placeNamestuFromPlace) ), new XElement("stuID", _objgetBoardingPointsRequest.stulID), new XElement("stuToPlace", new XElement("placeCode", _objgetBoardingPointsRequest.placeCodestuToPlace), new XElement("placeID", _objgetBoardingPointsRequest.placeIDstuToPlace), new XElement("placeName", _objgetBoardingPointsRequest.placeNamestuToPlace) ), new XElement("wsUser", new XElement("franchUserID", _objgetBoardingPointsRequest.franchUserID), new XElement("password", _objgetBoardingPointsRequest.password), new XElement("userID", _objgetBoardingPointsRequest.userID), new XElement("userKey", _objgetBoardingPointsRequest.userKey), new XElement("userName", _objgetBoardingPointsRequest.userName), new XElement("userRole", _objgetBoardingPointsRequest.userRole), new XElement("userStatus", _objgetBoardingPointsRequest.userStatus), new XElement("userType", _objgetBoardingPointsRequest.userType) ) ) ) ) ) ); } catch (Exception ex) { } return doc; }
public async void postXMLData1() { try { string uri = AppStatic.WebServiceBaseURL; // some xml string Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute); getBoardingPointsRequest _objBPR = new getBoardingPointsRequest(); _objBPR.franchUserID = AppStatic.franchUserID; _objBPR.password = AppStatic.password; _objBPR.userID = AppStatic.userID; _objBPR.userKey = AppStatic.userKey; _objBPR.userName = AppStatic.userName; _objBPR.userRole = AppStatic.userRole; _objBPR.userStatus = AppStatic.userStatus; _objBPR.userType = AppStatic.userType; _objBPR.placeIDFrom = pickDropHelper.objGetAvailableService.placeIDFrom; _objBPR.placeCodeFrom = pickDropHelper.objGetAvailableService.placeCodeFrom; _objBPR.placeNameFrom = pickDropHelper.objGetAvailableService.placeNameFrom; _objBPR.placeIDto = pickDropHelper.objGetAvailableService.placeIDto; _objBPR.placeCodeTo = pickDropHelper.objGetAvailableService.placeCodeTo; _objBPR.placeNameTo = pickDropHelper.objGetAvailableService.placeNameTo; _objBPR.journeyDate = pickDropHelper.objGetAvailableService.journeyDate; _objBPR.serviceID = pickDropHelper.objGetAvailableService.serviceID; _objBPR.placeCodestuFromPlace = pickDropHelper.objGetSeatLayout.placeCodestuFromPlace; _objBPR.placeCodestuToPlace = pickDropHelper.objGetSeatLayout.placeCodestuToPlace; _objBPR.placeIDstuFromPlace = pickDropHelper.objGetSeatLayout.placeIDstuFromPlace; _objBPR.placeIDstuToPlace = pickDropHelper.objGetSeatLayout.placeIDstuToPlace; _objBPR.placeNamestuFromPlace = pickDropHelper.objGetSeatLayout.placeNamestuFromPlace; _objBPR.placeNamestuToPlace = pickDropHelper.objGetSeatLayout.placeNamestuToPlace; _objBPR.stulID = pickDropHelper.objGetAvailableService.studID; xmlUtility listings = new xmlUtility(); XDocument element = listings.getBoardingPoint(_objBPR); string file = element.ToString(); var httpClient = new Windows.Web.Http.HttpClient(); var info = AppStatic.WebServiceAuthentication; 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); List<getBoardingPoints> sdata = loadedData.Descendants("boardingPoints").Where(c => c.Element("type").Value == "DROPOFF POINT").Select(c => new getBoardingPoints() { platformNo = c.Element("platformNo").Value, pointID = c.Element("pointID").Value, Time = c.Element("time").Value, Type = c.Element("type").Value, pointName = c.Element("pointName").Value }).ToList(); foreach (var item in sdata) { _obj.platformNo = item.platformNo; _obj.pointID = item.pointID; _obj.pointName = item.pointName; _obj.Time = item.Time; _obj.Type = item.Type; _getBoardingPoints.Add(_obj); } ListMenuItems.ItemsSource = sdata; LoaderPopDropoff.Visibility = Visibility.Collapsed; } catch (Exception ex) { } }