title: How to unmarshall SOAP XML to Java Object
body: <p>while trying to unmarshall my soap XML to JAXB object am getting the following error.</p>
  
  <p>We are getting error that expected element is none. Should anything specific be done while unmarshalling the SOAP XML.</p>
  
  <pre><code>javax.xml.bind.JAXBContext jaxbContext = (javax.xml.bind.JAXBContext) JAXBContext.newInstance(Class.forName(requestName));
  Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
  StringReader reader = new StringReader(SoapXmlString);          
  reqInfo = unmarshaller.unmarshal(reader);
  </code></pre>
  
  <p>Am getting the following error :</p>
  
  <pre><code> javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Envelope"). Expected elements are (none)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
      at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254)
      at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249)
      at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement
  </code></pre>
  
  <p>and here is the sample XML</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://example.com/v2"&gt;
         &lt;soapenv:Header/&gt;
         &lt;soapenv:Body&gt;
            &lt;v2:createSession&gt;
               &lt;v2:client&gt;
                  &lt;!--Optional:--&gt;
                  &lt;v2:name&gt;?&lt;/v2:name&gt;
                  &lt;!--Optional:--&gt;
                  &lt;v2:clientId&gt;?&lt;/v2:clientId&gt;
                  &lt;!--Optional:--&gt;
                  &lt;v2:requestId&gt;?&lt;/v2:requestId&gt;
               &lt;/v2:client&gt;
               &lt;!--Optional:--&gt;
               &lt;v2:oldSessionId&gt;?&lt;/v2:oldSessionId&gt;
               &lt;!--Optional:--&gt;
               &lt;v2:clientIp&gt;?&lt;/v2:clientIp&gt;
               &lt;!--Optional:--&gt;
               &lt;v2:clientIpStatus&gt;?&lt;/v2:clientIpStatus&gt;
               &lt;!--Optional:--&gt;
               &lt;v2:superBYOBFlow&gt;?&lt;/v2:superBYOBFlow&gt;
               &lt;!--Optional:--&gt;
               &lt;v2:FlowParams&gt;?&lt;/v2:FlowParams&gt;
               &lt;!--Optional:--&gt;
               &lt;v2:deviceInfo&gt;?&lt;/v2:deviceInfo&gt;
            &lt;/v2:createSession&gt;
         &lt;/soapenv:Body&gt;
      &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Please do help . </p>