As a developer, everyone knows about the enum
type. It is a special data type that enables a variable to be a set of predefined constants, and the variable ought to be identical to one of the values that have been defined for it.
In the SOAP web service, the communication is made through XML (string). But what will happen if someone sends a garbage value to an enum type variable in the SOAP request? This post is all about that. So, continue reading it further.
As you know that the enum
only holds specific values that were defined at the time of the creation of that enum
type. So, it can only hold value, that has been already defined for it.
As XML is the only way of communication in SOAP web service, which is actually nothing but a plain string, a consumer can pass any garbage value to it. So, for the enum
type variable also, we can pass a string of garbage values to the SOAP request.
When the SOAP web service is called by any application, the request XML gets converted to Java objects by marshaling it. If we use Spring-WS Framework, which is one of the implementations of the JAX-WS specification, the @RequestPayLoad
annotation will perform the marshaling job for us.
While marshaling the request XML to Java objects, if there exists any garbage value for the enum
type which is not part of that predefined list of values will be set as NULL
by default in Java.