title: Making a web service request parameter a required field
body: <p>The is code first approach to Jax-WS web service.</p>
  
  <pre><code>@WebService (serviceName = "MyInstallPhotoService")
  @SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL, parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
  public class MyInstallPhotoWS {
  
      private MyInstallPhotoManager myInstallPhotoManager;
  
      @Resource
      WebServiceContext context;
  
  
      @WebMethod(operationName = "getMyInstallPhoto")
      @WebResult(name = "PhotoRetrievalResponse", partName = "PhotoRetrievalResponse")
      public MyInstallPhotoResponse getBadgePhoto(@WebParam(name = "BadgeNumber", partName = "BadgeNumber") String badgeNumber, @WebParam(name = "LastName", partName = "LastName") String lastName) {
          MyInstallPhotoResponse myInstallPhotoResponse = new MyInstallPhotoResponse();
          try {
              // more code here
          } catch (Exception e) {
            e.printStackTrace();
          }
          return myInstallPhotoResponse;
       }
  }
  </code></pre>
  
  <p>In the above code MyInstallPhotoResponse is defined in a xml schema. The SoapUI request generated something like this</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;rsw:getBadgePhoto&gt;
           &lt;!--Optional:--&gt;
           &lt;rsw:BadgeNumber&gt;I180748-003&lt;/rsw:BadgeNumber&gt;
           &lt;!--Optional:--&gt;
           &lt;rsw:LastName&gt;Jones&lt;/rsw:LastName&gt;
        &lt;/rsw:getBadgePhoto&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>How can make the BadgeNumber and LastName a required field as opposed to optional as per the soapui request. I tried to move the badgeNumber and lastName to a object myinstallphotorequest (defined in schema) and made the two parameters requried. this the soapui request I got.</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myin="http://www.lexisnexis.com/myInstallPhotoService" xmlns:myin1="http://www.lexisnexis.com/schema/myInstallPhotoServiceTypes"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;myin:getMyInstallPhoto&gt;
           &lt;!--Optional:--&gt;
           &lt;myin:MyInstallPhotoRequest&gt;
              &lt;myin1:badgeNumber&gt;?&lt;/myin1:badgeNumber&gt;
              &lt;myin1:lastName&gt;?&lt;/myin1:lastName&gt;
           &lt;/myin:MyInstallPhotoRequest&gt;
        &lt;/myin:getMyInstallPhoto&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Again I was not able to remove the Optional for the parameter "MyInstallPhotoRequest".</p>