Receiving an HTTP Post C#

D

digitalcolony

I need to setup a web page that receives an XML document via an HTTP
post. Should I use an HTTP handler, web service, webRequest, Stream or
something else? In Classic ASP I used the "Request" and it worked.
Any example links would also be helpful.

MAS
 
J

Joerg Jooss

Thus wrote (e-mail address removed),
I need to setup a web page that receives an XML document via an HTTP
post. Should I use an HTTP handler, web service, webRequest, Stream
or something else? In Classic ASP I used the "Request" and it
worked. Any example links would also be helpful.

I would say that depends on what kind of XML it is (is it SOAP or Plain Old
XML aka POX?) and what happens with it afterwards (do you simply store it
somewhere or do you need to parse it?).

Cheers,
 
S

Sharon

Hi,
WebRequest is the easy way.
Web services is better, but a little harder to implement.
It depends on your application needs.
Sharon.
 
D

digitalcolony

Plain Old XML (not SOAP). I've got the code written that parses the
XML, just not the part that "catches" it.

The page doesn't make a request out. It sits and waits for a post.


MAS
 
D

digitalcolony

HttpListener is not page specific.
WebRequest asks that I request data from a URL.

What I need is a page that receives XML from a POST. I don't need to
POST out, I need to receive that POST. What object does this?

In Classic ASP it was the Request object.

Set oXML = Server.CreateObject("Msxml2.FreethreadedDomDocument")
oXML.async = False
oXML.setProperty "ServerHTTPRequest", True
oXML.load(Request)
sPost = oXML.xml

Anyone know the C# equal to these 5 lines of code?

MAS
 
J

Joerg Jooss

Thus wrote digitalcolony,
HttpListener is not page specific.
WebRequest asks that I request data from a URL.
What I need is a page that receives XML from a POST. I don't need to
POST out, I need to receive that POST. What object does this?

In Classic ASP it was the Request object.

Set oXML = Server.CreateObject("Msxml2.FreethreadedDomDocument")
oXML.async = False
oXML.setProperty "ServerHTTPRequest", True
oXML.load(Request)
sPost = oXML.xml
Anyone know the C# equal to these 5 lines of code?

Read the XML directly from HttpRequest.InputStream, like

protected void UploadButton_Click(object sender, EventArgs e) {
// LoadXml() represents your XML processing code. It should work
// with a System.IO.Stream
LoadXml(Request.InputStream);
}

Cheers,
 
D

digitalcolony

Thanks for pointing me in the right direction. InputStream is exactly
what I needed.

string rawXML="";
XmlTextReader reader = null;
reader = new XmlTextReader(Request.InputStream);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(reader);
rawXML = xmlDoc.InnerXml;

MAS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top