title: Jax-WS interface as parameter
body: <p>try to use a interface as parameter for jax-ws web service
  Interface</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  
  @XmlRootElement
  @XmlJavaTypeAdapter(TransactionBase.TransactionableAdapter.class)
  public interface Transactionable {
  
  public int getRecid() ;
  public void setRecid(int recid) ;
  }
  </code></pre>
  
  <p>Implementation</p>
  
  <pre><code>import com.tr.route.transactions.Transactionable;
  @XmlRootElement 
  @XmlType(name = "Transactionable")
  public  class TransactionBase implements Transactionable{
  
      private int recid;
      private String ref;
      public TransactionBase(String type ) {
      System.out.println("TransactionBase.Constructor with param:" +       type);
       }
  
     public static TransactionBase valueOf(String allObject) {
      System.out.println("TransactionBase.valueOf:");
      TransactionBase rezult =  new TransactionBase(allObject);
      return rezult;
     }
      public int getRecid() {
          return recid;
      }
  
      public void setRecid(int recid) {
          this.recid = recid;
      }
      // adapter
    public static class TransactionableAdapter
      extends XmlAdapter&lt;TransactionBase, Transactionable&gt; {
  
      @Override
      public TransactionBase marshal(Transactionable o)
          throws Exception {
          System.out.println("TransactionableAdapter:mashal:");           
          return (TransactionBase)o;
      } 
  
      @Override
      public Transactionable unmarshal(TransactionBase o)
          throws Exception {
          System.out.println("TransactionableAdapter:unmashal:");
      return (Transactionable)o;
      }
      }
  }
  </code></pre>
  
  <p>Web service class</p>
  
  <pre><code>import javax.ws.rs.Consumes;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  @Path("/ExternalTransactions")
   public class ExternalTransactions {
  
  
  
  @POST 
  @Produces( MediaType.APPLICATION_XML)
  @Consumes(MediaType.APPLICATION_XML) 
  @Path("/insertTransaction") 
  
  @XmlElement(type=TransactionBase.class)
  public String insertTransaction(Transactionable insertRequest) {
  
      String insertResponse =  "method was called";
  
      return insertResponse;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Whatever I have done I get:</p>
  
  <pre><code>Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions Transactionable is an interface, and JAXB can't handle interfaces.
  </code></pre>
  
  <p>Please do not redirect me to:
  <a href="http://blog.bdoughan.com/2011/05/jaxb-and-interface-fronted-models.html" rel="nofollow">http://blog.bdoughan.com/2011/05/jaxb-and-interface-fronted-models.html</a></p>
  
  <p>Later Edit:</p>
  
  <p>I am using jersey implementation.</p>