title: How to include empty xml elements in SOAP request using WCF?
body: <p>I have to consume a <code>Java</code> web service. The signature of service method is</p>
  
  <pre><code>public bool UpsertEmployee(Employee employe);
  </code></pre>
  
  <p>The problem is when the <code>SOAP</code> is generated, for the properties with null value the coresponding <code>XML</code> elements are not included in request. The result is:</p>
  
  <pre><code>...
  &lt;Employee&gt;
    &lt;id&gt;1&lt;/id&gt;
    &lt;firstName&gt;Jhonny&lt;/firstName&gt;
  &lt;/Employee&gt;
  </code></pre>
  
  <p>And I want to be:</p>
  
  <pre><code>...
  &lt;Employee&gt;
    &lt;id&gt;1&lt;/id&gt;
    &lt;firstName&gt;Jhonny&lt;/firstName&gt;
    &lt;lastName/&gt;
  &lt;/Employee&gt;
  </code></pre>
  
  <p>Is there a way to accomplish this?</p>
  
  <p>Can I set a property before mehod invocation?</p>
  
  <pre><code>var client= new EmployeeServiceClient();;
  // Can I do something here to accoplish my goal?    
  client.UpsertEmployee(new Employee{
      id = "1",
      firstname = "Jhonny"
  });
  </code></pre>
  
  <p>The generated <code>Employee</code> class code is</p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.36366")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:mve.go.all.mdg.vendor")]
  public partial class Employee : object, System.ComponentModel.INotifyPropertyChanged
  {
  
      private string idField;
  
      private string firstNameField;
  
      private string lastNameField;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)]
      public string id
      {
          get
          {
              return this.idField;
          }
          set
          {
              this.idField = value;
              this.RaisePropertyChanged("id");
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
      public string firstName
      {
          get
          {
              return this.firstNameField;
          }
          set
          {
              this.firstNameField = value;
              this.RaisePropertyChanged("firstName");
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 3)]
      public string lastName
      {
          get
          {
              return this.lastNameField;
          }
          set
          {
              this.lastNameField = value;
              this.RaisePropertyChanged("lastName");
          }
      }
  
      public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
  
      protected void RaisePropertyChanged(string propertyName)
      {
          System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
          if ((propertyChanged != null))
          {
              propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>
  
  <p>I cannot modify the file code because in the future it is posible to need an update on the service reference.</p>