Results 1 to 10 of 10

Thread: [2005] XML Web Service Multi Line problem, Solve it if you can ?

  1. #1

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    [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

  2. #2

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: [2005] XML Web Service Multi Line problem, Solve it if you can ?

    anybody up for this ?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  4. #4

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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

  5. #5

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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 . . .

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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 /> (&lt;br /&gt so that you can look for these when receiving the entry back and replacing it with your System.Environment.NewLine

  8. #8

    Thread Starter
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    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

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width