title: How to register MessageBodyWriter and MessageBodyReader in Jersey 2.x
body: <p>I am implementing RESTful services using <code>jersey</code> api and I've come know that I need to register the custom xmlWriter and xmlReader. Client code implements MessageBodyWriter and I need to know ho0w to register it in server side because I am getting <code>MessageBodyProviderNotFoundException</code> for media type application/xml. </p>
  
  <p>MessageBodyWriter code</p>
  
  <pre><code>public class SendDocumentsServiceRequestXMLWriter extends BaseMessageBodyWriter implements MessageBodyWriter&lt;SendDocumentsRequest&gt; {
  
  public boolean isWriteable( Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType mediaType ) {
      return type == SendDocumentsRequest.class &amp;&amp; !mediaType.isWildcardType() 
              &amp;&amp; !mediaType.isWildcardSubtype() &amp;&amp; mediaType.isCompatible( MediaType.valueOf( "application/xml" ) );
  }
  
  public long getSize( SendDocumentsRequest t, Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType mediaType ) {
      return 0;
  }
  
  public void writeTo( SendDocumentsRequest t, Class&lt;?&gt; type, Type genericType, Annotation[] annotations, MediaType mediaType,
      MultivaluedMap&lt;String, Object&gt; httpHeaders, OutputStream entityStream ) throws IOException, WebApplicationException {
      try {
          ESignatureClientJAXBContextFactory.getMarshaller( SendDocumentsRequest.class ).marshal( t, entityStream );
      } catch (Exception e) {
          throw new ESignatureClientException( e );
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How can I register this class so that Jersey picks it up?</p>
  
  <p>Thanks</p>