Link to home
Start Free TrialLog in
Avatar of _TAD_
_TAD_

asked on

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")
        objHTTP.send(strXML)
        strReturn = objHTTP.responseText
        Me.TextBox1.Text = intCtr & ": " & strReturn
        Me.Refresh()

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.
ASKER CERTIFIED SOLUTION
Avatar of gbzhhu
gbzhhu
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _TAD_
_TAD_

ASKER


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;
                  try
                  {
                        myRequestStream = myHttpRequest.GetRequestStream();
                        myRequestStream.Write(buff,0,buff.Length);
                     
                        myHttpResponse = (HttpWebResponse)myHttpRequest.GetResponse();
                        baseStream = myHttpResponse.GetResponseStream();
           
                        XmlTextReader xmlRdr = new XmlTextReader(baseStream);
               
                        xmlRdr.MoveToContent();
                        response = HttpUtility.HtmlDecode(xmlRdr.ReadInnerXml());
                  }
Thanks for the grade A and glad you have it sussed