Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jaxb not validating values returned from unmarshal method in DateTimeAdapter #1199

Open
Tomas-Kraus opened this issue May 28, 2018 · 1 comment

Comments

@Tomas-Kraus
Copy link
Member

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>

@Tomas-Kraus
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant