title: Creating and sending SOAP message in Java
body: <p>How do I create a Soap message/envelope with the following content in Java and send it.</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cat="http://www.someurl.com/Catalogue/"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;cat:GetRecordByField&gt;
           &lt;!--Optional:--&gt;
           &lt;cat:fieldName&gt;Image&lt;/cat:fieldName&gt;
           &lt;!--Optional:--&gt;
           &lt;cat:value&gt;10076GB.jpg&lt;/cat:value&gt;
        &lt;/cat:GetRecordByField&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>I have checked above message with SOAPUI and getting the correct response and now need to use JAVA to retrieve and process the response.</p>
  
  <p>Update:</p>
  
  <p>I have managed to generate following message, however it is not in the same format and is not acceptable.</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;cat:GetRecordByField xmlns:cat="http://quoteCompany.com"&gt;
              &lt;cat:fieldName xmlns:cat="something"&gt;Image&lt;/cat:fieldName&gt;
              &lt;cat:value xmlns:cat="something1"&gt;10076GB.jpg&lt;/cat:value&gt;
          &lt;/cat:GetRecordByField&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>I followed this tutorial: <a href="http://www.java2s.com/Code/Java/JDK-6/SendingaSOAPMessage.htm" rel="nofollow">http://www.java2s.com/Code/Java/JDK-6/SendingaSOAPMessage.htm</a></p>