We have SOAP webservice and our approach is WSDL first. Below you see the request object generated from wsdl via wsdl to java plugin in pom.xml. This is how request object looks like:
@XmlRootElement(name = "XXXRequest") public class GetXXXRequest {
@XmlElement(name = "XXX", required = true)
@XmlJavaTypeAdapter(XX .class)
protected String x;
@XmlElement(name = "YYY", required = true)
@XmlJavaTypeAdapter(XX .class)
protected String y;
@XmlElement(name = "ZZZ", required = true)
@XmlJavaTypeAdapter(XX .class)
protected String z;
@XmlElement(name = "TTT", required = true)
@XmlJavaTypeAdapter(XX.class)
protected String t;
@XmlElement(name = "TypeOfRequest", required = true)
protected TypeOfRequest type;
@XmlElement(name = "Criteria", required = true)
protected Criteria criteria;
TypeOfRequest IS ENUM. Now TypeOfRequest had 7 values. Let us say User send any other value than the 7 values defined for it in TypeOfRequest then it comes as NULL and our validation can not validate it to see if user really did not chose any TypeOfRequest or gave some other value than 7 values. SO in nut shell i want to validate and send meaningful message if user chose any other value than 7 value. I am not able to achieve it. Is there any way i can do it ? I have an idea that i can intercept it but need guidance to implement it. We are using cxf , jaxws and Spring framework.
Your tags imply you're using Spring; in which case you may want to look into spring validation. Using this, you can add annotations which specify contracts instances of your class should uphold:
@NonNull
, etc., and then add@Valid
(or@Validated
) in your controller method where you're injecting the instance.And in controller: