title: XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader) in Android application using KSOAP2 library
body: <p>This is my first question here, I have been searching for solutions, but all that I have found was similar situations or questions without answers. So I have a simple test with android that consumes a local webservice that delivers the following body: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  -&lt;wsdl:definitions xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:tns="http://xfire.codehaus.org/Calculadora" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://xfire.codehaus.org/Calculadora"&gt;
  
  
  -&lt;wsdl:types&gt;
  
  
  -&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xfire.codehaus.org/Calculadora" elementFormDefault="qualified" attributeFormDefault="qualified"&gt;
  
  
  -&lt;xsd:element name="mult"&gt;
  
  
  -&lt;xsd:complexType&gt;
  
  
  -&lt;xsd:sequence&gt;
  
  &lt;xsd:element name="in0" type="xsd:int" minOccurs="1" maxOccurs="1"/&gt;
  
  &lt;xsd:element name="in1" type="xsd:int" minOccurs="1" maxOccurs="1"/&gt;
  
  &lt;/xsd:sequence&gt;
  
  &lt;/xsd:complexType&gt;
  
  &lt;/xsd:element&gt;
  
  
  -&lt;xsd:element name="multResponse"&gt;
  
  
  -&lt;xsd:complexType&gt;
  
  
  -&lt;xsd:sequence&gt;
  
  &lt;xsd:element name="out" type="xsd:int" minOccurs="1" maxOccurs="1"/&gt;
  
  &lt;/xsd:sequence&gt;
  
  &lt;/xsd:complexType&gt;
  
  &lt;/xsd:element&gt;
  
  
  -&lt;xsd:element name="soma"&gt;
  
  
  -&lt;xsd:complexType&gt;
  
  
  -&lt;xsd:sequence&gt;
  
  &lt;xsd:element name="in0" type="xsd:int" minOccurs="1" maxOccurs="1"/&gt;
  
  &lt;xsd:element name="in1" type="xsd:int" minOccurs="1" maxOccurs="1"/&gt;
  
  &lt;/xsd:sequence&gt;
  
  &lt;/xsd:complexType&gt;
  
  &lt;/xsd:element&gt;
  
  
  -&lt;xsd:element name="somaResponse"&gt;
  
  
  -&lt;xsd:complexType&gt;
  
  
  -&lt;xsd:sequence&gt;
  
  &lt;xsd:element name="out" type="xsd:int" minOccurs="1" maxOccurs="1"/&gt;
  
  &lt;/xsd:sequence&gt;
  
  &lt;/xsd:complexType&gt;
  
  &lt;/xsd:element&gt;
  
  
  -&lt;xsd:element name="hello"&gt;
  
  &lt;xsd:complexType/&gt;
  
  &lt;/xsd:element&gt;
  
  
  -&lt;xsd:element name="helloResponse"&gt;
  
  
  -&lt;xsd:complexType&gt;
  
  
  -&lt;xsd:sequence&gt;
  
  &lt;xsd:element name="out" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/&gt;
  
  &lt;/xsd:sequence&gt;
  
  &lt;/xsd:complexType&gt;
  
  &lt;/xsd:element&gt;
  
  &lt;/xsd:schema&gt;
  
  &lt;/wsdl:types&gt;
  
  
  -&lt;wsdl:message name="helloResponse"&gt;
  
  &lt;wsdl:part name="parameters" element="tns:helloResponse"&gt; &lt;/wsdl:part&gt;
  
  &lt;/wsdl:message&gt;
  
  
  -&lt;wsdl:message name="helloRequest"&gt;
  
  &lt;wsdl:part name="parameters" element="tns:hello"&gt; &lt;/wsdl:part&gt;
  
  &lt;/wsdl:message&gt;
  
  
  -&lt;wsdl:message name="multRequest"&gt;
  
  &lt;wsdl:part name="parameters" element="tns:mult"&gt; &lt;/wsdl:part&gt;
  
  &lt;/wsdl:message&gt;
  
  
  -&lt;wsdl:message name="somaRequest"&gt;
  
  &lt;wsdl:part name="parameters" element="tns:soma"&gt; &lt;/wsdl:part&gt;
  
  &lt;/wsdl:message&gt;
  
  
  -&lt;wsdl:message name="multResponse"&gt;
  
  &lt;wsdl:part name="parameters" element="tns:multResponse"&gt; &lt;/wsdl:part&gt;
  
  &lt;/wsdl:message&gt;
  
  
  -&lt;wsdl:message name="somaResponse"&gt;
  
  &lt;wsdl:part name="parameters" element="tns:somaResponse"&gt; &lt;/wsdl:part&gt;
  
  &lt;/wsdl:message&gt;
  
  
  -&lt;wsdl:portType name="CalculadoraPortType"&gt;
  
  
  -&lt;wsdl:operation name="mult"&gt;
  
  &lt;wsdl:input name="multRequest" message="tns:multRequest"&gt; &lt;/wsdl:input&gt;
  
  &lt;wsdl:output name="multResponse" message="tns:multResponse"&gt; &lt;/wsdl:output&gt;
  
  &lt;/wsdl:operation&gt;
  
  
  -&lt;wsdl:operation name="soma"&gt;
  
  &lt;wsdl:input name="somaRequest" message="tns:somaRequest"&gt; &lt;/wsdl:input&gt;
  
  &lt;wsdl:output name="somaResponse" message="tns:somaResponse"&gt; &lt;/wsdl:output&gt;
  
  &lt;/wsdl:operation&gt;
  
  
  -&lt;wsdl:operation name="hello"&gt;
  
  &lt;wsdl:input name="helloRequest" message="tns:helloRequest"&gt; &lt;/wsdl:input&gt;
  
  &lt;wsdl:output name="helloResponse" message="tns:helloResponse"&gt; &lt;/wsdl:output&gt;
  
  &lt;/wsdl:operation&gt;
  
  &lt;/wsdl:portType&gt;
  
  
  -&lt;wsdl:binding name="CalculadoraHttpBinding" type="tns:CalculadoraPortType"&gt;
  
  &lt;wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;
  
  
  -&lt;wsdl:operation name="mult"&gt;
  
  &lt;wsdlsoap:operation soapAction=""/&gt;
  
  
  -&lt;wsdl:input name="multRequest"&gt;
  
  &lt;wsdlsoap:body use="literal"/&gt;
  
  &lt;/wsdl:input&gt;
  
  
  -&lt;wsdl:output name="multResponse"&gt;
  
  &lt;wsdlsoap:body use="literal"/&gt;
  
  &lt;/wsdl:output&gt;
  
  &lt;/wsdl:operation&gt;
  
  
  -&lt;wsdl:operation name="soma"&gt;
  
  &lt;wsdlsoap:operation soapAction=""/&gt;
  
  
  -&lt;wsdl:input name="somaRequest"&gt;
  
  &lt;wsdlsoap:body use="literal"/&gt;
  
  &lt;/wsdl:input&gt;
  
  
  -&lt;wsdl:output name="somaResponse"&gt;
  
  &lt;wsdlsoap:body use="literal"/&gt;
  
  &lt;/wsdl:output&gt;
  
  &lt;/wsdl:operation&gt;
  
  
  -&lt;wsdl:operation name="hello"&gt;
  
  &lt;wsdlsoap:operation soapAction=""/&gt;
  
  
  -&lt;wsdl:input name="helloRequest"&gt;
  
  &lt;wsdlsoap:body use="literal"/&gt;
  
  &lt;/wsdl:input&gt;
  
  
  -&lt;wsdl:output name="helloResponse"&gt;
  
  &lt;wsdlsoap:body use="literal"/&gt;
  
  &lt;/wsdl:output&gt;
  
  &lt;/wsdl:operation&gt;
  
  &lt;/wsdl:binding&gt;
  
  
  -&lt;wsdl:service name="Calculadora"&gt;
  
  
  -&lt;wsdl:port name="CalculadoraHttpPort" binding="tns:CalculadoraHttpBinding"&gt;
  
  &lt;wsdlsoap:address location="http://localhost:8080/livro_android_xfire/services/Calculadora"/&gt;
  
  &lt;/wsdl:port&gt;
  
  &lt;/wsdl:service&gt;
  
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>The client is an android app with the following code:</p>
  
  <pre><code>String url = "http://XX.X.X.X:8080/livro_android_xfire/services/Calculadora?wsdl"
  
  SoapObject soap = new SoapObject("urn:Calculadora", "soma");
  
  // Adiciona os parâmetros para a soma
  soap.addProperty("n1", n1);
  soap.addProperty("n2", n2);
  
  // Cria o envelope com o objeto SOAP
  SoapSerializationEnvelope envelope = new   SoapSerializationEnvelope(SoapEnvelope.VER11);
  envelope.setOutputSoapObject(soap);
  
  Log.i(TAG, "Calling WebService: " + url);
  
  // Cria o HttpTransport para enviar os dados (SOAP)
  HttpTransportSE httpTransport = new LivroHttpTransport(url);
  httpTransport.debug = true;
  
  // Faz a requisição
  httpTransport.call("", envelope);
  </code></pre>
  
  <p>I have followed the <code>httpTransport.call</code> and noticed that when it reaches the method <code>this.parseResponse(envelope, (InputStream)is);</code> inside the <code>HttpTransportSE</code> class, it throws the Exception
  <code>org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@286e958)</code>.</p>
  
  <p>Could anyone help me please?</p>