Simple XML Log

I want to receive an XML document via an aspx page and log the raw xml to a text file.  I've been looking at this for a while and can't work out how to do it.  Can someone tell me how to grab the raw xml text (once I've got the text I can do the logging bit)

Thanks
0
anonymous (74722)
5/10/2004 11:26:03 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
736 Views

Similar Articles

[PageSpeed] 19


HHoulston wrote:

> I want to receive an XML document via an aspx page and log the raw
> xml to a text file.  I've been looking at this for a while and can't
> work out how to do it.  Can someone tell me how to grab the raw xml
> text (once I've got the text I can do the logging bit)?

Assuming the XML document is sent as the body of an HTTP POST request 
the following should do:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
void SaveRequestBody (string fileName) {
   if (Request.HttpMethod == "POST") {
     BufferedStream bufferedInputStream = new 
BufferedStream(Request.InputStream);
     BufferedStream bufferedOutputStream = new BufferedStream(new 
FileStream(Server.MapPath(fileName), FileMode.Create));
     byte[] buffer = new byte[512];
     int byteCount;
     while ((byteCount = bufferedInputStream.Read(buffer, 0, 
buffer.Length)) != 0) {
       bufferedOutputStream.Write(buffer, 0, byteCount);
     }
     bufferedInputStream.Close();
     bufferedOutputStream.Close();
   }
}
void Page_Load () {
   string fileName = @"test20040510Log.xml";
   SaveRequestBody(fileName);
   Response.Write("<p>Saved request body as <a href=\"" + fileName + 
"\">file.</a></p>");
}
</script>

This however simply saves the bytes received as a byte stream, no XML 
well-formedness check is done so you might want to stream the bytes 
through an XmlReader before saving them
-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/

0
mahotrash (1777)
5/10/2004 12:30:14 PM
Reply:

Similar Artilces:

XML DataSet Deployment
Let me ask one more time! If you have an application that uses a DataSet (System.Data) but the dataset is only loaded with XML data. Do you need to deploy MDAC with your application? Trey No - DataSet is totally disconnected and can work without any back-end server connection. You can persist DataSet in XML files (and load it afterwards in) without even touching the database. HTH Daniel D.C. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights "Trey" <weaver@nc.rr.com> wrote in message news:e9ui5oh$DHA.3256@TK2MSFTNGP09.phx.gbl......

customizations.xml help
I've imported a custom customizations.xml fiel( latest release for the application) and now accounts, leads and a few more are not on the workplace. While these are not needed for live, I kind of like to have them there as a lot of code samples use them. I can't make them show up by ticking the [i]Areas that display this entity[/i] on each entity menu. I know that I have to modify customizations.xml but how? what do I need to change so that I can tick these? TIA Hi, What you probably need to do is modify the sitemap. There is thorough documentation in the CRM SDK on how ...

XML Structure
Hi how to create dataset to save xml relational structure to file? Programming language is vb.net This is what i get now out <?xml version="1.0" standalone="yes"?> <NewDataSet> <HEADER> <HEADERID>1</HEADERID> </HEADER> <ROW> <ROWID>1</ROWID> <HEADERID>1</HEADERID> </ROW> <ROW> <ROWID>2</ROWID> <HEADERID>1</HEADERID> </ROW> </NewDataSet> It shoud be.. <?xml version="1.0" standalone="yes"?> <NewDataSet> &...

Customer Stats
I have a spreadsheet that logs the time/name/enquiry/etc of Customers. I need it to count the number of callers within each hourly period ie 9:00, 9:10, 9:20, 9:25 would be 4 callers etc, for statistical analysis. I need to send this info to a graph showing volume of callers over the day. I am at my wits end - i am sure it is sooo simple. :confused: Thanks --- Message posted from http://www.ExcelForum.com/ Dear Scotty A pivot table may be the answer. Use the time of day as the row field, and then group all of the calls into hourly blocks. Hope this helps Paul >-----Original M...

use XmlReader/XmlWriter to reformat XML?
Since XmlWriter offers so many nice options for formatting, I thought it would be nice to read in via XmlReader, and write back out via XmlWriter. It might be overkill, but I'd also like to be able to check some values during that time also so I was going to be using XmlReader anyway. Unfortunately I don't see an easy way to stream it back out through XmlWriter without going node by node. Any suggestions? Is there an easier/faster way to do this already? Michael Michael Malinak wrote: > Since XmlWriter offers so many nice options for formatting, I thought it > would ...

How to Replay Log Files
How to Replay Log Files That Have Been Generated Since the Last Full Backup on an Exchange 2003? I found a article that is for Exchange 2000: 821511 Does iit also apply to Exchange 2003? Thanks! Patrick "Patrick" <Patrick@discussions.microsoft.com> wrote: >How to Replay Log Files That Have Been Generated Since the Last Full Backup >on an Exchange 2003? > >I found a article that is for Exchange 2000: 821511 > >Does iit also apply to Exchange 2003? > >Thanks! > >Patrick Bear in mind that the article you referred to was for a restore fro...

Indenting XML in a string
Sorry if this seems like a newbie question, because I *am* rather new to XML I have a string with XML content string s = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><Service xmlns=\"uri://sumthing\">.........</Service>"; where '.....' is some more xml content When printing this string to an ASPX page, I need the output to be properly indented, presentable. I researched on Google a bit, saw something about XMLTextWriter having a Formatting property which can be set to 'Indented', but I don't know how to implem...

Hwo to handle empty fields in XML
The following XML has an empty <UserDefinedTag /> (first record) My VB.NET app got stuck here because I don't know how to handle it. It works fine with a vlid user defined tag (next record) <UserDefinedTag>40320121</UserDefinedTag> Your help is greatly apprecited!! Bill - <JACOData> - <Inventorys> - <Inventory Type="Physical"> <Product>Dyed Diesel</Product> <TankNumber>15008230383-1</TankNumber> <UserDefinedTag /> <DateTime>1/14/2007 1:00:49 PM</DateTime> <Volume>308.122</Vo...

XML validation #2
Hi all I have a xsd schema and some xml input structures, I want to validate them with xsd schema, how to do it. with best regards Viorel Ghilas ...

Serializing multiple objects in one XML document
Each time I serialize an object using XmlSerializer I get a structure like this: <?xml version="1.0"?> <MyType> .. .. </MyType> <?xml version="1.0"?> <MyType> .. .. </MyType> Instead I would like <?xml version="1.0"?> <MyRootThatIWillWriteToTheStream> <MyType> .. .. </MyType> <MyType> .. .. </MyType> </MyRootThatIWillWriteToTheStream> So in other words, can I avoid writing the XML 1.0 decoration header each time? -- Thanks An XML document can only have 1 root, so you have to add ...

multiples * in message tracking log file Exchange 2003 Server
Dear All, When i track message and click for details it shows me error message " The object ****************************** in the message tracking logs can't be found in the directory.The object may be deleted. The tracking history may be incorrect. Any similar expirience or idea what could be a problem? Regards Goran Kubelka <GoranKubelka@discussions.microsoft.com> wrote: >When i track message and click for details it shows me error message >" The object ****************************** in the message tracking logs >can't be found in the directory.The obj...

ignoring tags in xml, using just the text
I would like to create an htm file (using Word) that will have some free form text. However, in the free form text I would like to be able to embed some fields like Name, Address, etc. I have tried to embed the fields surrounded by different characters such as __Name__, @@Name@@, $$Name$$. the problem that i am encountering is that when the htm page is displayed in IE or in Word the text looks correct.. However, when inspecting the html/xml code in notepad, the text looks like __<span class=SpellE>Name</span>__ therefore i cannot use a method like string.replace to replace th...

How to Write one Log file in Multi Thread program
���� MIME ��ʽ�ľ��кܶಿ����Ϣ�� ------=_NextPart_000_0022_01C33EE2.566EF870 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable How to Write one Log file in Multi Thread program. ------=_NextPart_000_0022_01C33EE2.566EF870 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312"> <META content=3D"MSHTML 6.00.246...

Sorting an XML document.
I have a slightly different sorting question than has been proposed before. My docuement looks like: <Records> <Record> <Sequence>5</Sequence> <Name>E</Name> </Record> <Record> <Sequence>1</Sequence> <Name>A</Name> </Record> <Record> <Sequence>4</Sequence> <Name>D</Name> </Record> <Record> <Sequence>2</Sequence> <Name>B</Name> </Record> <Record> <Sequence>3</Sequence> &...

Create XML From access, Fill SQL 2000 Table
Are there .NET commands to create a new table from an XML Schema. I want to create a program which converts an access table to SQL 2000 using XML. Regards ...

ANN: CAX Caching Api for Xml
Beta version is available for CAX, a caching API for XML. CAX extends the functionality of the .NET XmlReader, which is a fast XML pull parser. CAX buffers and caches XML as it is parsed and provides a cursor to all previously parsed XML. CursorMoveToParent and CursorMoveToRoot are two of the eighteen cursor methods. The Path property gives the full path of the currently parsed node. CAX works with xml documents of unlimited size and uses very little memory. CAX may be downloaded from the company website: http://www.xponentsoftware.com/cax.aspx ...

Xml Problem , Please Help
Hi , I have a stored procedure which return an xml by using the (for xml auto/explicit) which working fine under the Query Analyzer . and i would like to build simple function that get the sp name and execute it and return the xml result . what is the best way to do that ? Best Regards , Tiraman :-) Hi Tiraman, First of all, I would like to confirm my understanding of your issue. From your description, I understand that you need to get the Xml results from a SQL stored procedure. If there is any misunderstanding, please feel free to let me know. I think we can get the Xml data fro...

[ANN]VTD-XML 2.1
This is a multi-part message in MIME format. ------=_NextPart_000_00DE_01C7B199.A236C700 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable VTD-XML 2.1 is released. This version contains a number of features and = bug fixes.=20 * The BookMark class is introduced into all available plaforms of = VTD-XML.=20 * C# and Java port of VTD-XML fix the bug of unicode chars in XPath = expression. * C version of VTD-XML has numerous code clean-ups.=20 Downloads available at http://sourceforge.net/project/showfiles.php?group_id=3D110612 ------=_NextPa...

What is the best way to parse and validate an arbitary XML documen
My application needs to be able to parse and validate either a DTD or schema based document without knowing in advance which form of grammar a document is using. (New documents presented to my system are schema based while the older ones are DTD - conversion is not an option as these document represent legally binding contracts and they must be processed as is). In the .Net 1.1 version of my code I used a XmlValidatingReader instance configured with ValidationType.Auto which handled both document types. Now that n I am porting the code to 2.0 I am trying to use the new XmlReader.Create...

SQL logs
I'm working on a test environment, and I attempted to delete the log files, and now everything is a mess. When I try to access the CRM server I get this error: The Microsoft CRM server or security service has been disabled or has not yet started. For more information, contact your system administrator. and if I try to look at the database in SQL Ent. it shows nothing! any ideas? -Gary if you delete the transaction logs, do you lose all core data? -Gary "Gary" <gary.rey@virtium.NOSPAM.com> wrote in message news:%23Q0qGeMHEHA.712@tk2msftngp13.phx.gbl... > I'm w...

XML to DataSet please help with selection
I have a two xml files schema is identical. When I read file into dataset and then bind dataset to the form. These are weather files we are getting from weather service. One file has only local weather so I don't have any problems with that, but other has weather for several different locations. Basically I need to select only weather for location if I know its code. I should have exactly same dataset so I will be able bind it to the same form without recoding. I was trying to use dataview, but dataview works only with one table and doesn't produce dataset. I got it working by ...

programmatically an XSD for converting XML to dataset problem
Hello, not certain if this should go here or ado.net but I'm trying to create an XSD on the fly (due to the fact that our dataaccess component is a legacy component which returns data in an xml format) Now I can create all of the schema using the .Net frameworks class except for being able to add the msdata:isDataSet="true" and msdata:Locale="en-GB" to the main element tag, by code up to the point where I need to add the above is as follows //<xs:schema id="dataset"> XmlSchema schema=new XmlSchema(); schema.Id=&quo...

Displaying XML Stream on ASP.NET Page
I am writing an application which will get stream of XML Data from a CRM application. I am able to make HTTP request and retrieve the xml stream in XML Text Reader. I want to display this data on an ASP.NET page. I have done some research and found that there is XML Web Server control in ASP.NET. However, all the examples I have seen utilize a XML document and not an XML Stream or XMLTextReader object. Can XML Web Server control also read from XML Text Reader. Also, what other options can I use to display stream of XML Data on ASP.NET Page. Any help would be greatly appreciated. Ashish wrot...

HTML tags within XML element rendered to HTML document
Hi What I need to do is to take the following XML (or some variant of it): <?xml version="1.0" encoding="UTF-8"?> <MyRawHTML> <H1>Hello, world!</H1> </MyRawHTML> And apply an XSLT to it along the lines of: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html&g...

How to know if users can log in OWA?
Hello all I need to know if some users can logged in OWA. It's possible? May be it exists a log file or a register or something like this. I work with Exchange Server 2003 and Outlook 2003 as client. Thanks in advanced henpat Check the IIS log files are ask them? Nue "henpat" <henpat63@hotmail.com> wrote in message news:eTjd%23eYIGHA.2668@tk2msftngp13.phx.gbl... > Hello all > > I need to know if some users can logged in OWA. It's possible? > May be it exists a log file or a register or something like this. > > I work with Exchange Server 200...