java spring ws:webServiceTemplate.marshalSendAndReceive发送前的签名文件

问题描述 投票:0回答:1

我正在尝试在发送文档请求之前对其进行签名,但是在检索请求文档时通过Document doc = soapMessage.getSOAPPart().getEnvelope().getOwnerDocument();并将其传递给sign方法,该方法将对其进行签名并更改带有签名节点的文档,我得到的响应是org.springframework.ws.soap.client.SoapFaultClientException: Validation failed with digest wrong.

但是,当我调试带有断点的代码时,在doWithMessage之前的任何一行中的方法certificationService.signDocument(doc, actionName, "Request", company);中设置了断点(在下面的代码段中将其替换为lambda表达式),我收到了正确的响应。

我是否缺少某些内容或内容,因为我在网络上找不到任何类似的问题。我被困在这里...

下面的代码段:

return webServiceTemplate.marshalSendAndReceive(
            config.getWebServiceUrl(),
            req,
            message -> {
                try {
                    SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
                    SOAPMessage soapMessage = saajSoapMessage.getSaajMessage();
                    Document doc = soapMessage.getSOAPPart().getEnvelope().getOwnerDocument();

                    saajSoapMessage.setSoapAction(SoapClientConfig.ACTION_BASE_URL + actionName);

                    certificationService.signDocument(doc, actionName, "Request", company);
                    soapMessage.saveChanges();

                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
java spring soap marshalling ws
1个回答
0
投票

问题已解决。我使用的是Java 12,我不知道为什么会出现此问题,但改用Java 8可以解决该问题。

© www.soinside.com 2019 - 2024. All rights reserved.