How best to preserve white space in Web Service SOAP messages going to and coming from Service Now?

sherman_1206
Tera Contributor

After some wonky formatting of my last post I will try this again, your forum does not like any extraneous html tags included:


When a service interacts with Service Now via SOAP Web service it would be ideal to preserve white space in the message. For example: if a html form accepts user input in input and textarea html elements and then passes these values to Service Now for insertion/updating of a given table the whitespace appears to be lost in transit.

- If I enclose the given SOAP field's value in pre tags before sending to service now, the content when displayed by Service Now in the frameset UI is displaying the pre and /pre tags around the text.
- If I submit text to Service Now and replace all " " (a space) with   then the content in Service Now displays all of these   instead of spaces.

I have found that at least in php nl2br() function which for those using other langauges, replaces new lines (\r\n) with a break works fairly well but does not completely preserve the original messages whitespace formatting.

Anyone have a solution to this or know a way to get this working?

3 REPLIES 3

john_andersen
Tera Guru

The best way to preserve whitespace in an element value in SOAP is to use the CDATA operator.

For example, in updating an incident with a comment, I used the following XML:



xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:inc="http://www.service-now.com/incident"
xmlns:xsi="xsi">



d71f7935c0a8016700802b64c67c11c6
Just when you thought<br/>things<br/><br/><br/>could go no worse, you threw this in!





This produced the following output (see attachment):
find_real_file.png


sherman_1206
Tera Contributor

Great, thanks for the response. So using CDATA will help with SOAP data going to Service Now. The next part of this is in regards to the frameset UI and how to preserve whitespace in there. For example a string in the comments field of an incident such as: " lots of space before text" will be replaced with "lots of space before text". The system preserves line breaks but does not respect extraneous white space which some of our techs have asked for because they may wish to add customer comments that have some formatting.

Any ideas on this aspect of it? I know slightly off topic to original question but relevant nonetheless.

Thanks again for the response, much appreciated.


The best suggestions I could give you there are wiki pages:

http://wiki.service-now.com/index.php?title=Using_CODE_Tags_to_Render_HTML_in_a_Journal_Field
---AND---
http://wiki.service-now.com/index.php?title=Implementing_HTML_in_Comments

Maybe your web service import set could take the field contents and add "[ code]< pre>< /pre>[ /code]" tags to your content.

There may be another answer out there, but I don't know it.