title: Unmarshaling a SOAP response in Go
body: <p>I am making a SOAP call to an API, Here is a sample response:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
   &lt;soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;soapenv:body&gt;
        &lt;soapenv:fault&gt;
          &lt;faultcode&gt;
            ERR109
          &lt;/faultcode&gt;
          &lt;faultstring&gt;
            Account Expired. Result code is 2163
          &lt;/faultstring&gt;
          &lt;detail&gt;
            &lt;ns1:serviceexception xmlns:ns1="http://www.csapi.org/schema/parlayx/common/v2_1"&gt;
              &lt;messageid&gt;
                ERR109
              &lt;/messageid&gt;
              &lt;text&gt;
                Account Expired. Result code is 2163
              &lt;/text&gt;
              &lt;variables&gt;
                2163
              &lt;/variables&gt;
            &lt;/ns1:serviceexception&gt;
          &lt;/detail&gt;
        &lt;/soapenv:fault&gt;
      &lt;/soapenv:body&gt;
    &lt;/soapenv:envelope&gt;
  </code></pre>
  
  <p>To unmarshal this response, I have built some structs:</p>
  
  <pre><code>type SoapResponse struct {
      Body    ResponseBody `soapenv:"body"`
  }
  type ResponseBody struct {
      Fault   Fault    `soapenv:"fault"`
  }
  type Fault struct {
      FaultCode   string `xml:"faultcode"`
      FaultString string `xml:"faultstring"`
      Detail      Detail `xml:"detail"`
  }
  type Detail struct {
      ServiceException ServiceException `ns1:"serviceexception"`
  }
  type ServiceException struct {
      ID          string `xml:"messageid"` 
      MessageText string `xml:"text"`
      ErrorCode   string `xml:"variables"`
  }
  </code></pre>
  
  <p>And here is the code that does the unmarshaling part:</p>
  
  <pre><code>responseBody, _:= ioutil.ReadAll(resp.Body)
  var soapResponse = new(SoapResponse)
  err := xml.Unmarshal(responseBody, soapResponse)
      if err != nil {
          panic("Error!")
      }
  </code></pre>
  
  <p>The problem is that all <code>soapResponse</code> properties are populated just right, except for <code>soapResponse.Body.Fault.Detail.ServiceException.ID</code> which prints nothing.<br>
  I couldn't figure out why. 
  Any help would be appreciated.</p>