Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / December 2004

Tip: Looking for answers? Try searching our database.

.net framework equivalent to MSXML2.XMLHTTP40()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave H - 15 Dec 2004 17:41 GMT
Hello all,

Novice to ASP.NET and am trying to access web service via xml.  I declared a
request  and DOC object one one using MSXML the other .net framework:

       Dim objRequest As New MSXML2.XMLHTTP40()
       Dim objXMLDoc As New XmlDocument()

What is the .net equivalent to the MSXML2.XMLHTTP40()?

Thanks,
Dave
Buddy Ackerman - 18 Dec 2004 05:54 GMT
> Hello all,
>
[quoted text clipped - 8 lines]
> Thanks,
> Dave

What you need to use is the WebRequest object.  Here's a funciton that I wrote
to POST a request (watch for wrapping in this message).  This function will
return the resposne content as a string which you can load into an XMLDocument
object and parse, query via XPath, or transform using XSLT.  If the web service
uses SOAP and has a WSDL there is  nice capability in VS.NET (or even the free
Webmatrix tool) that will create a class for accessing the web service.  BTW,
the params argument need to be in the format of that of a normal form POST
request (i.e. &field1=somevalue&field2=someothervalue&field3=...)

        Public Function webFormPost(ByVal myUri As String, ByVal params As
String, ByRef errors As String) As String

            Dim retString As String
            Dim request As HttpWebRequest = CType(WebRequest.Create(myUri),
HttpWebRequest)
            request.Method = "POST"
            request.ContentLength = len(params)
            request.ContentType = "application/x-www-form-urlencoded"

            Dim writer As New StreamWriter(request.GetRequestStream())
            Try
                writer.write(params)
            Catch e As Exception
                errors = e.message
            Finally
                writer.Close()
            End Try

            Dim response As HttpWebResponse = request.GetResponse()
            Dim strmReader As New StreamReader(response.getResponseStream())
            retString = strmReader.ReadToEnd()
            strmReader.close()
            Return retString
        End Function

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.