The problem is solved. I had to fix the RampartSender class from the rampart-core_1.6.1.wso2v40 library.