title: Cannot create envelope from given source
body: <p>I am trying to consume a SOAP based web service with the class <em>org.springframework.ws.client.core.WebServiceTemplate</em> of Spring WS 2.2.2 release, like this:</p>
  
  <pre><code>webServiceTemplate.setDefaultUri(uri);
  webServiceTemplate.setMessageSender(new SOAPMessageSenderWithAuth());
  res = (RESPONSE) webServiceTemplate.marshalSendAndReceive(request);
  </code></pre>
  
  <p>The request is built with a class that has been generated from WSDL-files of the web service.</p>
  
  <p>The webservice has been successfully tested with SOAP UI, but when accessing it with Java the Exception "<strong><em>SoapMessageCreationException: Could not create message from InputStream: Unable to create envelope from given source (SAAJ0511)</em></strong>" and "<strong><em>Unable to create envelope from given source because the root element is not named 'Envelope' (SAAJ0514)</em></strong>" is thrown.</p>
  
  <p>Does anyone have any advice for this exception?</p>
  
  <p>Thanks in advance!</p>
  
  <p>The Spring bean for <em>webServiceTemplate</em> is defined as following:</p>
  
  <pre><code>&lt;bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"
      p:marshaller-ref="jaxbMarshaller"
      p:unmarshaller-ref="jaxbMarshaller"
      p:defaultUri="..."&gt;
      &lt;constructor-arg ref="messageFactory"/&gt;
          &lt;property name="messageSender"&gt;
            &lt;bean class="org.springframework.ws.transport.http.HttpComponentsMessageSender"&gt;
                &lt;property name="credentials"&gt;
                    &lt;bean class="org.apache.http.auth.UsernamePasswordCredentials"&gt;
                        &lt;constructor-arg value="..."/&gt;
                        &lt;constructor-arg value="..."/&gt;
                    &lt;/bean&gt;
                &lt;/property&gt;
            &lt;/bean&gt;
        &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>The Exception is:</p>
  
  <p>org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Unable to create envelope from given source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source</p>
  
  <p>This is the class for the Web Service Client using the Spring WS Template:</p>
  
  <pre><code>import javax.annotation.Resource;
  import org.apache.log4j.Logger;
  import org.springframework.ws.client.WebServiceIOException;
  import org.springframework.ws.client.core.WebServiceTemplate;
  import com.myproject.soap.client.services.SOAPWebServiceClient;
  
  /**
   *
   * @param &lt;REQUEST&gt;
   * @param &lt;RESPONSE&gt;
   */
  public class DefaultSOAPWebServiceClient&lt;REQUEST, RESPONSE&gt; implements SOAPWebServiceClient&lt;REQUEST, RESPONSE&gt;
  {
      private final static Logger LOG = Logger.getLogger(DefaultSOAPWebServiceClient.class.getName());
      @Resource(name = "webServiceTemplate")
      private WebServiceTemplate webServiceTemplate;
  
      @Override
      public RESPONSE sendAndReceive(final REQUEST request, final String uri)
      {
          LOG.info("SOAP URL-" + uri);
          LOG.info("REQUEST-" + request.toString());
          RESPONSE res = null;
  
          try
          {
              res = (RESPONSE) webServiceTemplate.marshalSendAndReceive(uri, request);
          }
          catch (final WebServiceIOException e)
          {
              e.printStackTrace();
              LOG.error("Service with URI: " + uri + " is unreachable");
          }
          return res;
      }
  }
  </code></pre>
  
  <p>The method <em>sendAndReceive</em> is called like this:</p>
  
  <pre><code>public MYDATAResponse createCustomer(final MYDATA request)
      {
          return (MYDATAResponse) soapWebServiceClient.sendAndReceive((REQUEST) request, getCreateCustomerURI());
      }
  </code></pre>