I have a problem accessing a web service made in PHP. I tried many codes but do not know if I have a stupid bug that makes me not work.
The Webservice I think is good because if I make the call from a page in PHP works, but if I access via Android does not work, so is the call I make in ANDROID.
The error occurs in: transporte.call(SOAP_ACTION, envelope,null);
The error is: org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2003/05/soap-envelope}Envelope (position:START_TAG <definitions name='SMB_GestionBoda' targetNamespace='http://localhost/webservice/SMB_GestionBoda.wdsl'>@8:43 in java.io.InputStreamReader@405d9f50)
Thanks.
The WSDL:
<definitions
name='SMB_GestionBoda'
targetNamespace='http://localhost/webservice/SMB_GestionBoda.wdsl'
xmlns:tns='http://localhost/webservice/SMB_GestionBoda.wdsl'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='GetProvidersRequest'>
<part name='id_task' type='xsd:int'/>
<part name='city' type='xsd:string'/>
</message>
<message name='GetProvidersResponse'>
<part name='result'/>
</message>
<portType name='SMB_GestionBodaPortType'>
<operation name='GetProviders'>
<input message='tns:GetProvidersRequest'/>
<output message='tns:GetProvidersResponse'/>
</operation>
</portType>
<binding name='SMB_GestionBodaBinding' type='tns:SMB_GestionBodaPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='GetProviders'>
<soap:operation soapAction='urn:localhost-SMB_GestionBoda#GetProviders'/>
<input>
<soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='SMB_GestionBodaService'>
<port name='SMB_GestionBodaPort' binding='SMB_GestionBodaBinding'>
<soap:address location='http://localhost/webservice/GetProviders.php'/>
</port>
</service>
</definitions>
The ANDROID CODE:
//Constantes para la invocacion del web service
final String NAMESPACE = "http://localhost/webservice/SMB_GestionBoda.wdsl";
final String URL="http://192.168.0.10/webservice/SMB_GestionBoda.wdsl";
final String METHOD_NAME = "GetProviders";
final String SOAP_ACTION = "urn:localhost-SMB_GestionBoda#GetProviders";
/*Se crea un objeto SoapObject para poder realizar la peticion
para consumir el ws SOAP. El constructor recibe
el namespace. Por lo regular el namespace es el dominio
donde se encuentra el web service*/
request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("id_task",0);
request.addProperty("city","valencia");
/*Se crea un objeto SoapSerializationEnvelope para serealizar la
peticion SOAP y permitir viajar el mensaje por la nube
el constructor recibe la version de SOAP*/
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = false; //se asigna true para el caso de que el WS sea de dotNet
//Se envuelve la peticion soap
envelope.setOutputSoapObject(request);
//Objeto que representa el modelo de transporte
//Recibe la URL del ws
HttpTransportSE transporte = new HttpTransportSE(URL);
transporte.debug=true;
try {
System.setProperty("http.keepAlive", "false");
//Hace la llamada al ws
transporte.call(SOAP_ACTION, envelope,null);
//Se crea un objeto SoapPrimitive y se obtiene la respuesta
//de la peticion
resultsRequestSOAP = (SoapPrimitive)envelope.getResponse();
//result = (SoapObject)envelope.bodyIn;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
Log.d("MI APP","dump : " + transporte.responseDump);
e.printStackTrace();
}
The Request DUMP:
<v:Envelope
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://www.w3.org/2003/05/soap-encoding"
xmlns:v="http://www.w3.org/2003/05/soap-envelope">
<v:Header />
<v:Body>
<n0:GetProviders id="o0" c:root="1" xmlns:n0="http://localhost/webservice/SMB_GestionBoda.wdsl">
<id_task i:type="d:int">0</id_task>
<city i:type="d:string">valencia</city>
</n0:GetProviders>
</v:Body>
</v:Envelope>
The Response DUMP:
<?xml version="1.0" encoding="utf-8"?>
<definitions
name='SMB_GestionBoda'
targetNamespace='http://localhost/webservice/SMB_GestionBoda.wdsl'
xmlns:tns='http://localhost/webservice/SMB_GestionBoda.wdsl'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='GetProvidersRequest'>
<part name='id_task' type='xsd:int'/>
<part name='city' type='xsd:string'/>
</message>
<message name='GetProvidersResponse'>
<part name='result'/>
</message>
<portType name='SMB_GestionBodaPortType'>
<operation name='GetProviders'>
<input message='tns:GetProvidersRequest'/>
<output message='tns:GetProvidersResponse'/>
</operation>
</portType>
<binding name='SMB_GestionBodaBinding' type='tns:SMB_GestionBodaPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='GetProviders'>
<soap:operation soapAction='urn:localhost-SMB_GestionBoda#GetProviders'/>
<input>
<soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='SMB_GestionBodaService'>
<port name='SMB_GestionBodaPort' binding='SMB_GestionBodaBinding'>
<soap:address location='http://localhost/webservice/GetProviders.php'/>
</port>
</service>
</definitions>