Amien90
asked on
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-url encoded.
The XML structure : the form field REQUEST.
StatusDescription = OK
Specs of webservice:
called using HTTPS-POST.
The contents format: application/x-www-form-url
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()
What result are you expecting?
ASKER
a xml file/string
What happens when you test the page through IE? Does it work as expected?
ASKER
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?
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.
how can i do this?
Did not understand.
ASKER
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?
but i think i need to put a <FORM NAME="REQUEST"> and </FORM> before and after the XML?
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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-fo rm-urlenco ded
i have a confirmation that the content of the xml itself is valid
"An error occured while Parsing an XML document"
myremotepost.Add("REQUEST"
perhaps it has something to do with xml encoding? UTF-8/application/x-www-fo
i have a confirmation that the content of the xml itself is valid
Try converting the encoding.
ASKER
is that encoding done in myremotepost.Add("REQUEST" , doc.InnerText) or in the myremotepost class itself?
myremotepost.Add("REQUEST" , Server.HtmlEncode(doc.Oute rXml))
gives me: 500 Internal Server Error
Dim bytesUTF8 As Byte() = System.Text.Encoding.UTF8. GetBytes(T extBox1.Te xt)
Dim fromUTF8 As String = System.Text.Encoding.UTF8. GetString( bytesUTF8)
myremotepost.Add("REQUEST" , fromUTF8)
gives me: An error occured while Parsing an XML document
myremotepost.Add("REQUEST"
gives me: 500 Internal Server Error
Dim bytesUTF8 As Byte() = System.Text.Encoding.UTF8.
Dim fromUTF8 As String = System.Text.Encoding.UTF8.
myremotepost.Add("REQUEST"
gives me: An error occured while Parsing an XML document
ASKER
nevermind
myremotepost.Add("REQUEST" , Server.HtmlEncode(doc.Oute rXml))
is working .. the 500 internal server error is a webservice issue.
Thanks all!
myremotepost.Add("REQUEST"
is working .. the 500 internal server error is a webservice issue.
Thanks all!
ASKER
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??
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?
ASKER
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.
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
http://www.c-sharpcorner.com/UploadFile/mahesh/WebRequestNResponseMDB12012005232323PM/WebRequestNResponseMDB.aspx
This shows the WebResponse example
http://www.c-sharpcorner.com/UploadFile/mahesh/WebRequestNResponseMDB12012005232323PM/WebRequestNResponseMDB.aspx
ASKER
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.GetResponseStre am()
Dim readStream As New StreamReader(receiveStream , Encoding.UTF8)
Dim responseFromServer As String = readStream.ReadToEnd()
MsgBox(responseFromServer)
is not working
Dim HttpWebRequest As HttpWebRequest = WebRequest.Create(url)
Dim dataStream As HttpWebResponse = HttpWebRequest.GetResponse
Dim receiveStream As Stream = dataStream.GetResponseStre
Dim readStream As New StreamReader(receiveStream
Dim responseFromServer As String = readStream.ReadToEnd()
MsgBox(responseFromServer)
is not working
ASKER
i will post a new question for this