title: SoapFaultClientException: username and/or/password cannot be null
body: <p>I have build a client, that should fetch data from a remote, wsdl-based webservice (using SOAP).</p>
  
  <p>But everytime I try to connect (with a call of a function) with the service I get the following exception:</p>
  
  <pre><code>org.springframework.ws.soap.client.SoapFaultClientException: Username and/or Password cannot be null
      at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38) ~[spring-ws-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]
      at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:826) ~[spring-ws-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]
      at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:621) ~[spring-ws-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]
      at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555) ~[spring-ws-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]
      at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390) ~[spring-ws-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]
      at com.test.adminUI.myPartners.client.MyPartnersServiceClient.sendSoapRequest(MyPartnersServiceClient.java:113) [bin/:na]
      at com.test.adminUI.myPartners.client.MyPartnersServiceClient.findUser(PartnersServiceClient.java:70) [bin/:na]...
  </code></pre>
  
  <p>If I put a wrong password for example, the service registered it, an throws a <strong>Unauthorized 401 ERROR</strong>
  So that mean, it actually validates my useraccount details.</p>
  
  <p>my client:</p>
  
  <pre><code>public class MyServiceClient  extends WebServiceGatewaySupport {
  
      @Autowired
      private ObjectFactory factory;
      @Autowired
      private SoapProperties adProperties;
  
      private static final String WS_ADDRESSING_URI = "http://www.w3.org/2005/08/addressing";
      private static final String TO_TAG = "To";
      private static final String ACTION_TAG = "Action";
      private static final String WSA_PREFIX = "wsa";
  
      private static final String SOAP_ACTION_FIND_IFXPERSON = adProperties.getsoapURL();
  
  
      public List&lt;Person&gt; findUser(String email, String globalID) {
          List&lt;Person&gt; list = null;
          FindPerson findperson = new FindPerson();
          try {
              findperson.setGlobalID(factory.createGlobalID(globalID));
  
              findperson.setServiceUsername(factory.createServiceUsername(adProperties.getServiceUser()));
              findperson.setServicePassword(factory.createServicePassword(adProperties.getServicePassword()));
  
  
              FindPersonResponse response = (FindPersonResponse) sendSoapRequest(
                      SOAP_ACTION_FIND_PERSON, findperson);
  
              list = response.getFindPersonResult().getValue();
          } catch (Exception ex) {
              log.error("could not find Person: ", ex);
          }
  
          return null;
      }
  
  
      private Object sendSoapRequest(final String soapAction, Object payLoad) {
  
          Object response = null;
  
          try {
              Credentials auth = new NTCredentials(adProperties.getAuthUser(),
                      adProperties.getAuthPassword(), null, adProperties.getAuthDomain());
  
              HttpClientBuilder clientBuilder = HttpClientBuilder.create();
  
              CredentialsProvider credsProvider = new BasicCredentialsProvider();
              credsProvider.setCredentials(AuthScope.ANY, auth);
              clientBuilder.setDefaultCredentialsProvider(credsProvider);
  
              RemoveSoapHeadersInterceptor interceptor = new RemoveSoapHeadersInterceptor();
              clientBuilder.addInterceptorFirst(interceptor);
  
              HttpClient httpClient = clientBuilder.build();
  
              HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender();
              messageSender.setHttpClient(httpClient);
              messageSender.setCredentials(auth);
              messageSender.afterPropertiesSet();
  
              getWebServiceTemplate().setMessageSender(messageSender);
              SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(
                      MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL));
              getWebServiceTemplate().setMessageFactory(messageFactory);
  
              response = getWebServiceTemplate().marshalSendAndReceive(
                      adProperties.getServiceEndpoint(), payLoad, new SoapActionCallback(soapAction) {
  
                          public void doWithMessage(WebServiceMessage message) {
                              try {
                                  SaajSoapMessage soapMessage = (SaajSoapMessage) message;
                                  SOAPMessage saajMessage = soapMessage.getSaajMessage();
  
                                  SOAPEnvelope envelope = saajMessage.getSOAPPart().getEnvelope();
                                  SOAPHeader header = envelope.getHeader();
  
                                  QName wsaToQName = new QName(WS_ADDRESSING_URI, TO_TAG, WSA_PREFIX);
                                  SOAPHeaderElement wsaTo = header.addHeaderElement(wsaToQName);
                                  wsaTo.setTextContent(adProperties.getServiceEndpoint());
  
                                  QName wsaActionQName = new QName(WS_ADDRESSING_URI, ACTION_TAG,
                                          WSA_PREFIX);
                                  SOAPHeaderElement wsaAction = header
                                          .addHeaderElement(wsaActionQName);
                                  wsaAction.setTextContent(soapAction);
  
                              } catch (Exception e) {
                                  log.error("", e);
                              }
                          }
                      });
          } catch (Exception ex) {
              log.error(ex);
          }
          return response;
      }
  }
  </code></pre>
  
  <p>Configuration:</p>
  
  <pre><code>@Configuration
  public class MyPartnersServiceConfiguration {
  
      @Bean
      public Jaxb2Marshaller marshaller() {
          Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
          marshaller.setPackagesToScan("com.test.adminUI.myPartners.wsdl");
          return marshaller;
      }
  
      @Bean
      public IFXPartnersServiceClient iFXPartnersServiceClient(Jaxb2Marshaller marshaller) {
          IFXPartnersServiceClient client = new IFXPartnersServiceClient();
          client.setDefaultUri("http://test.idms.partnersservice");
          client.setMarshaller(marshaller);
          client.setUnmarshaller(marshaller);
          return client;
      }
  
  }
  </code></pre>
  
  <p>Does anybody know what i have to do? </p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I forgot to mention, that I also get a warning in my console: </p>
  
  <pre><code> o.a.http.impl.auth.HttpAuthenticator: NEGOTIATE authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt))
  </code></pre>
  
  <p>Is this the problem? What do I have to do in this case?</p>