title: Spring Web service unmarshalling not happening correctly
body: <p>I have been trying to integrate the spring WS to test a SOAP webservice.Integration has hit a roadblock as I am not able receive the proper response in the unmarshelled object.
  Below are the details:</p>
  
  <p>Application Context is below:</p>
  
  <pre><code> &lt;!-- Define the SOAP version used by the WSDL --&gt;
  &lt;bean id="soapMessageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"&gt;
      &lt;property name="soapVersion"&gt;
          &lt;util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12"/&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;!-- The location of the generated Java files --&gt;
  &lt;oxm:jaxb2-marshaller id="marshaller" contextPath="com.uk.fs.generatedsources"/&gt;
  
  &lt;!-- Configure Spring Web Services --&gt;
  &lt;bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"&gt;
      &lt;constructor-arg ref="soapMessageFactory"/&gt;
      &lt;property name="marshaller" ref="marshaller"/&gt;
      &lt;property name="unmarshaller" ref="marshaller"/&gt;
      &lt;property name="defaultUri" value="http://192.168.243.21/test/services/testservice?wsdl"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Below is the method which invokes marshalSendAndReceive:</p>
  
  <pre><code>  public List&lt;FSChild&gt; getFSChildren() {
      GetFSChildren getFSChildren= new ObjectFactory().createGetFSChildren();
      getFSChildren.setCountry("CA");
      getFSChildren.setFsCode("5010");
      getFSChildren.setLimit(6);
      GetFSChildrenResponse response = (GetFSChildrenResponse) webServiceTemplate.marshalSendAndReceive(
              getFSChildren);
  
      return response.getGetFSChildrenReturn();
  }
  </code></pre>
  
  <p>Class GetFSChildrenResponse is as below:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
  "getHSChildrenReturn"
  })
  @XmlRootElement(name = "getFSChildrenResponse")
  public class GetFSChildrenResponse {
  
  @XmlElement(required = true)
  protected List&lt;FSChild&gt; getFSChildrenReturn;
  
  public List&lt;FSChild&gt; getGetFSChildrenReturn() {
      if (getFSChildrenReturn == null) {
          getFSChildrenReturn = new ArrayList&lt;FSChild&gt;();
      }
      return this.getFSChildrenReturn;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>class FSChild is as below:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "FSChild", namespace = "http://hs.uk.com", propOrder = {
  "description",
  "fsCode"
  })
  public class FSChild {
  @XmlElement(required = true, nillable = true)
  protected String description;
  @XmlElement(required = true, nillable = true)
  protected String fsCode;
  
  public String getDescription() {
      return description;
  }
  public void setDescription(String value) {
      this.description = value;
  }
  public String getFsCode() {
      return hsCode;
  }
  public void setFsCode(String value) {
      this.hsCode = value;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I feel like quite close to get it working..
  Request is properly marshalled and even request is sent properly to webservice which logs the response and returns it properly.
  but when try to extract the response like below:</p>
  
  <pre><code>GetFSChildrenResponse response = (GetFSChildrenResponse) webServiceTemplate.marshalSendAndReceive( getFSChildren);
  </code></pre>
  
  <p>now at this point when I debug,I find that response object is populated and it contains 1 <code>getHSChildrenReturn</code> list containing one item which was expected but code and description in fschild is set to null.</p>
  
  <p>I have even turned on TRACE logs for messages.I see response xml properly returning data which is as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/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;getHSChildrenResponse xmlns="http://service.hs.pb.com"&gt;
              &lt;getHSChildrenReturn&gt;
                  &lt;description&gt;Silk: Silk-worm cocoons suitable for reeling.&lt;/description&gt;
                  &lt;fsCode&gt;5001000000&lt;/hsCode&gt;
              &lt;/getFSChildrenReturn&gt;
          &lt;/getFSChildrenResponse&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Please find below the wsdl from which classes were generated:</p>
  
  <pre><code>&lt;wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap"           xmlns:impl="http://service.fs.uk.com" xmlns:intf="http://service.fs.uk.com"    xmlns:tns1="http://fs.uk.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"   xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.fs.uk.com"&gt;
  
  
      &lt;!--
  WSDL created by Apache Axis version: 1.4
  Built on Apr 22, 2006 (06:55:48 PDT)
  --&gt;
  &lt;wsdl:types&gt;
  &lt;schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://service.fs.uk.com"&gt;
  &lt;import namespace="http://fs.uk.com"/&gt;
  &lt;element name="getCountries"&gt;
  &lt;complexType/&gt;
  &lt;/element&gt;
  &lt;element name="getCountriesResponse"&gt;
  &lt;complexType&gt;
  &lt;sequence&gt;
  &lt;element maxOccurs="unbounded" name="getCountriesReturn" type="xsd:string"/&gt;
  &lt;/sequence&gt;
  &lt;/complexType&gt;
  &lt;/element&gt;
  &lt;element name="getFSChildren"&gt;
  &lt;complexType&gt;
  &lt;sequence&gt;
  &lt;element name="fsCode" type="xsd:string"/&gt;
  &lt;element name="country" type="xsd:string"/&gt;
  &lt;element name="limit" type="xsd:int"/&gt;
  &lt;/sequence&gt;
  &lt;/complexType&gt;
  &lt;/element&gt;
  &lt;element name="getFSChildrenResponse"&gt;
  &lt;complexType&gt;
  &lt;sequence&gt;
  &lt;element maxOccurs="unbounded" name="getFSChildrenReturn" type="tns1:FSChild"/&gt;
  &lt;/sequence&gt;
  &lt;/complexType&gt;
  &lt;/element&gt;
  &lt;/schema&gt;
  &lt;schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://fs.uk.com"&gt;
  &lt;complexType name="FSChild"&gt;
  &lt;sequence&gt;
  &lt;element name="description" nillable="true" type="xsd:string"/&gt;
  &lt;element name="fsCode" nillable="true" type="xsd:string"/&gt;
  &lt;/sequence&gt;
  &lt;/complexType&gt;
  &lt;/schema&gt;
  &lt;/wsdl:types&gt;
  &lt;wsdl:message name="getCountriesResponse"&gt;
  &lt;wsdl:part element="impl:getCountriesResponse" name="parameters"&gt;&lt;/wsdl:part&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="getCountriesRequest"&gt;
  &lt;wsdl:part element="impl:getCountries" name="parameters"&gt;&lt;/wsdl:part&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="getFSChildrenRequest"&gt;
  &lt;wsdl:part element="impl:getFSChildren" name="parameters"&gt;&lt;/wsdl:part&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="getFSChildrenResponse"&gt;
  &lt;wsdl:part element="impl:getFSChildrenResponse" name="parameters"&gt;&lt;/wsdl:part&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:portType name="FSService"&gt;
  &lt;wsdl:operation name="getCountries"&gt;
  &lt;wsdl:input message="impl:getCountriesRequest" name="getCountriesRequest"&gt;&lt;/wsdl:input&gt;
  &lt;wsdl:output message="impl:getCountriesResponse" name="getCountriesResponse"&gt;&lt;/wsdl:output&gt;
  &lt;/wsdl:operation&gt;
  &lt;wsdl:operation name="getFSChildren"&gt;
  &lt;wsdl:input message="impl:getFSChildrenRequest" name="getFSChildrenRequest"&gt;&lt;/wsdl:input&gt;
  &lt;wsdl:output message="impl:getFSChildrenResponse" name="getFSChildrenResponse"&gt;&lt;/wsdl:output&gt;
  &lt;/wsdl:operation&gt;
  &lt;/wsdl:portType&gt;
  &lt;wsdl:binding name="FSServiceSoapBinding" type="impl:FSService"&gt;
  &lt;wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
  &lt;wsdl:operation name="getCountries"&gt;
  &lt;wsdlsoap:operation soapAction=""/&gt;
  &lt;wsdl:input name="getCountriesRequest"&gt;
  &lt;wsdlsoap:body use="literal"/&gt;
  &lt;/wsdl:input&gt;
  &lt;wsdl:output name="getCountriesResponse"&gt;
  &lt;wsdlsoap:body use="literal"/&gt;
  &lt;/wsdl:output&gt;
  &lt;/wsdl:operation&gt;
  &lt;wsdl:operation name="getFSChildren"&gt;
  &lt;wsdlsoap:operation soapAction=""/&gt;
  &lt;wsdl:input name="getFSChildrenRequest"&gt;
  &lt;wsdlsoap:body use="literal"/&gt;
  &lt;/wsdl:input&gt;
  &lt;wsdl:output name="getFSChildrenResponse"&gt;
  &lt;wsdlsoap:body use="literal"/&gt;
  &lt;/wsdl:output&gt;
  &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  &lt;wsdl:service name="testserviceService"&gt;
  &lt;wsdl:port binding="impl:FSServiceSoapBinding" name="testservice"&gt;
  &lt;wsdlsoap:address location="http://192.168.240.87/FSWS/testservice/FSService"/&gt;
  &lt;/wsdl:port&gt;
  &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>