public string InterfaceClassToXml(FindDepartureRouteResult interfaceClass) { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance"); MemoryStream memoryStream = new MemoryStream(); XmlSerializer xs = new XmlSerializer(interfaceClass.GetType()); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, new UTF8Encoding()); xs.Serialize(xmlTextWriter, interfaceClass, ns); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; return(UTF8ByteArrayToString(memoryStream.ToArray())); }
private void button1_Click(object sender, EventArgs e) { using (TransportationPortalWebService ops = new TransportationPortalWebService()) { textBox3.Text = "call"; ops.Url = textBox1.Text; string DepartureId = textBox2.Text; FindDepartureRouteResult r = ops.FindDepartureRoute(null, null, DepartureId); textBox3.Text = "null"; if (r != null) { string s = InterfaceClassToXml(r); textBox3.Text = s; } } }
public FindDepartureRouteResult FindDepartureRoute(string ChannelId, string Language, string DepartureIdentity) { TransportationPortal p = new TransportationPortal(); internalFindDepartureRouteSearchParameters internalFindDepartureRouteSearchParameters = new internalFindDepartureRouteSearchParameters(); internalFindDepartureRouteSearchParameters.DepartureIdentity = DepartureIdentity; internalFindDepartureRouteResult internalFindDepartureRouteResult = (internalFindDepartureRouteResult)PackageHelper.GetResult(internalFindDepartureRouteSearchParameters, p.FindDepartureRoute, p.find); if (internalFindDepartureRouteResult.list.GetLength(0) != 1) { return(null); } else { FindDepartureRouteResult FindDepartureRouteResult = new FindDepartureRouteResult(); FindDepartureRouteResult.DepartureRoute = internalFindDepartureRouteResult.list[0]; return(FindDepartureRouteResult); } }