title: How to generate a specific namespace for SOAP using Java client
body: <p>I'm fresh to SOAP in Java. I would like to create a client that generates a similar envelope to this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing"&gt;
     &lt;s:Header&gt;
        &lt;a:Action s:mustUnderstand="1"&gt;http://www.w3.org/2009/02/ws-tra/Create&lt;/a:Action&gt;
        &lt;h:ChannelIdentifier xmlns:h="http://my-web-site.org/my-trans/identifiers/1.0/" xmlns="http://my-web-site.org/my-trans/identifiers/1.0/"&gt;4&lt;/h:ChannelIdentifier&gt;
        &lt;h:DocumentIdentifier xmlns:h="http://my-web-site.org/my-trans/identifiers/1.0/" xmlns="http://my-web-site.org/my-trans/identifiers/1.0/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" scheme=""&gt;XXXXXX&lt;/h:DocumentIdentifier&gt;
        &lt;h:MessageIdentifier xmlns:h="http://my-web-site.org/my-trans/identifiers/1.0/" xmlns="http://my-web-site.org/my-trans/identifiers/1.0/"&gt;d8c314a3-6add-474c-871a-e0872612beeb&lt;/h:MessageIdentifier&gt;
        &lt;a:MessageID&gt;urn:uuid:856e3d41-92ef-4332-8a36-82d98b436fb4&lt;/a:MessageID&gt;
        &lt;a:ReplyTo&gt;
           &lt;a:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/a:Address&gt;
        &lt;/a:ReplyTo&gt;
        &lt;a:To s:mustUnderstand="1"&gt;https://XXX.com/AP1/ResourceService.svc&lt;/a:To&gt;
     &lt;/s:Header&gt;
     &lt;s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
        &lt;Create xmlns="http://www.w3.org/2009/02/ws-tra"&gt;
           &lt;message xmlns=""&gt;&amp;lt;AccessPoint.BO.Document&amp;gt;&amp;lt;![CDATA[Dummy Content]]&amp;gt;&amp;lt;/AccessPoint.BO.Document&amp;gt;&lt;/message&gt;
        &lt;/Create&gt;
     &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>The main challenge here is, how to generate these specific namespaces like <code>a:Action</code> or <code>s:Header</code>. Also how to add both xmlns and xml attributes in each one. I could hard code this but is there any standard to do this?</p>
  
  <p>I prefer using <code>javax.xml.soap.*</code> but if there are better library, please let me know.</p>