简体   繁体   English

CXF Web服务(Java)中的预期摘要和实际摘要之间的差异

[英]Difference between Expected digest and Actual digest in CXF web service (Java)

16:56:06,477 DEBUG DOMReference:398 - Expected digest: 3BXXHthnTP9kC1YB6FPUrpnO72wNuPmWerwglakCGiY=
16:56:06,477 DEBUG DOMReference:399 - Actual digest: hesLZ/G8ekBPdFNGrxIJmxSYhhMC/BBHD6x/pHqXJt4=
16:56:06,477 DEBUG DOMXMLSignature:276 - Reference[#Body] is valid: false 

I have a web service done in CXF and I have done a client just by using javax.xml.crypto package utilities. 我在CXF中完成了一个Web服务,并且仅使用javax.xml.crypto包实用程序就完成了一个客户端。 On the client side when I check the validity of the signature it says valid. 在客户端,当我检查签名的有效性时,它表示有效。 Where I have digest of body section as "3BXXHthnTP9kC1YB6FPUrpnO72wNuPmWerwglakCGiY=". 我在其中的正文部分的摘要为“ 3BXXHthnTP9kC1YB6FPUrpnO72wNuPmWerwglakCGiY =“。

Then generated SOAP message is being sent and at the web service side it says actual digest is something else but not what I got in client side. 然后发送生成的SOAP消息,并在Web服务端说实际的摘要是其他内容,而不是我在客户端获得的内容。

Can anyone shed some light on this ? 谁能对此有所启发? Thanks 谢谢

I was reading the SOAP msg from a file. 我正在从文件中读取SOAP消息。 There have been some non-UTF8 chars which got included in to digest. 有一些非UTF8字符包含在内以进行摘要。 However I was canonicalizating before digest which should fix this kind of issues. 但是,我在摘要之前进行了规范化,应该可以解决此类问题。 Code modified to read only UTF-8 data and that fixed the issue. 修改代码以仅读取UTF-8数据,从而解决了该问题。

File attachmentFile = new File("soap_sample.xml");
    FileInputStream fis = new FileInputStream(attachmentFile);
    InputStreamReader isr = new InputStreamReader(fis, "UTF8");
    BufferedReader in = new BufferedReader(isr);

    StringBuffer buffer = new StringBuffer();

    String inputLine = null;
    while ((inputLine = in.readLine()) != null) {
        buffer.append(inputLine);
    }

    InputStream is = IOUtils.toInputStream(buffer.toString(), "UTF-8");

    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(new MimeHeaders(), is);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM