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.'
        dataStream.Close()
        ' 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.'
        Console.WriteLine(responseFromServer)

        ' Clean up the streams.'
        reader.Close()
        dataStream.Close()
        response.Close()

Open in new window

Amien90Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
What result are you expecting?
0
Amien90Author Commented:
a xml file/string
0
CodeCruiserCommented:
What happens when you test the page through IE? Does it work as expected?
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Amien90Author Commented:
Yes..

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?


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

Did not understand.
0
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?
0
CodeCruiserCommented:
0
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
0
CodeCruiserCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
0
CodeCruiserCommented:
Try converting the encoding.
0
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
0
Amien90Author Commented:
nevermind

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

is working .. the 500 internal server error is a webservice issue.
Thanks all!
0
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??
0
CodeCruiserCommented:
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?
0
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.

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

This shows the WebResponse example

http://www.c-sharpcorner.com/UploadFile/mahesh/WebRequestNResponseMDB12012005232323PM/WebRequestNResponseMDB.aspx
0
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()
MsgBox(responseFromServer)

is not working
0
Amien90Author Commented:
i will post a new question for this
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.