title: How do you add XML prolog in javax.xml.soap.SOAPBody
body: <p>I am trying to send an XML document via SOAP to a server that requires the payload XML to contain an XML prolog e.g., <code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;</code>.  The following is very similar to the code I'm using:</p>
  
  <pre><code>SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
  SOAPPart soapPart = getSoapMessage().getSOAPPart();
  SOAPEnvelope envelope = soapPart.getEnvelope();
  envelope.addNamespaceDeclaration("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
  soapHeader = envelope.getHeader();
  soapBody = envelope.getBody();
  
  soapHeader.detachNode();
  SOAPBodyElement bodyElement = soapBody.addBodyElement(getEnvelope().createName("my_element_name"));
  bodyElement.addAttribute(getEnvelope().createName("my_attribute_name"), "my_attribute_value");
  bodyElement.addChildElement("my_child_element");
  ...
  </code></pre>