File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes representing null values in SOAP web services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "representing null values in SOAP web services" Watch "representing null values in SOAP web services" New topic

representing null values in SOAP web services

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
Hi All,

I am currently in the process of creating a web service client. For all optional data elements if we don't have values available we don't pass that element in the SOAP request payload and things work fine but for some specific use cases which we cannot control these elements are being passed something like this

which causes the web service to fail. In general what is the correct way to handle this. should we not be passing the elements in the absence of values or should we pass empty elements
In the latter two I believe the value the Web service receives is blank ("") hence causes it to fail.

Should the web service be handling blank strings or not passing the element at all is the right way to represent null values.

Let me know your thoughts

Jim Akmer
Ranch Hand

Joined: Jul 06, 2010
Posts: 104
Why is the type of the element encapsulated in the tag send to client?
Are you using RPC encoding?
manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
yes Jim. The web services we are trying to communicate with were created years back and they were generated using RPC based java web service standards.
These web services were created using the bottom-up approach.

My question is more generic is should i not pass the soap request elements at all if there are no values or should I resort to empty elements. What is the right way to deal with missing values in the SOAP based webservices world.

Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1183
How do you set a null value via (SOAP) Web Services? might help.


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Another link to an article:
Best wishes!

My free books and tutorials:
I agree. Here's the link:
subject: representing null values in SOAP web services
It's not a secret anymore!