webservice, getting empty response

see code. i get this back "           " .. few empty spaces. Seems like i need to wait longer for the response from server for the full content .. is that possible? how can i do this? or is there anything else wrong?

StatusDescription = OK

Specs of webservice:

called using HTTPS-POST.
The contents  format: application/x-www-form-urlencoded.
The XML structure : the form field REQUEST.
' Create a request using a URL that can receive a post. '
        Dim request As WebRequest = WebRequest.Create(url)
        ' Set the Method property of the request to POST.'
        request.Method = "POST"
        request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
        ' Create POST data and convert it to a byte array.'
        Dim postData As String = ioLines
        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(ioLines)

        ' Set the ContentType property of the WebRequest.'
        request.ContentType = "application/x-www-form-urlencoded"
        ' Set the ContentLength property of the WebRequest.'
        request.ContentLength = byteArray.Length
        ' Get the request stream.'
        Dim dataStream As Stream = request.GetRequestStream()
        ' Write the data to the request stream.'
        dataStream.Write(byteArray, 0, byteArray.Length)
        ' Close the Stream object.'
        ' Get the response.'
        Dim response As WebResponse = request.GetResponse()
        ' Display the status.'
        Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)

        ' Get the stream containing content returned by the server.'
        dataStream = response.GetResponseStream()
        ' Open the stream using a StreamReader for easy access.'
        Dim reader As New StreamReader(dataStream)
        ' Read the content.'
        Dim responseFromServer As String = reader.ReadToEnd
        ' Display the content.'

        ' Clean up the streams.'

Open in new window

Who is Participating?
What result are you expecting?
Amien90Author Commented:
a xml file/string
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

What happens when you test the page through IE? Does it work as expected?
Amien90Author Commented:

i think it is this:

The XML structure : the form field REQUEST

i think i didnt do this .. i need to put the xml content in a HTML field named REQUEST ..
how can i do this?

>i need to put the xml content in a HTML field named REQUEST ..
how can i do this?

Did not understand.
Amien90Author Commented:
i'm not sure too . manual is not that specific

but i think i need to put a <FORM NAME="REQUEST"> and </FORM> before and after the XML?
Amien90Author Commented:
its about the same that i have in my code.
the xml itself is correct. i'v checked that one.

again "html input field named 'request'" .. what does this mean?
seems like i need to embed the xml data into a input field?
help appreciated
Amien90Author Commented:
Thanks for your reply .. ok .. now i got a response from the webservice in xml back . .but its an error
"An error occured while Parsing an XML document"

myremotepost.Add("REQUEST", doc.InnerText)

perhaps it has something to do with xml encoding? UTF-8/application/x-www-form-urlencoded

i have a confirmation that the content of the xml itself is valid
Try converting the encoding.
Amien90Author Commented:
is that encoding done in myremotepost.Add("REQUEST", doc.InnerText) or in the myremotepost class itself?

myremotepost.Add("REQUEST", Server.HtmlEncode(doc.OuterXml))

gives me: 500 Internal Server Error

Dim bytesUTF8 As Byte() = System.Text.Encoding.UTF8.GetBytes(TextBox1.Text)
Dim fromUTF8 As String = System.Text.Encoding.UTF8.GetString(bytesUTF8)
myremotepost.Add("REQUEST", fromUTF8)

gives me: An error occured while Parsing an XML document
Amien90Author Commented:

myremotepost.Add("REQUEST", Server.HtmlEncode(doc.OuterXml))

is working .. the 500 internal server error is a webservice issue.
Thanks all!
Amien90Author Commented:
how do i fetch the xml reponse that i now see in my browser back in asp.net?

If Not Request.Form("field1") Is Nothing Then
Response.Write("field1 : " & Request.Form("field1") & "</br>")
End If
If Not Request.Form("field2") Is Nothing Then
Response.Write("field2 : " & Request.Form("field2") & "</br>")
End If

dont understand this. Request.Form??
Request.Form is being used to read the posted input. It is writing the input back to the output! Is the above code from the webservice?
Amien90Author Commented:
no .. its from your url. this should be used to Receiving Page (Point C) .. i guess

what i have now, is that i see the xml result in the browser. what i want to do is that i only want to output a certain node of the xml.

BTW i though that it should be possible to use the code of my first post to consume xml webservice.. Why do i need to send also html code? i know the webservice is using coldfusion.

You need to use the WebResponse class to receive the result and then use XMLDocument to parse it.

This shows the WebResponse example

Amien90Author Commented:
and i put that after  myremotepost.Post()?

Dim HttpWebRequest As HttpWebRequest = WebRequest.Create(url)
Dim dataStream As HttpWebResponse = HttpWebRequest.GetResponse
Dim receiveStream As Stream = dataStream.GetResponseStream()
Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)
Dim responseFromServer As String = readStream.ReadToEnd()

is not working
Amien90Author Commented:
i will post a new question for this
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.