我正在尝试在发送文档请求之前对其进行签名,但是当通过检索请求文档Document doc = soapMessage.getSOAPPart().getEnvelope().getOwnerDocument();
并将其传递给将对其进行签名并使用签名节点更改文档的签名方法时,我得到的响应是org.springframework.ws.soap.client.SoapFaultClientException: Validation failed with digest wrong.
但是,当我使用断点调试代码并doWithMessage
在之前的任何行中设置方法内部的断点(在下面的代码片段中将其替换为 lambda 表达式)时certificationService.signDocument(doc, actionName, "Request", company);
,我收到了正确的响应,正如预期的那样。
我错过了什么或什么,因为我在网上找不到任何类似的问题。我被困在这里...
片段代码如下:
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();
}
});