title: How to access SOAP message elements?
body: <p>So i am trying to replace the values of username and password in the XML file containing a SOAP message. Here are the elements:</p>
  
  <pre><code> &lt;o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
          &lt;o:UsernameToken u:Id="uuid-68f84594-d592-470b-9bbc-b29f58b4756f-1"&gt;
              &lt;o:Username&gt;&lt;/o:Username&gt;
              &lt;o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;&lt;/o:Password&gt;
          &lt;/o:UsernameToken&gt;
      &lt;/o:Security&gt;
  </code></pre>
  
  <p>Basically, i want to take the username and password values from my config file, and place them in the username and password fields within the XML file containing the soap message. This is my attempt, and it throws a NPE at the docElement.getElementsByTagName lines:</p>
  
  <pre><code> public void updateUserDetails() {
      final Properties configProperties = new Properties();
      try {
          configProperties.load(new FileInputStream(PROPERTIES));
          final Document requestDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new FileInputStream(SOAP_REQUEST));
          final Element docElement = requestDoc.getDocumentElement();
          docElement.getElementsByTagName("Username").item(0).setTextContent(configProperties.getProperty("username"));
          docElement.getElementsByTagName("Password").item(0).setTextContent(configProperties.getProperty("password"));
      } catch(IOException | ParserConfigurationException | SAXException exception) {
          LOGGER.error("There was an error loading the properties file", exception);
      }
  }
  </code></pre>
  
  <p>Any help will be appreciated!</p>