title: Add SOAP header object using pure JAX-WS
body: <p>I'm trying to implement simple web service client for <em>PayPal Express Checkout API</em> using <strong>JAX WS</strong>. <em>PayPal Express Checkout API</em> provides <strong>WSDL</strong> file, from which I was able to generate Java classes using <em>CXF's wsdl2java</em> utility.</p>
  
  <p>From authentication reasons, it demands adding <strong>SOAP Header</strong> to each request. This header is quite simple and should look like here:
  <a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&amp;content_ID=developer/e_howto_api_ECSOAPAPIBasics#id09C3I0CF0O6" rel="nofollow noreferrer">https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&amp;content_ID=developer/e_howto_api_ECSOAPAPIBasics#id09C3I0CF0O6</a></p>
  
  <p>Generated from <strong>WSDL</strong> classes include <strong>ebay.apis.eblbasecomponents.CustomSecurityHeaderType</strong> class which represents header which I need to add to each request.</p>
  
  <p>So the question is: how can I add manually created instance of <strong>CustomSecurityHeaderType</strong> class to SOAP request's header taking into account following conditions:</p>
  
  <ol>
  <li>I'm not very eager to use classes from <strong>com.sun.*</strong> package as mentioned in answer here: <a href="https://stackoverflow.com/questions/2322953/jax-ws-adding-soap-headers">JAX-WS - Adding SOAP Headers</a> (mainly because of possible portability issues between different JDK's)</li>
  <li>I don't want to manually marshal that object into <em>nested</em> <strong>javax.xml.soap.SOAPElement</strong> instances as mentioned in answer here:
  <a href="https://stackoverflow.com/questions/830691/how-do-i-add-a-soap-header-using-java-jax-ws">How do I add a SOAP Header using Java JAX-WS</a></li>
  </ol>