Document doc = unsignedEnvelope.getAsDocument();
encrypt.setDocument(doc);
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
Document signedDoc = sign.build(doc, crypto, secHeader);
Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
/*
* convert the resulting document into a message first. The toAxisMessage()
* mehtod performs the necessary c14n call to properly set up the signed
* document and convert it into a SOAP message. After that we extract it
* as a document again for further processing.