title: Making WSDL parameters optional
body: <p>I'm trying to work with the Microsoft Exchange EWS protocol, for which Microsoft provide a WSDL file. I'm generate a JAX-WS client library from this using <code>wsimport</code>.</p>
  
  <p>Unfortunately, Microsoft's WSDL file is faulty. One of the things it is getting wrong (apparently) is that all SOAP request parameters are defined as mandatory --- except they're not, they're optional, and in some situations I have to be able to not supply them.</p>
  
  <p>Excerpt from the WSDL file:</p>
  
  <pre><code>&lt;wsdl:operation name="GetUserAvailability"&gt;
      &lt;soap:operation soapAction="http://schemas.microsoft.com/exchange/services/2006/messages/GetUserAvailability" /&gt;
      &lt;wsdl:input&gt;
          &lt;soap:header message="tns:GetUserAvailabilitySoapIn" part="Impersonation" use="literal"/&gt;
          &lt;soap:header message="tns:GetUserAvailabilitySoapIn" part="TimeZoneContext" use="literal"/&gt;
          &lt;soap:header message="tns:GetUserAvailabilitySoapIn" part="RequestVersion" use="literal"/&gt;
          &lt;soap:body parts="GetUserAvailabilityRequest" use="literal" /&gt;
          &lt;soap:header message="tns:GetUserAvailabilitySoapIn" part="RequestVersion" use="literal"/&gt;
      &lt;/wsdl:input&gt;
      &lt;wsdl:output&gt;
          ...skipped...
      &lt;/wsdl:output&gt;
  &lt;/wsdl:operation&gt;
  
  &lt;wsdl:message name="GetUserAvailabilitySoapIn"&gt;
      &lt;wsdl:part name="GetUserAvailabilityRequest" element="tns:GetUserAvailabilityRequest" /&gt;
      &lt;wsdl:part name="Impersonation" element="t:ExchangeImpersonation"/&gt;
      &lt;wsdl:part name="TimeZoneContext" element="t:TimeZoneContext" /&gt;
      &lt;wsdl:part name="RequestVersion" element="t:RequestServerVersion"/&gt;
  &lt;/wsdl:message&gt;
  
  &lt;xs:element name="ExchangeImpersonation" type="t:ExchangeImpersonationType"/&gt;
  </code></pre>
  
  <p>If I call this with, say, <code>service.getUserAvailability(request, null, null, version)</code>, then I get an <code>&lt;ExchangeImpersonation xsl:nil="true"/&gt;</code> element in the header, and the Exchange server complains about having an extraneous element.</p>
  
  <p>So, I want to edit the WSDL file to make these parameters properly optional. I've tried adding various combinations of <code>wsdl:required=false</code> and <code>minOccurs=0</code> to various places according to the docs, but <code>wsimport</code> appears to be ignoring them completely --- the resulting code is unchanged.</p>
  
  <p>How do I do this?</p>