简体   繁体   中英

How to express 'null' value from web service as real null or empty string instead of 'null' string

In my application, I am using JSF and Java Web Services. When any of my web-service functions return a null value, it is always expressed as a "null" string. As a consequence, I cannot use EL expressions like #{empty object} to test for null values or empty strings.

I'd like to ask if there's a way to configure such that Java Web Services will return null value as an empty string OR JSF/EL can understand "null" string as null value.

if you,

  • using SOAP, you must remember that the SOAP message is an XML, so you can return an empty String as null or empty object

  • using HTTP or REST, you must remember that the HTTP using type of String to serialize the object and informations

So you have choose:

  • right serialization of return objects. If you using SOAP, remember Base64 encoding.

  • right output value for errors. You can serialize directly the exceptions or your custom message codes.

I hope to help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM