0

Hi

i am reciving XML File and trying to send a rspone to it my code is:

string sProcess = "";    
        XmlDocument objXML = new XmlDocument();
        DateTime NowD = DateTime.Now;
        String DateD = NowD.ToString("yyyy-MM-ddThhmmss");
       
        try
        {
            sProcess = "Load XML";
            objXML.Load(Page.Request.InputStream);
            
            objXML.Save(@"D:\Payment-" + DateD + ".xml");
            objXML.Load(Request.InputStream);


            XmlNode rootNode = objXML.DocumentElement;
            XmlAttribute StoreIDXml = rootNode.Attributes["Main"];
            XmlNodeList PartnerXML = objXML.GetElementsByTagName("Sender");
            XmlNodeList ItemXML = objXML.GetElementsByTagName("Receiver");

        
            Response.StatusCode = 200;
            Response.StatusDescription = "OK";
            Response.ContentType = "text/xml";
            Response.ContentEncoding = Encoding.UTF8;
            objXML.Save(Page.Response.OutputStream);
 
        }
        catch (System.Xml.XmlException ex)
        {
            Response.StatusCode = 500;
            Response.StatusDescription = "Process: " + sProcess + " - " + ex.Message;
            Response.ContentType = "text/plain";
            Response.Write("HTTP Error " + Convert.ToString(Response.StatusCode) + ": Process: " + sProcess + " - " + ex.Message);
        }

        finally
        {
            objXML = null;
        }

i'm saving the document with no problems but there is no response going out ... where it is the problem ... any help please ..

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by William Walseth
0

Here's some code in ASP.NET C# to do what you're talking about.

// Prepare the response, as XML
			Response.ContentType = "text/xml";

			// Prepare the acknowledgement
			XmlDocument replyDoc = new XmlDocument();
			replyDoc.LoadXml("<response/>");
			replyDoc.DocumentElement.SetAttribute("version", "Response: " + System.DateTime.Now + " " + Server.MachineName);
			
			try {
				XmlDocument xml = new XmlDocument();

				if (Request.HttpMethod == "GET") {
					throw new Exception( "Sorry, we only support HTTP Post" );
				} else {
					xml.Load(Request.InputStream);
				}
				string strService = xml.DocumentElement.GetAttribute("service");
				
				switch( strService ) {
					case "test":
					replayDoc.loadXML( "<response status='it worked'/>" );
					break;

					default:
					throw new Exception( "Unknown service: "  + strService );
					}
				}	catch( Exception ex ) {
					replyDoc.DocumentElement.SetAttribute("err", ex.Message);
				}
			} finally {
				Response.Write(replyDoc.InnerXml);	
			}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.