title: android webservice response "parse xml to pojo exception"
body: <p>I am trying to access soap webservices in android. </p>
  
  <pre><code>        AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
          ...
          ...
          String result = (String) httpTransport.responseDump;
  </code></pre>
  
  <p>I got the response <strong>result</strong> string as xml format given below,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
          &lt;soapenv:Body&gt;
              &lt;sampleResponse xmlns="http://impl.test.com"&gt;
                  &lt;sampleReturn&gt;
                      &lt;clientNameList&gt;
                          &lt;clientNameList&gt;
                              &lt;clientID&gt;1&lt;/clientID&gt;
                          &lt;/clientNameList&gt;
                          &lt;clientNameList&gt;
                              &lt;clientID&gt;2&lt;/clientID&gt;
                          &lt;/clientNameList&gt;
                      &lt;/clientNameList&gt;
                      &lt;message&gt;SUCCESS&lt;/message&gt;
                  &lt;/sampleReturn&gt;
              &lt;/sampleResponse&gt;
          &lt;/soapenv:Body&gt;
      &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Parsing this xml into Pojo using Simple XML Serialization(simple-xml-2.6.6.jar). <strong>Ref:</strong> <a href="http://simple.sourceforge.net/download/stream/doc/examples/examples.php" rel="nofollow noreferrer">here</a></p>
  
  <pre><code>        Persister persister = new Persister();
          UserResponse userResponse = persister.read(UserResponse.class, result);
  </code></pre>
  
  <p>Now I got the exception as </p>
  
  <pre><code>Element 'Body' does not have a match in class com.test.UserResponse at line 1
  </code></pre>
  
  <p>For more code information <a href="https://stackoverflow.com/questions/12066666/android-ksoap2-complex-typerequest-and-response">here</a></p>
  
  <p>How can I fix this?</p>
  
  <p>UserResponse.java(POJO class)</p>
  
  <pre><code>public class UserResponse {
  
  private String message = null;
  
  private Client[] clientNameList = null;
  
  public String getMessage() {
          return message;
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  
  public void setClientNameList(Client[] clientNameList) {
          this.clientNameList = clientNameList;
      }
  
      public Client[] getClientNameList() {
          return clientNameList;
      }
  }
  </code></pre>
  
  <p>and Client.java</p>
  
  <pre><code>public class Client {
  
  private int clientID;
  
  public void setClientID(int clientID) {
          this.clientID = clientID;
      }
  
      public int getClientID() {
          return clientID;
      }
  }
  </code></pre>