[2005] XML Web Service Multi Line problem, Solve it if you can ?
Hello again,
i havent posted here for the last 2 years but i am happy to be back here.
i have a visual basic .net 2005 project that calls a webservice method ( built also using vb.net 2005). this webservice is supposed to log some events [ insert a database row] into a sql server 2005 database on the same server the webservice is deployed on.
now when i invoke the webmothod from any client application, i send it a multilines text block on a string parameter of the webservice. the problem is the new lines [ carriage returns] it is all lost.
all multiple lines are inserted and retrieved later from the database as a single line text.
how can i make the xml web service understands that i am sending multiple lines ???
thank you all
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
Hello, remember me? I suppose not... :(
Got an example of how exactly you're sending multilines? Are you replacing \n or \r s? Using System.Environment.NewLine? I want to see how the web service 'knows' that it's receiving multilines, and how you know that when you read it back that you don't have multilines.
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
dear Mendhak,
how can i forget you and your frogs, i see you still hanging out with a lot of frogs images. glad to see you still here and doing ok.
back to the issue of the thread so that other readers do not kill us. i am just sending the multiline text in a string parameter of the webservice.
first :
frankly i do not do anything to make the webservice knows that it is recieving multiline.
second:
i know that the multilines are removed becuase i did a small query on the database and put the result into a multiline textbox and it shows as one line. it doesnt even have special characters in it.
thx again for your help friend
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
oops , sorry forgot to tell you. i am sending the string parameter a string that contains several environment.newline. that is how i send it from the application. on the webservice i do no processing. just take the paramter string and run it on an insert sqlcommand directly to the database.
of course i put the string in a sql parameter to prevent harmful sql injections etc . . .
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
I thought for sure this must be a mistake but I got the same results you did. What I found is that something about the XML Deserialization process strips out the \r\n and converts it to \n although I didn't even get that.
I don't have a solution but it definately seems like something that should be easier than it is to fix.
My example is here:
Web Service
Click Once App
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
As they say, you learn something new every day.
Add an annotation, then, to your input, which you process when you receive back. For example, <br /> (<br />) so that you can look for these when receiving the entry back and replacing it with your System.Environment.NewLine
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
okay then,
thank you all for your efforts, i will have to send a complex tag like <br/> while sending the new line and then replace it in the webserviece with environment.newline before inserting in the database.
thank you all for your effort, but sometimes i really hates microsoft. i dont believe in the total testing of the webservices technology, no one checked a multiline parameter !!!!
again thx all for the great help and have a good day.
Regards
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
It's not a Microsoft problem.... it's a WEbService/SOAP "problem" ... the XML is streamed as a single line, and as a result any CRLF is stripped before the request is even sent. So it's not the receiving end that's dropping things, it's the client sender. Unfortunately that's the way it is. The only way I can think of to preserve the data w/o doing a replace is to send the data in a CData element. But I'm not sure how that plays into a SOAP call.
-tg
Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?
Further to what he said, look at this
Quote:
Originally Posted by MSDN
The following describes attribute value normalization:
* For a character reference, append the referenced character to the attribute value.
* For an entity reference, recursively process the replacement text of the entity.
* For a white space character (#x20, #xD, #xA, #x9), append #x20 to the normalized value. (Only a single #x20 is appended for a "#xD#xA" sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity.)
* Process other characters by appending them to the normalized value.
* If the declared value is not CDATA, discard any leading and trailing space (#x20) characters and replace sequences of space (#x20) characters with a single space (#x20) character.
Refer to the W3C XML 1.0 recommendation for further discussion on normalization.
http://msdn.microsoft.com/library/de...ationTopic.asp