I've been doing all kinds of searches today and can't seem to find one clear answer on this.
Our payment gateway posts xml data to a custom URL we set, and when an event is triggered at their business center website, it sends an xml report to the URL.
I can't seem to figure out (or get working) reading the http posted data when my URL is triggered. I can get it to work if I just paste the samle xml data into doc.load("<sample.....>...."), but not if I'm reading the inputstream (or at least I think I
am). I don't have a lot of experience with XML, other than using XML Reader to read through a string, etc.
Here's what I think it chokes at with an exception of "Data at the root level is invalid. Line 1, position 1.". I say "think" because I can't debug this since I have to use their Test button on the custom URL at their website, and I don't want to open up
my local host where I normally test/debug.
Dim requestStream As Stream = Request.InputStream <---I THINK IT CHOKES HERE
Dim xmlDoc As XmlDocument = New XmlDocument
Dim xmlUpdateNodeList, xmlFollowOnNodeList As XmlNodeList
Dim xmlNode As XmlNode
xmlDoc.Load(requestStream)
' create XmlNodeReader for document
Dim reader As XmlNodeReader = New XmlNodeReader(xmlDoc)
' display each node's content
While reader.Read
Select Case reader.NodeType
' if Element, display its name
Case XmlNodeType.Element
xmlString = "<" & reader.Name & ">" & "<br />"
' if empty element, decrease depth
If reader.IsEmptyElement Then
xmlString = "Empty Element" & "<br />"
End If
Case XmlNodeType.Comment ' if Comment, display it
xmlString = "<!--" & reader.Value & _
"-->" & "<br />"
Case XmlNodeType.Text ' if Text, display it
xmlString = reader.Value & "<br />"
' if XML declaration, display it
Case XmlNodeType.XmlDeclaration
xmlString = "<?" & reader.Name & " " & _
reader.Value & "?>" & "<br />"
' if EndElement, display it and decrement depth
Case XmlNodeType.EndElement
xmlString = "</" & reader.Name & ">" & "<br />"
End Select
Member
1 Points
77 Posts
Read XML posted to my URL from an external service
Feb 22, 2013 08:34 PM|Laplain|LINK
I've been doing all kinds of searches today and can't seem to find one clear answer on this.
Our payment gateway posts xml data to a custom URL we set, and when an event is triggered at their business center website, it sends an xml report to the URL.
I can't seem to figure out (or get working) reading the http posted data when my URL is triggered. I can get it to work if I just paste the samle xml data into doc.load("<sample.....>...."), but not if I'm reading the inputstream (or at least I think I am). I don't have a lot of experience with XML, other than using XML Reader to read through a string, etc.
Here's what I think it chokes at with an exception of "Data at the root level is invalid. Line 1, position 1.". I say "think" because I can't debug this since I have to use their Test button on the custom URL at their website, and I don't want to open up my local host where I normally test/debug.
Participant
880 Points
190 Posts
Re: Read XML posted to my URL from an external service
Feb 23, 2013 03:26 AM|Talal Tayyab|LINK
This error is indicative of malformed xml. You can try saving the stream data and examining the xml to see if it is proper.
Member
1 Points
77 Posts
Re: Read XML posted to my URL from an external service
Mar 13, 2013 12:01 AM|Laplain|LINK
Member
1 Points
77 Posts
Re: Read XML posted to my URL from an external service
Mar 13, 2013 03:14 PM|Laplain|LINK
Here's what I get:
Data at the root level is invalid. Line 1, position 1.
Any ideas?