title: Secure web service calls using WSS4J return "An error was discovered processing the <wsse:Security> header"
body: <p>I’m trying to add password digest WS-Security bits to web service calls from my client using WSS4J. I generated the client classes from the WSDL using Axis' WSDL4J and followed the instructions for adding WS-Security's "Password Digest" headers to the SOAP message using WSS4J, but  return with the error message, "An error was discovered processing the  header". Adding debug messages, it doesn’t look like my CallbackHandler is ever getting hit. Am I doing something very wrong? Or am I missing some setup piece that goes unexplained in the WSS4J documentation? </p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>class CSProvider {
      public CS get(CSService csService, URL url, String username)
              throws ServiceException {
          CS csPort = csService.getCSPort(url);
  
          ((Stub) csPort)._setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
          ((Stub) csPort)._setProperty(WSHandlerConstants.USER, username);
          ((Stub) csPort)._setProperty(UsernameToken.PASSWORD_TYPE, WSConstants.PW_DIGEST);
          ((Stub) csPort)._setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, "com.example.namespace.to.PasswordCallbackHandler");
  
          return csPort;   
      }
  }
  
  public class PasswordCallbackHandler implements CallbackHandler {
  
      @Override
      public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
          for (Callback callback : callbacks) {
              if (callback instanceof WSPasswordCallback) {
                  ((WSPasswordCallback) callback).setPassword(PasswordStore.getPassword());
              } else {
                  throw new UnsupportedCallbackException(callback);
              }
          }
      }
  }
  </code></pre>