title: Spring WS Test MockWebServiceServer response created with `withSoapEnvelope` is empty
body: <p>I've want to test a SOAP client with a mocked server.</p>
  <p>If I use <code>mockServer.expect(soapEnvelope(request)).andRespond(withPayload(response))</code> all is working as expected.</p>
  <p>But what I want is to respond with a specific SOAP message which contains relevant information in SOAP header: <code>mockServer.expect(soapEnvelope(request)).andRespond(withSoapEnvelope(response))</code></p>
  <p>If I do so, the header and the body of the soap message are empty and therefore my test fails. Can anybody tell me what the problem is?</p>
  <pre class="lang-java prettyprint-override"><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = { MigekSoapZemisSearchConfiguration.class }, initializers = {
          ConfigFileApplicationContextInitializer.class })
  @DirtiesContext
  @ActiveProfiles(&quot;test&quot;)
  public class MigekSoapZemisSearchClientTest {
  
      @Autowired
      private ApplicationContext appContext;
  
      @Autowired
      private MigekSoapZemisSearchClient client;
  
      private MockWebServiceServer mockServer;
  
      @Before
      public void init() {
          mockServer = MockWebServiceServer.createServer(client);
      }
  
      @Test
      public void valid_xsd_request_response_test() throws IOException {
  
          Resource request = appContext.getResource(&quot;classpath:soap/soapRequest.xml&quot;);
          RequestMatcher rm = soapEnvelope(request);
  
          Resource response = appContext.getResource(&quot;classpath:soap/soapResponse.xml&quot;);
          ResponseCreator respce = withSoapEnvelope(response);
  
          mockServer.expect(rm).andRespond(respce);
          
          JAXBElement&lt;PersonType&gt; result = client.getPersonDetails(&quot;35db14e0-5237-435e-b2a6-02f1e75fa489&quot;);
          Assert.assertNotNull(result);
          Assert.assertEquals(result.getValue().getFirstName(), &quot;Marina&quot;);
  
          mockServer.verify();
      }
  
  }
  </code></pre>
  <p>soapResponse.xml:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;SOAP-ENV:Envelope
      xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
      &lt;SOAP-ENV:Header&gt;
          &lt;ns10:ResponseHeader
              xmlns:ns10=&quot;http://ejpd.admin.ch/bfm/zemis/header/types/v1&quot;
              xmlns=&quot;http://www.ech.ch/xmlns/eCH-0135/1&quot;&gt;
              &lt;ns10:MessageId&gt;35db14e0-5237-435e-b2a6-02f1e75fa489&lt;/ns10:MessageId&gt;
              &lt;ns10:Notice Severity=&quot;WARNING&quot;&gt;
                  &lt;ns10:Source&gt;getPersonDetails&lt;/ns10:Source&gt;
                  &lt;ns10:Code&gt;7&lt;/ns10:Code&gt;
                  &lt;ns10:Message&gt;Resultat beinhaltet aufgrund fehlender Berechtigung
                      nicht alle angeforderten Elemente(PersonType.ResidencePermit)
                  &lt;/ns10:Message&gt;
              &lt;/ns10:Notice&gt;
          &lt;/ns10:ResponseHeader&gt;
      &lt;/SOAP-ENV:Header&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;ns11:GetPersonDetailsResponse
              xmlns:ns11=&quot;http://ejpd.admin.ch/bfm/zemis/personsearchservice/types/v5&quot;&gt;
              &lt;ns11:zemisNumber&gt;1234567.0&lt;/ns11:zemisNumber&gt;
              &lt;ns11:firstName&gt;Peter&lt;/ns11:firstName&gt;
              &lt;ns11:lastName&gt;Muster&lt;/ns11:lastName&gt;
              &lt;ns11:gender&gt;2&lt;/ns11:gender&gt;
          &lt;/ns11:GetPersonDetailsResponse&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>