title: JAXBException: class not known to the context in CXF JAX-WS client with anyType parameter call
body: <p>I get this exception when I try to call a .NET web service:</p>
  
  <pre><code> javax.xml.bind.JAXBException: class com.pixelware.mdv.tramites.TramiteXML nor any of its super class is known to this context.
  </code></pre>
  
  <p>The client is a Java library created with the CFX JAX-WS frontend (Classes precreated with WSDL)</p>
  
  <p>The method I'm trying to call accepts (nested in another object) an Object (anyType in the WSDL)</p>
  
  <p>Looks like the JAXB engine inside CXF is unable to marshall (serialize to XML) my class. That's because JAXB is unable to serialize a class if it is not registered in it's context and the class being passed it's part of the main program, not the client library.</p>
  
  <p>The CXF documentation shows a lot of configuration options, and it looks like it can be done adding  the property additionalContextClasses to the service properties. 
  I can't add this property by configuration because my client is a separated library with the CFX generated classes.</p>
  
  <p>I tried to add the property programmatically with this code:</p>
  
  <pre><code>Map&lt;String, Object&gt; ctx = (BindingProvider)ws.getWSSoap()).getRequestContext();
  ctx.put("jaxb.additionalContextClasses", new Class[] {TramiteXML.class});
  </code></pre>
  
  <p>But it doesn't work. Looks like maybe this configuration has to be done before creating the client.</p>
  
  <p>I've also found this <a href="http://cxf.547215.n5.nabble.com/Additional-JAXBContext-classes-via-JAX-WS-API-td569167.html" rel="nofollow">post</a>, whit the same (or very similar) problem, and the proposed solutions are far from easy.</p>
  
  <p>Shouldn't it be much more simple? Maybe I'm missing something.
  Any suggestions?</p>