String or STring Array?

I am doing an HTTP Request and

This code below outputs the StreamResponse in a StreamReader

In a Debug.WriteLile it looks like regular XML

So...
Is outputdata a string or an array?

Dim outputData As New [String](readBuff, 0, count)

THis is what outputs in a Debug.WriteLine
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<org.m5.api.v1.Response xmlns:m5="http://www.m5net.com/org/m5/data/v2/cti" xmlns:csta="http://www.ecma-international.org/standards/ecma-323/csta/ed5">
    <ErrorCount>0</ErrorCount>
    <Id>1</Id>
</org.m5.api.v1.Response>
lrbristerAsked:
Who is Participating?
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
i know it works, just saying u dont need to read chunks from the response u can read to the end of the stream.

for your question, outputData  is string not an array,
0
 
Meir RivkinFull stack Software EngineerCommented:
can u post the whole code please?
btw, if u use ReadToEnd() of the StreamReader, u gonna get the whole xml as a string.
for example:
Dim response As WebResponse = webRequest.GetResponse()
Dim responseStream As Stream = response.GetResponseStream()
Dim responseReader As New StreamReader(responseStream)
Dim responseString As String = responseReader.ReadToEnd()

Open in new window

0
 
lrbristerAuthor Commented:
Sedgwick

here you go
The part in question is
Dim outputData As New [String](readBuff, 0, count)



Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
 While streamResponse.CanRead
	Dim streamRead As New StreamReader(streamResponse)
 	Dim readBuff(2560) As [Char]
	Dim count As Integer = streamRead.Read(readBuff, 0, 2560)
	Dim line As String = ""
	Debug.WriteLine(ControlChars.Cr + "Characters Returned " + CStr(count))
	If count = 0 Then
		GoTo Resend
	Else
		Dim outputData As New [String](readBuff, 0, count)
		Debug.WriteLine(ControlChars.Cr + "The contents of the returned data are :  ")
 		Debug.WriteLine(ControlChars.Cr + outputData + vbCrLf)
                 
	End If
 End While

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Meir RivkinFull stack Software EngineerCommented:
try this:
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
Dim responseReader As New StreamReader(streamResponse)
Dim responseString As String = responseReader.ReadToEnd()
Debug.WriteLine(ControlChars.Cr + "The contents of the returned data are :  ")
Debug.WriteLine(ControlChars.Cr + responseString + vbCrLf)

Open in new window

0
 
CodeCruiserCommented:
>Is outputdata a string or an array?

You are creating a new instance of string from a byte array so its a string.
0
 
lrbristerAuthor Commented:
sedgewick,
  Huh?

My code works.
I just want to know if that's an array?
0
 
lrbristerAuthor Commented:
sedgeweck

I'm getting it back in chunks from the ResponseSTream
0
 
Meir RivkinFull stack Software EngineerCommented:
ok, didn't know that.
hope i was helpful anyway.
cheers
0
 
lrbristerAuthor Commented:
That's what I wanted. Thanks
0
All Courses

From novice to tech pro — start learning today.