title: JAXB - Mapping SOAP to Java Classes
body: <p>I need help to mapping my Soap Envelope to java Classes, my intention manipulate the results to DB.</p>
  
  <p>I dont't have problems with get my SOAP Envelope or to work With DB, my problems is totaly with JABX and mapping my classes according my SOPA Envoloap.</p>
  
  <p>This is my SOAP:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soap:Header&gt;
        &lt;KD4SoapHeaderV2 xmlns="http://www.ibm.com/KD4Soap"&gt;A03ODA1YzhlZDQ2MWQAAQ==&lt;/KD4SoapHeaderV2&gt;
     &lt;/soap:Header&gt;
     &lt;soap:Body&gt;
        &lt;Response xmlns="http://tempuri.org/"&gt;
           &lt;Result xmlns:a="http://schemas.datacontract.org/2004/07/PS.SharedWebServices.Response" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
              &lt;a:Errors /&gt;
              &lt;a:Count&gt;329&lt;/a:Count&gt;
              &lt;a:Return&gt;SUCCESS&lt;/a:Return&gt;
              &lt;a:DashboardDTOs&gt;
                 &lt;a:DashboardDTOs&gt;
                    &lt;a:Value&gt;28.58&lt;/a:Value&gt;
                    &lt;a:Code&gt;O001&lt;/a:Code&gt;
                    &lt;a:Name&gt;Test2&lt;/a:Name&gt;
                 &lt;/a:DashboardDTOs&gt;
                 &lt;a:DashboardDTOs&gt;
                    &lt;a:Value&gt;40.22&lt;/a:Value&gt;
                    &lt;a:Code&gt;O002&lt;/a:Code&gt;
                    &lt;a:Name&gt;Test2&lt;/a:Name&gt;
                 &lt;/a:DashboardDTOs&gt;
                 &lt;a:DashboardDTOs&gt;
                    &lt;a:Value&gt;54.11&lt;/a:Value&gt;
                    &lt;a:Code&gt;O003&lt;/a:Code&gt;
                    &lt;a:Name&gt;Test3&lt;/a:Name&gt;
                 &lt;/a:DashboardDTOs&gt;
              &lt;/a:DashboardDTOs&gt;
           &lt;/Result&gt;
        &lt;/Response&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>This is my the Class with receive the main values (count, return and list of Dashboards DTO):</p>
  
  <pre><code>@XmlRootElement(name = "Response") 
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "Response", propOrder = { "Count",  "Return", "DashboardDTOs"})
  public class Result {
  
      @XmlElement(name="Count", required = true)
      private Integer Count;
  
      @XmlElement(name="Return", required = true)
      private String Return;
  
      @XmlElement(name = "DashboardDTOs")
      private List&lt;DashboardDTOs&gt; DashboardDTOs;
  
      ...
  </code></pre>
  
  <p>This is the second model that receives the DashboardDTO:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "DashboardDTOs", propOrder = {
          "Value",
          "Code",
          "Name"
      })
  public class DashboardDTOs {
  
      @XmlElement(name = "Value")
      private double Value;
  
      @XmlElement(name = "Code")
      private String Code;
  
      @XmlElement(name = "Name")
      private String Name;
  
      ...
  </code></pre>
  
  <p>And my app try to convert the SOAPEnvelope to a Result but I got error:</p>
  
  <pre><code>Unmarshaller unmarshaller = JAXBContext.newInstance(Result.class).createUnmarshaller();
  GetListSummarizedTransactionResultDTO returnValue = (Result)unmarshaller.unmarshal(soapMessagem.getSOAPBody().extractContentAsDocument());
  
  
  
  unexpected element (uri:"http://tempuri.org/", local:"Response"). Expected elements are &lt;{}Result&gt;
  </code></pre>
  
  <p>what I'm doing wrong?</p>
  
  <p>Thans</p>