MSXML variant - Create XML Web request without MSXML

Posted on 2006-05-02
Last Modified: 2007-12-19
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""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.
Question by:_TAD_
    LVL 12

    Accepted Solution

    LVL 23

    Author Comment


    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());
    LVL 12

    Expert Comment

    Thanks for the grade A and glad you have it sussed

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now