title: Create a SOAP POST in JAVA
body: <p>I am pretty new to SOAP and i am struggling to create a SOAP POST request to a server . I have the following sample request:-</p>
  
  <pre><code>POST /sso/ArtifactResolver/metaAlias/assert-idp
  HTTP/1.1
  Host:xxx
  Content-Type: text/xml
  Content-Length: 
  SOAPAction:http://....
  </code></pre>
  
  <p>and here is my SOAP Envevelop</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;SOAP-ENV:Body&gt;
  &lt;samlp:ArtifactResolve
  xmlns:samlp="xxxxxxxxxxxxxx"
  xmlns="xxxxxxxxxxx"
  ID="_6c3a4f8b9c2d"
  25 March 2014 Page 30
  (APPROVED – Version 1.1)
  Version="2.0"
  IssueInstant="2012-05-21T00:39:45Z"&gt;
  &lt;Issuer&gt;https://www.xxxxxxxxxxxxxx&lt;/Issuer&gt;
  &lt;Artifact&gt;
  AAQAABWFTOPhANZhf21nl9DmXsAkiSM0ocx7GdxUfXFttmS954 BP6Vb01I0=
  &lt;/Artifact&gt;
  &lt;/samlp:ArtifactResolve&gt;
  &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>Below is my java code i am trying to use:-</p>
  
  <pre><code>    MessageFactory factory = MessageFactory.newInstance();
      SOAPMessage soapMsg = factory.createMessage();
      SOAPPart part = soapMsg.getSOAPPart();
      SOAPEnvelope envelope = part.getEnvelope();
      SOAPHeader header = envelope.getHeader();
      SOAPBody body = envelope.getBody();
  
  
      SOAPBodyElement element = body.addBodyElement(envelope.createName("ArtifactResolve", "sampl", "xxxxxxxxxxxx"));
      element.addChildElement("Issuer").addTextNode("xxxxxxxxxxx");
      element.addChildElement("Artifact").addTextNode("xxxxxxxxxxxx");
      element.setAttribute("xmlns", "xxxxxxxxxxxxx");
      element.setAttribute("ID", "xxxxxxxxx");
      element.setAttribute("Version", "2.0");
      element.setAttribute("IssueInstant", "xxxxxxxxxx"); 
  
   PostMethod post = new PostMethod("PUT Server Url");
              // Request content will be retrieved directly from the input stream
  
              post.setRequestEntity(entity);
              // consult documentation for your web service
              post.setRequestHeader("SOAPAction", "**what to put here????**");
              // Get HTTP client
              HttpClient httpclient = new HttpClient();
  
              try {
                  int result = httpclient.executeMethod(post);
                  System.out.println(post.getResponseBodyAsString());
              } finally {
                  // Release current connection to the connection pool once you are done
                  post.releaseConnection();
              }
  </code></pre>
  
  <p>Now in the above code where to specify the Server url? 
  Second is how to pass complete soap XML to post request?
  How to pass the top POST data which is given?
  What to give for soap action.?</p>
  
  <p>Sorry for this guys buy i am completely new to this so no idea. 
  I tried looking for this over the internet but no help.</p>
  
  <p>Please help me out over here</p>
  
  <p>Thanks ...</p>