title: Convert Soap XML response to Object
body: <p>i'm new to working with SOAP API's</p>
  
  <p>I have a soap response from an API</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soapenv:Body&gt;
  &lt;LoginResponse xmlns="http://test.org/ADMail_Service"&gt;
  &lt;LoginResult&gt;
  &lt;ErrorMessage&gt;Successful login&lt;/ErrorMessage&gt;
  &lt;Status&gt;true&lt;/Status&gt;
  &lt;/LoginResult&gt;
  &lt;/LoginResponse&gt;
  &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>I'm trying to transform this into an object.</p>
  
  <p>From reading articles online I'm trying to use JAXB to do this, but my object is empty. </p>
  
  <p>Here's the code for reading the response. I wrote the response to an xml file for test purposes:</p>
  
  <pre><code>try {
      XMLInputFactory xif = XMLInputFactory.newFactory();
      XMLStreamReader xsr = xif.createXMLStreamReader(new FileReader("input.xml"));
      xsr.nextTag(); // Advance to Envelope tag
  
      xsr.nextTag(); // Advance to Body tag
      xsr.nextTag();
      xsr.nextTag();
  
  
      JAXBContext jc = JAXBContext.newInstance(LoginResult.class);
      Unmarshaller unmarshaller = jc.createUnmarshaller();
      JAXBElement&lt;LoginResult&gt; je = unmarshaller.unmarshal(xsr, LoginResult.class);
  
      System.out.println(je.getName());
      System.out.println(je.getValue());
  } catch (XMLStreamException e) {
      e.printStackTrace();
  } catch (JAXBException e) {
      e.printStackTrace();
  } catch (FileNotFoundException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>The <code>LoginResult</code> class:</p>
  
  <pre><code>public class LoginResult {
      private String errorMessage;
      private String status;
  
      public String getErrorMessage() {
          return errorMessage;
      }
  
      public void setErrorMessage(String errorMessage) {
          this.errorMessage = errorMessage;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>