code: public static byte[] getSoapMessageAsByte(String version,
              List headerBlocks, Element body, String encoding) throws Exception {
          Document message = createSoapMessage(version, headerBlocks, body);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
  
          TransformerFactory tf = TransformerFactory.newInstance();
            // Fortify Mod: prevent external entity injection
          tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
          Transformer t = tf.newTransformer();
  		// End Fortify Mod
          t.setOutputProperty(OutputKeys.ENCODING, encoding);
          t.transform(new DOMSource(message), new StreamResult(baos));
  
          // System.out.println("SOAP MESSAGE : " + baos.toString());
  
          return baos.toByteArray();
      }
docs: A method to create a SOAP message and retrieve it as byte.
  
  @param version
  the SOAP version to be used (1.1 or 1.2).
  @param headerBlocks
  the list of Header Blocks to be included in the SOAP Header .
  @param body
  the XML message to be included in the SOAP BODY element.
  @param encoding
  the encoding to be used for the message creation.
  
  @return The created SOAP message as byte.
  
  @author Simone Gianfranceschi