• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

MSXML variant - Create XML Web request without MSXML

I have the MSXML object and I have the following code (which works superbly - local intranet app):

        Dim objHTTP As New MSXML.XMLHTTPRequest
        Dim strURL As String
        Dim strReturn As String

        strURL = "http://<server>/<path>/<AppPortal>.jsp"

        objHTTP.open("post", strURL, False)
        objHTTP.setRequestHeader("Content-Type", "text/xml")
        strReturn = objHTTP.responseText
        Me.TextBox1.Text = intCtr & ": " & strReturn

Other than converting it to C# (which is trivial), is there any way that I can perform this action using native .net code/libraries?

The MSXML class object is from the MS-XML ToolKit provided by Microsoft.
  • 2
1 Solution
_TAD_Author Commented:

yes, that's exactly what I needed (with a few minor tweaks).

{my code}

                  byte[] buff = System.Text.Encoding.ASCII.GetBytes(inputXml);

                  HttpWebRequest myHttpRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
                  myHttpRequest.Method = "POST";
                  myHttpRequest.KeepAlive = false;
                  myHttpRequest.ContentType = "application/x-www-form-urlencoded";
                  myHttpRequest.ContentLength = buff.Length;
                  myHttpRequest.Timeout = 30000;
                  HttpWebResponse myHttpResponse = null;
                  string response = string.Empty;

                  Stream myRequestStream = null;
                  Stream baseStream = null;
                        myRequestStream = myHttpRequest.GetRequestStream();
                        myHttpResponse = (HttpWebResponse)myHttpRequest.GetResponse();
                        baseStream = myHttpResponse.GetResponseStream();
                        XmlTextReader xmlRdr = new XmlTextReader(baseStream);
                        response = HttpUtility.HtmlDecode(xmlRdr.ReadInnerXml());
Thanks for the grade A and glad you have it sussed

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now