Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

SOAP filtering out my carriage returns???

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So im trying to send a string that is essentially an xml document. On the client side the string length is larger then what i get on the serverside which causes problems in my application. The client side string has newline and carriage returns but when recieved in the webservice i only see the newlines which account for the missing characters. I do not want to URL encode the string since this would be suboptimal in my situation. what other options do i have to ensure exactly what i send it received in the web service??
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello premesh-

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
 
Marshal
Posts: 28288
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with SOAP, particularly. As it says in section 2.11 of the XML Recommendation:

"To simplify the tasks of applications, the XML processor MUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any #xD that is not followed by #xA to a single #xA character."
 
premesh purayil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the infor. Im not processing the xml here, im just essentially reading a txt file and sending the string result accross to the webservice. The value can be any arbitrary string and in this specific case it just happens to be as a result of reading an xml file. So do you mean to say that when i read a file that is xml i most do some post/pre processing?
 
premesh purayil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
basically my string contains "\r \n" through out it...
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need to preserve the linebreaks as they are, you might consider enclosing all text nodes in CDATA sections, the contents of which are guaranteed to be left undisturbed.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U can do a regex / search replace '/n/r' characters with ' ' and it will work for u .
 
premesh purayil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so there is no way to send a string across soap that contains a carriage return and have it preserve the carriage return? Basically i want to store exactly what is passed in the form it is passed so filtering out the carriage return means when i return the string to the user when they try to retrieve it , it will not be exactly what they entered... is this because of something SOAP is doing?
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May I ask what the purpose of the application is, or at least what the purpose of sending an entire XML document as a String object would be? I've done something similar in the past, and admit, it isn't the best solution. JAXB marshalling and unmarshalling is the best way, in my opinion, to send XML data that represents objects. Even in the application i mentioned above, we still used JAXB to unmarshall the String containing the XML.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Paul pointed out, this has nothing to do with SOAP, but with XML. The way to do it is what I mentioned before: CDATA sections. Their content is guaranteed to be left alone.
 
premesh purayil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose CDATA sections are an option.. basically the application allows you to store annotations ... kinda like a comment which can be any arbritary string of any size (with db limitations). The webservice call is passed an object which is the serialized version of the object that holds the string... something like "literal(length(5)value(hello))" which then it deserializes back into an object. To parse the serialisation we break up the string into tokens by the "(" and the ")".. and i use the length field to determine how long the string was so that i can extract the value correctly ( in case the string had a ")" in it or spaces etc the length param tells me the exact expected length). In this specific case the client is sending over a very large string which they created by parsing an xml doc like isaid..turns out it contains "\r \n" at the end of every line. So when i serialize on the client side the length includes the "\r" but when i desrialize on the server side the length is incorrect and my parsing breaks down. I suppose i can tell the client that we dont support "\r" in the strings so they would have to filter them out... or wrap them in CDATA tags... just wierd that its being striped out anyways... i think i know how to get around this.. but id like to know WHY its doing it
 
reply
    Bookmark Topic Watch Topic
  • New Topic