473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Managed Code alternative for MSXML2.XMLHTTP

I need to do a synchronous POST to a web server with a
string variable and receive back the response into a
second string variable. It seems that with .NET I find
myself needing to use lots of specialized classes to
accomplish the same thing in VB6. It's getting to the
point where it looks rather kludgy and may be difficult to
maintain in the future. So then, is there a better, more
efficient way to do this?

Here's the VB6 code:
Dim httpPost As New MSXML2.XMLHTTP
With httpPost
.open("POST", "www.someURL.com", False)
.send(strOutgoing)
strIncoming = .responseText
End With

Here's the .NET code:
'is there a better way to read a string into a byte array
than this?
Dim PostEncoding As New System.Text.ASCIIEncoding
Dim PostByteArray As Byte() = PostEncoding.GetBytes
(strOutgoing)
Dim httpPost As HttpWebRequest = CType(WebRequest.Create
("www.someURL.com"), HttpWebRequest)
With httpPost
.Method = "POST"
.ContentLength = strOutgoing.Length

Dim PostStream As System.IO.Stream = .GetRequestStream
()
PostStream.Write(PostByteArray, 0,
PostByteArray.Length)

Dim PostResponse As WebResponse = .GetResponse()
Dim PostResponseStream As System.IO.Stream =
PostResponse.GetResponseStream()
Dim PostStreamReader As New System.IO.StreamReader
(PostResponseStream)
strIncoming = PostStreamReader.ReadToEnd()
End With

Nov 22 '05 #1
0 1557

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
0
by: samtai | last post by:
I need to do a synchronous POST to a web server with a string variable and receive back the response into a second string variable. It seems that with .NET I find myself needing to use lots of...
19
by: trower | last post by:
I would like to be able to grab another sites source code and put it into a field on my form so that I can then grab information from it. The website is :...
2
by: Michael Christensen | last post by:
Hi How do I send an input-param to my web service with MSXML2.ServerXMLHTTP? Can this be done without the soap-toolkit? Can't find anything about it - looking forward getting some help :-)...
0
by: | last post by:
///======================in C# writeSession.aspx ///Session("loginID") == "tmp"; MSXML2.XMLHTTPClass xmlHttp = new XMLHTTPClass(); try { XmlDocument xmlDom = new XmlDocument();...
8
by: Drew | last post by:
I have recently converted all of my native C++ dll's to be compiled with the /CLR switch. After doing this, I notcied a very strange and frustrating issue. One of my managed dll's calls another...
8
by: lopi | last post by:
Hello. I'm trying to remotely get a pdf file - http://remoteServer/file.pdf - in order to store it into another server, maybe with Scripting.FileSystemObject However the following code doesn't...
1
by: Subrato | last post by:
Hi, I am very new to xml and I have this piece of code which I took off a website. The situation is that on of the website, user files up a form and it is submitted. On submission, the page should...
8
by: jd2007 | last post by:
Why the Ajax code below in ajax.js is causing my form not to work ? ajax.js: var a=0; var b=0; var c=0; var d=0; var e=0; var f=0;
5
by: mukeshrasm | last post by:
Hi I am using AJAX to display the value in selection/list box. this code is working fine in Firefox Mozila browser but it is not working in Internet Explorer so please tell me how this will work...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.