This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Description
We have created a Datetime adapter to handle empty DateTime tag ( which we are in need to nullify a column in the db) but the below code doesn't work when enable schema validation.
Since seems that the schema validation validate the received value from the xml request message and not from the unmarshal value.
`
public class DateTimeAdapter extends XmlAdapter<String, Date>{
private String pattern = "yyyy-MM-dd'T'HH:mm:ss";
/* (non-Javadoc)
* @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
*/
public String marshal(Date date) throws Exception {
if(date == null)
return null;
return new SimpleDateFormat(pattern).format(date);
}
public Date unmarshal(String dateString) throws Exception
{
if(!dateString.isEmpty())
return new SimpleDateFormat(pattern).parse(dateString);
return new SimpleDateFormat(pattern).parse("1900-01-01T00:00:00");
}
}
`
Xml Message Instance
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="testtnsJ"> <soapenv:Header/> <soapenv:Body> <tes:createTest> <!--Optional:--> <request> <!--Optional:--> <requesterContext> <userId>qwd</userId> <testDate></testDate> </requesterContext> </request> </tes:createTest> </soapenv:Body> </soapenv:Envelope>
Enable schema validation
<jaxws:properties> <entry key="schema-validation-enabled" value="true" /> </jaxws:properties>