[2005] Send XML document as Request Parameter
How do I send an XML document as a request parameter? Here's some pseudo code of what I have so far:
I'm using the XMLDocument Object, then using 'OuterXML' I get the document as a string : strXMLdoc
url = "http://myurl.com"
strpost = "xml=" & HttpUtility.UrlEncode(strXMLdoc)
I set the content type to 'text/xml'
And to send :
Dim encoding As New System.Text.UTF8Encoding
Dim byte1 As Byte() = encoding.GetBytes(strpost)
Dim newStream As Stream = objRequest.GetRequestStream()
newStream.Write(byte1, 0, byte1.Length)
newStream.Close()
Then I use the Request object and Stream - which works in all other cases so I know that part is right.
Is there anything wrong with the above? I will post more of the code if its not obvious (like am I using the wrong content type or encoding, or am I doing a 'double' encoding (using httputility and UTF8 ?)
Re: [2005] Send XML document as Request Parameter
As a request parameter? Are you sure you have your terminology right?
As a request parameter would mean that you're sending it to another page and want to pass it either by GET or POST.
Your code appears to be writing the XML out; as though you want a user to browse to your page and it should appear as an XML document to them. Is that what you're trying?
As for your code, more could would help, yes.