title: JAVA WEBSERVICE : Unmarshalling Error: For input string: ""
body: <p>I'm running via SoapUI a webservice.
  With the following request, </p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ofic="http://www.myserver.com/mywebService/"&gt;
     &lt;soapenv:Header&gt;
    &lt;ofic:headerRequest&gt;
       &lt;timeStampRequest&gt;2017-11-07&lt;/timeStampRequest&gt;
       &lt;username&gt;xxxxxx&lt;/username&gt;
       &lt;password&gt;xxxxxx&lt;/password&gt;
    &lt;/ofic:headerRequest&gt;
    &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;ofic:contract&gt;
           &lt;contractNo&gt;&lt;/contractNo&gt;
        &lt;/ofic:contract&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>i'm obtaining this response:</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soap:Body&gt;
        &lt;soap:Fault&gt;
           &lt;faultcode&gt;soap:Client&lt;/faultcode&gt;
           &lt;faultstring&gt;Unmarshalling Error: For input string: ""&lt;/faultstring&gt;
        &lt;/soap:Fault&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>The attribute "contractNo"  is type "Long", and it can't have a null value. I was trying to validate the value of "contractNo", but it seems that this unmarshalling error fires before the validation of this attribute.</p>
  
  <p>Is there a way to trap this unmarshalling error , in order to show a different message?</p>
  
  <p>Thanks in advance!!!</p>
  
  <p><B><i>(...three hours later + a horrible headache ...)</i></B></p>
  
  <p><b>SOLUTION</b></p>
  
  <p>In the class "Contract" i put this:</p>
  
  <pre><code>@NotNull(message="cannot be null")
  @XmlElement(required = false,nillable=true)
  @XmlJavaTypeAdapter(type=long.class, value=XMLLongAdapter.class)
  protected long contractNo;
  </code></pre>
  
  <p>XMLLongAdapter.class  was built based on this post --> <a href="https://stackoverflow.com/questions/14053063/marshaling-a-long-primitive-type-using-jaxb">Marshaling a long primitive type using JAXB</a></p>
  
  <p>And that is, i can validate the null entry for the attribute "contractNo"</p>
  
  <p>I hope it helps.</p>