Webservice returning strings

R

Richard Bailey

Hi. I've got a problem that is totally baffling me. Its also a very
simple one. Basically the following code :

<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello" & Chr(13) & Chr(10) & "World"
End Function

Returns "HelloWorld" when I display it in a textbox or output it to a
file with StreamWriter. I'm creating an application that takes files
from the webserver, zips them and sends them to the client app. Along
the way it was dropping all my carriage-returns. When I tried executing
the above simple example, it still filters out the new lines. What
baffles me more is that when I first compress the file and pass an array
of bytes to the client, the client uncompresses the file correctly but
the output still contains no carriage-returns. I've tried all different
combinations of carriage-returns/line-feeds but regardless when I do a
string.indexOf(chr(13)) on the returned string I get nothing.

Thank you in advance for any help you can offer.
 
T

Telmo Sampaio

Richard,

I do not know if there is an easy solution for this problem. But what you
see is due t the fact that Web Services return XML data. In XML, chr(10) and
chr(13) are considered "insignificant white spaces", and do not show up.

I know this doesn't help much, but I could not ind a solution without
changing the way your web method handles the returned data (like returning
an aray of string lines, so you know each elemet is a different line).

Telmo
 
R

Richard Bailey

Ok, I came up with a solution but I was hoping there was a better way.
I just inserted <NL> where ever there was supposed to be a new line and
after downloading the file I replace the <NL> with actual
carriage-returns. I understand why transferring data from a web service
to a client application would cause the string to lose carriage-returns,
but even transferring string data from a private function to another
function loses them.

Oh well. For now I got my mickey mouse solution. If anyone has any
better ideas, please let me know. Thanks a bunch.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top