-1

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:

<?xml version="1.0" encoding="UTF-8"?>

-<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">


-<wsdl:types>


-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xfire.codehaus.org/Calculadora" elementFormDefault="qualified" attributeFormDefault="qualified">


-<xsd:element name="mult">


-<xsd:complexType>


-<xsd:sequence>

<xsd:element name="in0" type="xsd:int" minOccurs="1" maxOccurs="1"/>

<xsd:element name="in1" type="xsd:int" minOccurs="1" maxOccurs="1"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>


-<xsd:element name="multResponse">


-<xsd:complexType>


-<xsd:sequence>

<xsd:element name="out" type="xsd:int" minOccurs="1" maxOccurs="1"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>


-<xsd:element name="soma">


-<xsd:complexType>


-<xsd:sequence>

<xsd:element name="in0" type="xsd:int" minOccurs="1" maxOccurs="1"/>

<xsd:element name="in1" type="xsd:int" minOccurs="1" maxOccurs="1"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>


-<xsd:element name="somaResponse">


-<xsd:complexType>


-<xsd:sequence>

<xsd:element name="out" type="xsd:int" minOccurs="1" maxOccurs="1"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>


-<xsd:element name="hello">

<xsd:complexType/>

</xsd:element>


-<xsd:element name="helloResponse">


-<xsd:complexType>


-<xsd:sequence>

<xsd:element name="out" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

</wsdl:types>


-<wsdl:message name="helloResponse">

<wsdl:part name="parameters" element="tns:helloResponse"> </wsdl:part>

</wsdl:message>


-<wsdl:message name="helloRequest">

<wsdl:part name="parameters" element="tns:hello"> </wsdl:part>

</wsdl:message>


-<wsdl:message name="multRequest">

<wsdl:part name="parameters" element="tns:mult"> </wsdl:part>

</wsdl:message>


-<wsdl:message name="somaRequest">

<wsdl:part name="parameters" element="tns:soma"> </wsdl:part>

</wsdl:message>


-<wsdl:message name="multResponse">

<wsdl:part name="parameters" element="tns:multResponse"> </wsdl:part>

</wsdl:message>


-<wsdl:message name="somaResponse">

<wsdl:part name="parameters" element="tns:somaResponse"> </wsdl:part>

</wsdl:message>


-<wsdl:portType name="CalculadoraPortType">


-<wsdl:operation name="mult">

<wsdl:input name="multRequest" message="tns:multRequest"> </wsdl:input>

<wsdl:output name="multResponse" message="tns:multResponse"> </wsdl:output>

</wsdl:operation>


-<wsdl:operation name="soma">

<wsdl:input name="somaRequest" message="tns:somaRequest"> </wsdl:input>

<wsdl:output name="somaResponse" message="tns:somaResponse"> </wsdl:output>

</wsdl:operation>


-<wsdl:operation name="hello">

<wsdl:input name="helloRequest" message="tns:helloRequest"> </wsdl:input>

<wsdl:output name="helloResponse" message="tns:helloResponse"> </wsdl:output>

</wsdl:operation>

</wsdl:portType>


-<wsdl:binding name="CalculadoraHttpBinding" type="tns:CalculadoraPortType">

<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>


-<wsdl:operation name="mult">

<wsdlsoap:operation soapAction=""/>


-<wsdl:input name="multRequest">

<wsdlsoap:body use="literal"/>

</wsdl:input>


-<wsdl:output name="multResponse">

<wsdlsoap:body use="literal"/>

</wsdl:output>

</wsdl:operation>


-<wsdl:operation name="soma">

<wsdlsoap:operation soapAction=""/>


-<wsdl:input name="somaRequest">

<wsdlsoap:body use="literal"/>

</wsdl:input>


-<wsdl:output name="somaResponse">

<wsdlsoap:body use="literal"/>

</wsdl:output>

</wsdl:operation>


-<wsdl:operation name="hello">

<wsdlsoap:operation soapAction=""/>


-<wsdl:input name="helloRequest">

<wsdlsoap:body use="literal"/>

</wsdl:input>


-<wsdl:output name="helloResponse">

<wsdlsoap:body use="literal"/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>


-<wsdl:service name="Calculadora">


-<wsdl:port name="CalculadoraHttpPort" binding="tns:CalculadoraHttpBinding">

<wsdlsoap:address location="http://localhost:8080/livro_android_xfire/services/Calculadora"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

The client is an android app with the following 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);

I have followed the httpTransport.call and noticed that when it reaches the method this.parseResponse(envelope, (InputStream)is); inside the HttpTransportSE class, it throws the Exception org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@286e958).

Could anyone help me please?

Roman
  • 6,486
  • 2
  • 23
  • 41
  • Same error in http://stackoverflow.com/questions/17816871/how-to-solve-org-xmlpull-v1-xmlpullparserexception-unexpected-type-positionen and a few other questions. The solution seems to be to use a newer version of the ksoap library. (from http://simpligility.github.io/ksoap2-android/getting-started.html I guess). Can you try and confirm whether that helps? – zapl Jun 03 '16 at 21:07
  • The XML you've shown is not well-formed, it cannot be parsed by anything. – Roman Jun 04 '16 at 23:56

1 Answers1

0

Hi guys thanks for the atention but, I solved it and acctually I made a mistake the url isn't right where is "http://XX.X.X.X:8080/livro_android_xfire/services/Calculadora?wsdl" should be "http://XX.X.X.X:8080/livro_android_xfire/services/Calculadora". And now is running. Thaks