我需要将 xml 响应保存到会话中。但我试过了,但没有。但我已将 xml 请求另存为会话它有效。我附上了工作和非工作代码。任何人都可以帮我解决这个问题。我不想将 xml 响应保存为文件。
工作代码
String xmltest = Session["xmlreq"].ToString();
SoapClient soap = new SoapClient();
string prueba = soap.RequestResponseMethod("getHotelValuedAvail", xmltest);
string tham = HttpUtility.HtmlDecode(prueba);
XmlDocument doc = new XmlDocument();
doc.LoadXml(tham);
doc.Save(Server.MapPath("hotelrs.xml"));
XslTransform myXslTransform;
myXslTransform = new XslTransform();
myXslTransform.Load(Server.MapPath("hotel.xsl"));
myXslTransform.Transform(Server.MapPath("hotelrs.xml"), Server.MapPath("transformhotels.xml"));
非工作代码
String xmltest = Session["xmlreq"].ToString();
SoapClient soap = new SoapClient();
string prueba = soap.RequestResponseMethod("getHotelValuedAvail", xmltest);
string tham = HttpUtility.HtmlDecode(prueba);
Session.Add("xmlrs", tham);
XmlDocument doc = new XmlDocument();
doc.LoadXml(Session["xmlrs"].ToString());
//doc.Save(Server.MapPath("hotelrs.xml"));
XmlDocument trdoc = new XmlDocument();
XslTransform myXslTransform;
myXslTransform = new XslTransform();
myXslTransform.Load(Server.MapPath("hotel.xsl"));
myXslTransform.Transform(doc.InnerXml, trdoc.InnerXml);
Session.Add("xmltrs", trdoc.InnerXml);