Search code examples
javaweb-servicessoapwsdljax-ws

WSDL date input in SOAP request always gets null, even when it isn't


I am trying to pass a date input through a soap request. However, I always get a null variable for that field in particular and not any other. When I tried to change the date variable from date to string, i actually received the variable with no issues. But when I retried with Date as type, I recreated the issue. Please help me find what I am missing. I use JAX-WS with JDK 1.7, maven 3.2.3. and I am running the application on a glassfish 4.1 Here is the request class (i am omitting the getters and setters for the sake of space here but they're well there!):

@XmlType(name = "ClientConsultationRequest", propOrder = {  "canal",
    "msisdn", "shDes", "dateOfSearch" , "nbrOfCycles" } )
public class ClientConsultationRequest extends BaseRequest {

@XmlElement(required=false, nillable = true)
private String canal;
@XmlElement(required = false, nillable = false)
private String msisdn;
@XmlElement(required = false, nillable = true)
private String shDes;
@XmlElement(required = false, nillable = false)
private Date dateOfSearch;
}

and when I do as follows:

Date dateOfSearch = consultationRequest.getDateOfSearch();

I get the following:

dateOfSearch = null

Even though my SOAP request contains:

        <!--Optional:-->
        <dateOfSearch>05/01/2015 22:00:00</dateOfSearch>

Solution

  • SOAP supported date format is fixed to YYYY-MM-DD'T'HH:mm:ss.SSSZ. Other than that every other format is considered as a null input.