php - Error in ANDROID with WSDL and ksoap2 -
i have problem accessing web service made in php. tried many codes not know if have stupid bug makes me not work.
the webservice think because if make call page in php works, if access via android not work, call 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>
change url extension .asmx not .wsdl
Comments
Post a Comment