title: javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.1 Message
body: <p>I am consuming a SOAP API. The XML response I receive is surrounded with a 'soap envelope' - so I need to remove or parse past that wrapper before I can process the XML. I've taken the below approach with other endpoints (so the code is sane, at least) but with this particular endpoint, I get errors. </p>
  
  <p>The error I'm encountering is: </p>
  
  <blockquote>
    <p>SEVERE: SAAJ0304: InputStream does not represent a valid SOAP 1.1
    Message</p>
  </blockquote>
  
  <p>This is the code I am using to remove the Soap Wrapper: </p>
  
  <pre><code>String soapResponse = getSoapResponseFromApi();
  ByteArrayInputStream inputStream = new ByteArrayInputStream(soapResponse.getBytes());
  SOAPMessage message = MessageFactory.newInstance().createMessage(null, inputStream);
  Document doc = message.getSOAPBody().extractContentAsDocument();   // &lt;-- error thrown here
  
  
  //unmarhsall the XML in 'doc' into an object
  //do useful stuff with that object
  </code></pre>
  
  <p>here is the XML I am receiving back (the contents of soapResponse in the code above) </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;soap:Body&gt;
          &lt;XMLContentIActuallyWant xmlns="http://my-url.com/webservices/"&gt;
              &lt;!-- Useful stuff here --&gt;
          &lt;/XMLContentIActuallyWant &gt;
      &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>