• 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")
        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.
0
_TAD_
Asked:
_TAD_
  • 2
1 Solution
 
gbzhhuCommented:
0
 
_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;
                  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());
                  }
0
 
gbzhhuCommented:
Thanks for the grade A and glad you have it sussed
0

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