Solved

Send POST and then Recive XML - system.net.WebRequest

Posted on 2004-10-26
225 Views
Last Modified: 2008-02-26
I need to be able to do this

POST /servlet/MainVCAServlet HTTP/1.0
Content-Type: text/xml
User-Agent: xLinkClient
Content-length: 544

<?xml version="1.0" standalone="no"?>
<!DOCTYPE request SYSTEM "http://xapi.covad.com/dtd/request.dtd">
<request>
<header>
<sender>
<key>
<login>YOUR LOGIN ID</login>
<password>YOUR PASSWORD</password>
</key>
</sender>
</header>
<body>
<subrequest type="serviceavailability">
<serviceavailabilityrequest>
<address>
<street1>1016 Asbury Way</street1>
<city>Mountain View</city>
<state>CA</state>
<zip>94043</zip>
</address>
</serviceavailabilityrequest>
</subrequest>
</body>
</request>

I am thinking it can be done with system.net.WebRequest
0
Question by:Vartana
    5 Comments
     
    LVL 96

    Expert Comment

    by:Bob Learned
    Yes, you should be able to do this.  Have you started with any code?  Do you know how to form a web request?

    Bob
    0
     
    LVL 1

    Author Comment

    by:Vartana
    no I dont know how to use it ?
    0
     
    LVL 96

    Accepted Solution

    by:
    0
     
    LVL 1

    Author Comment

    by:Vartana
    Dim myRequest As WebRequest = WebRequest.Create("http://staging.mileg.org/testapp/form2.asp")
    Dim strPost As String = "textbox=simon"
    MessageBox.Show(myRequest.RequestUri.ToString)myRequest.Method = "post"
    myRequest.ContentLength = strPost.Length
    myRequest.ContentType = "application/x-www-form-urlencoded"
    Dim mystreamwriter As New StreamWriter(myRequest.GetRequestStream)
    mystreamwriter.Write(strPost)
    mystreamwriter.Close()
    MessageBox.Show(myRequest.RequestUri.ToString)

    ' Return the response.
    Dim myResponse As WebResponse = myRequest.GetResponse
    Dim mystream As Stream = myResponse.GetResponseStream
    Dim mystreamreader As New StreamReader(mystream)
    Do Until mystreamreader.Peek = -1
    TextBox1.Text += (mystreamreader.ReadLine.ToString())
    Loop
    mystreamreader.Close()
    mystream.Close()
    0
     
    LVL 96

    Expert Comment

    by:Bob Learned
    0

    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!

    Suggested Solutions

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    884 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

    21 Experts available now in Live!

    Get 1:1 Help Now