title: How are date and datetime supposed to be serialized SOAP (xml) messages
body: <p>We are working on a building a java client with a third party SOAP Webservice, that is I have not access or control off server side code.  We are just provided with the WSDL description file of the service.  We are using Axis 1 (version 1.4 ).  </p>
  
  <p>We have run into following issue related to date vs datetime serialization and deserialization.  The said wsdl defines two types DateTime and DateRange</p>
  
  <pre><code>&lt;xs:element minOccurs="0" name="DateTime" type="xs:dateTime"/&gt;
  &lt;xs:element minOccurs="0" name="DateRange"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="Start" type="xs:date"/&gt;
        &lt;xs:element name="End" type="xs:date"/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>Where xs prefix denotes XML Schema, that is following is present </p>
  
  <pre><code>xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  </code></pre>
  
  <p>The axis wsdl2java generates Java Objects whre datetime field is type to Calendar, and start, end fields are typed to java.util.Date</p>
  
  <p>When serialization happens the start and end fields are serialized to yyyy-mm-dd format , for example 2014-02-01 
  But when the actual call is made to server side we recieve following response</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;SOAP-ENV:Header/&gt;
     &lt;SOAP-ENV:Body&gt;
        &lt;SOAP-ENV:Fault&gt;
           &lt;faultcode&gt;SOAP-ENV:Server&lt;/faultcode&gt;
           &lt;faultstring xml:lang="en"&gt;JiBX unmarshalling exception; nested exception is org.jibx.runtime.JiBXException: Missing 'T' separator in dateTime&lt;/faultstring&gt;
        &lt;/SOAP-ENV:Fault&gt;
     &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>We used SOAP UI to build the request xml payload directly and observed if we pass just the date portion in start and end fields we get exact same response, while if we pass those two fields with time portion like a dateTime field it works, gives no fault message.</p>
  
  <p>This when taken together with what I could gleam from XMLSchema documentation for 
  <a href="http://www.w3.org/TR/xmlschema-2/#date" rel="nofollow"> xs:date </a> and <a href="http://www.w3.org/TR/xmlschema-2/#dateTime" rel="nofollow">xs:dateTime</a> , in particular lexical and canonical representation section, seems to imply that</p>
  
  <ol>
  <li><p>Axis based serialization of start and end field to just yyyy-mm-dd and ignoring the time portion is correct.  And client side code generated conforms to WSDL provided to us.</p></li>
  <li><p>Server side code does not conform to WSDL provided to us, it expects a dateTime field rather than a date field.</p></li>
  <li><p>Since date and dateTime  field are required to be serialized in different formats by the schema definition.  The result it failure at server side when it attempts to de-serialize 
  the message </p></li>
  </ol>
  
  <p>To validate our hypothesis 1. we used Python's ZSI library to generate python stub and resulting xml from it.<br>
  Even that serializes start and end in yyyy-mm-dd format , with an additional 'Z' at the end.
  This again fails to get deserialized at server side, even though this serialization format conforms to xs:date as defined by XML Schema</p>
  
  <pre><code>&lt;ns1:Start&gt;2014-02-05Z&lt;/ns1:Start&gt;
  </code></pre>
  
  <p>Can somebody confirm if hypothesis formed by us, based on observed behaviour, documentation and experiment with Python's ZSI is correct.  Or if we are missing some detail</p>