Best Alternative to Zero-Value .NET Value Type for Java Spending Service

We are creating some WCF services that will be consumed initially by .NET clients, but will be used in the future for Java clients.

Thus, we want to avoid using any data types in an interface that Java does not support.

The specific one we know about is the types of valid values.

One suggestion is that we can support them using a string to represent, for example, a nullable int. Thus, the empty string is null, otherwise there is a requirement that the string be parsed as an int.

Can anyone recommend a better alternative, or is that what you would do?

+5
source share
2 answers

One of the approaches that was used in the project that I participated several years ago (also .NET / Java) was to add indicator properties: NumPropertyand NumPropertyIsNull. It was not very pretty, but it worked.

As a side to node, I think that in the end we were unable to find one business example where the difference between 0and nullmattered.

+3
source

, WCF, , Java, - Integer int, Byte Byte .. , , NULL .NET , , , , , , Java .

+5

All Articles