There is a .net client which calls java web services api - addSchedule(Date startDate, Date endDate). endDate is optional - i.e client can pass endDate= null and all is fine. But the issue is- .Net client ca开发者_如何学JAVAnnot assign null to Date variable type.
One more thing we checked, if java web service response passes the null Date value to .net client, this is received as Date.MIN_VALUE by .Net. So we thought what if .Net passes endDate=Date.MIN_VALUE,so java will get the endDate=null. But java is getting Date.MIN_VALUE as valid date.
So we are stuck. Please suggest a good workaround.
Try using a Nullable DateTime (Nullable<DateTime>
or DateTime?
), since this can hold a null value. A normal value type (like DateTime) can't hold null, and will have a default value (in the case of DateTime
this is DateTime.MinValue
, but for int
it is 0)
We need to add nillable=true in Java webservice method :- addSchedule(Date startDate, @XmlElement(nillable=true) Date endDate)
. With this new wsdl definition, .Net client generates AddScheule(DateTime, <Nullable>DateTime)
.This is supported by metro 2.2 version jars (jaxb and jaxws.jar). If jre6 has a old version of these jars, download the 2.2 version of these jars and place in the JRE_HOME/lib/endorsed folder. Use the same jre path to build your project.
And when deploying the application on tomcat, copy jaxb and jaxws.jar [2.2 version] in the directory CATALINA_HOME/endorsed. You are good to go.
精彩评论