I'm developing a SOAP based WebService (JAX-WS) and dates come with specific format "yyyymmdd". My WSDL defines the date as string but I would like to return a SOAP fault response when the expected format is not followed by the element value.
I've defined an XMLAdapter
for element and tried the following in unmarshall method:
public XMLGregorianCalendar unmarshal(String value) throws Exception {
if (!checkCorrectFormat(value)){
throw new RuntimeException();
}
return ParseHelper.getInstance().parseStrDateToXMLDate(value);
}
But the exception is lost and the WebService goes on without problem getting a null XMLGregorianCalendar
value for the unmarshalled element. Perhaps this is not the right place to implement this format control...
Any help would be appreciated.