You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by st...@sdv-it.de on 2017/12/20 10:47:26 UTC

CXF treats empty and blank Strings as null

Hi

We are facing an issue with CXF regarding the marshalling of empty/blank 
string.

By default CXF treats empty and blank Strings as null. Unfortunately we 
are consuming a legacy service where a String with containing spaces 
actually has meaning and therefore should not be treated as null.

Is there a way to configure the marshaller to differentiate between and 
empty-string "" and a blank-string " "? So that the blank-string is 
preserved?



best regards

Stefan Goebel

Re: CXF treats empty and blank Strings as null

Posted by Ioel Shem-Tov <io...@gmail.com>.
Hi Stefan,

If I understand your problem correctly, I think you need to add an
interceptor that escapes those spaces to your InIntercpetors.

One possible way, if you do use XML, is to use
org.apache.cxf.interceptor.transform.TransformInInterceptor:

1. Instantiate a TransformInInterceptor
2. On the new interceptor define transformations that escape the spaces
(like " " -> "| |", "  " -> "|  |", or perhaps " " -> "&20;")
3. Add the configured interceptor to your InInterceptos.
4. Interpret the escaped spaces back to spaces.

I hope this helps.
Joel

On 25 December 2017 at 23:12, Andrei Shakirin <as...@talend.com> wrote:

> Hi,
>
> Which media type are you using by communication, is it XML / JSON/
> something different ?
>
> Regards,
> Andrei.
>
> > -----Original Message-----
> > From: stefan.goebel@sdv-it.de [mailto:stefan.goebel@sdv-it.de]
> > Sent: Mittwoch, 20. Dezember 2017 11:47
> > To: users@cxf.apache.org
> > Subject: CXF treats empty and blank Strings as null
> >
> > Hi
> >
> > We are facing an issue with CXF regarding the marshalling of empty/blank
> > string.
> >
> > By default CXF treats empty and blank Strings as null. Unfortunately we
> are
> > consuming a legacy service where a String with containing spaces
> actually has
> > meaning and therefore should not be treated as null.
> >
> > Is there a way to configure the marshaller to differentiate between and
> empty-
> > string "" and a blank-string " "? So that the blank-string is preserved?
> >
> >
> >
> > best regards
> >
> > Stefan Goebel
>

RE: CXF treats empty and blank Strings as null

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

Which media type are you using by communication, is it XML / JSON/ something different ?

Regards,
Andrei.

> -----Original Message-----
> From: stefan.goebel@sdv-it.de [mailto:stefan.goebel@sdv-it.de]
> Sent: Mittwoch, 20. Dezember 2017 11:47
> To: users@cxf.apache.org
> Subject: CXF treats empty and blank Strings as null
> 
> Hi
> 
> We are facing an issue with CXF regarding the marshalling of empty/blank
> string.
> 
> By default CXF treats empty and blank Strings as null. Unfortunately we are
> consuming a legacy service where a String with containing spaces actually has
> meaning and therefore should not be treated as null.
> 
> Is there a way to configure the marshaller to differentiate between and empty-
> string "" and a blank-string " "? So that the blank-string is preserved?
> 
> 
> 
> best regards
> 
> Stefan Goebel