title: How can I send an abstract argument to a web service?
body: <p>I want to send an abstract object as an argument in a webservice method.</p>
  
  <p>These are my classes:
  The abstract class:</p>
  
  <pre><code>@XmlSeeAlso({Male.class, Female.class})
  
  public abstract class Person {
      public String name;
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getName() {
          return name;
      }
  }
  </code></pre>
  
  <p>The extending children:</p>
  
  <pre><code>@XmlRootElement(name = "person")
  public class Male extends Person {
  
  private boolean male;
  
  /**
   * @return the male
   */
  public boolean isMale() {
      return male;
  }
  
  /**
   * @param male the male to set
   */
  public void setMale(boolean male) {
      this.male = male;
  }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@XmlRootElement(name = "person")
  public class Female extends Person{
      private boolean female;
  
      /**
       * @return the female
       */
      public boolean isFemale() {
          return female;
      }
  
      /**
       * @param female the female to set
       */
      public void setFemale(boolean female) {
          this.female = female;
      }
  }
  </code></pre>
  
  <p>And this is my webservice Interface:</p>
  
  <pre><code>@WebService
  public interface wsTest {
      @WebMethod
      int getInt();
  
      @WebMethod
      String getString(String s);
  
      @WebMethod
      Map&lt;String, String&gt; getMap(Map&lt;String, String&gt; map);
  
      @WebMethod
      String getMaleStr(Male male);
  
      @WebMethod
      String getIsMale(@WebParam(name = "param")Person person);
  }
  </code></pre>
  
  <p>My problem is that I want to send to the webMethod: getIsMale an object of type Male but the soap message doesn't send it of type Male thus stripping off its "male" member as follows:</p>
  
  <p>The Request when sending:</p>
  
  <pre><code>Male male   = new Male();
  male.name   = "Avi";
  male.setMale(true);
  System.out.println("Calling: getIsMale...");
  System.out.println("Response is: " + ws.getIsMale(male));
  </code></pre>
  
  <p>Is as follows:</p>
  
  <pre><code>[?xml version="1.0" standalone="yes"?]
  [soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"]
    [soap:Body]
      [ns1:getIsMale xmlns:ns1="http://ws.xconnect.com/"]
        [ns1:param]
          [ns2:name xmlns:ns2="http://ws.xconnect.com"]Avi[/ns2:name]
        [/ns1:param]
      [/ns1:getIsMale]
    [/soap:Body]
  [/soap:Envelope]
  </code></pre>