text: Q:
  
  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. On the client side when I check the validity of the signature it says valid. Where I have digest of body section as "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. 
  Can anyone shed some light on this ? 
  Thanks 
  
  A:
  
  I was reading the SOAP msg from a file. There have been some non-UTF8 chars which got 
  included in to digest. 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. 
  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);
  
  