public void addToSOAPBody(org.apache.axis.Message msg, XRoadProtocolHeader xRoadProtocolHeader) {
    try {
      // get SOAP envelope from SOAP message
      org.apache.axis.message.SOAPEnvelope se = msg.getSOAPEnvelope();
      SOAPBody body = se.getBody();

      @SuppressWarnings("rawtypes")
      Iterator items = body.getChildElements();
      if (items.hasNext()) {
        body.removeContents();
      }

      SOAPBodyElement element =
          body.addBodyElement(
              se.createName(
                  getSendingOptionsResponseType.DEFAULT_RESPONSE_ELEMENT_NAME,
                  CommonStructures.NS_DHL_PREFIX,
                  CommonStructures.NS_DHL_URI));

      if (xRoadProtocolHeader.getProtocolVersion().equals(XRoadProtocolVersion.V2_0)) {
        SOAPElement elParing = element.addChildElement(se.createName("paring"));
        elParing.addTextNode(this.dataMd5Hash);
      }

      // X-road "keha" part in SOAP message
      SOAPElement elKeha = element.addChildElement(se.createName("keha"));
      elKeha.addAttribute(se.createName("href"), "cid:" + kehaHref);
    } catch (Exception ex) {
      CommonMethods.logError(ex, this.getClass().getName(), "addToSOAPBody");
    }
  }
  /**
   * Test that first signs, then encrypts a WS-Security envelope.
   *
   * <p>
   *
   * @throws Exception Thrown when there is any problem in signing, encryption, decryption, or
   *     verification
   */
  public void testEncryptedKeySignature() throws Exception {

    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    LOG.info("Before Sign/Encryption....");
    Document doc = unsignedEnvelope.getAsDocument();

    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);

    WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
    encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
    encrKey.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
    encrKey.setKeySize(192);
    encrKey.prepare(doc, crypto);

    WSSecEncrypt encrypt = new WSSecEncrypt();
    encrypt.setEncKeyId(encrKey.getId());
    encrypt.setEphemeralKey(encrKey.getEphemeralKey());
    encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
    encrypt.setEncryptSymmKey(false);
    encrypt.setEncryptedKeyElement(encrKey.getEncryptedKeyElement());

    WSSecSignature sign = new WSSecSignature();
    sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
    sign.setCustomTokenId(encrKey.getId());
    sign.setSecretKey(encrKey.getEphemeralKey());
    sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);

    Document signedDoc = sign.build(doc, crypto, secHeader);
    Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);

    if (LOG.isDebugEnabled()) {
      LOG.debug("Signed and encrypted message with IssuerSerial key identifier (both), 3DES:");
      String outputString =
          org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
      LOG.debug(outputString);
    }

    LOG.info("After Sign/Encryption....");
    verify(encryptedSignedDoc);
  }
 /**
  * Constructs a soap envelope
  *
  * <p>
  *
  * @return soap envelope
  * @throws java.lang.Exception if there is any problem constructing the soap envelope
  */
 protected SOAPEnvelope getSOAPEnvelope() throws Exception {
   InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
   Message msg = new Message(in);
   msg.setMessageContext(msgContext);
   return msg.getSOAPEnvelope();
 }