Maybe this is now the best solution, but it works.
It seems setting UTF-8 to message it's not enough. So, I'm encoding the SAAJ Message before doing the signature.
Something like this.
Code:
Object result = wst.marshalSendAndReceive(input,
new WebServiceMessageCallback() {
public void doWithMessage(WebServiceMessage message) throws IOException {
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
SaajSoapMessage wsm = null;
// UTF-8 encoding
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
message.writeTo(os);
StringBuilder sm = new StringBuilder(os.toString());
os.close();
ByteArrayInputStream is = new ByteArrayInputStream(sm.toString().getBytes("UTF-8"));
wsm = (SaajSoapMessage)getWebServiceTemplate().getMessageFactory().createWebServiceMessage(is);
saajSoapMessage.setSaajMessage(wsm.getSaajMessage());
is.close();
} catch (Exception e) {
e.printStackTrace();
}
SOAPMessage saajMessage = saajSoapMessage.getSaajMessage();
try {
ProcessingContext context = new ProcessingContext();
context.setSOAPMessage(saajMessage);
SOAPMessage securedMessage = cprocessor.secureOutboundMessage(context);
saajSoapMessage.setSaajMessage(securedMessage);
} catch (XWSSecurityException e) {
throw new XwsSecuritySecurementException(e.getMessage());
}
}
});