I have found a solution. The thing was to use this bit of code for editing SOAP
SOAPFactory factory = SOAPFactory.newInstance();
SOAPElement signatureElement = factory.createElement("Signature");
signatureElement.addTextNode(signature);
firstChild.appendChild(signatureElement);
in stead of this:
Element element = firstChild.getOwnerDocument().createElement("Signature");
element.setNodeValue(signature);
firstChild.appendChild(element);
Apparently, the second version will work with appache-commons, but not with JBoss for some reason. Hope this helps someone.
Regards,
Branislav