Search code examples
androidksoap2android-ksoap2

Can't send request with ksoap2


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"               xmlns:cli="http://www.xxx.com/services/cliente" xmlns:tel="http://www.xxx.com">
  <soapenv:Header/>
  <soapenv:Body>
 <cli:ConsultaAbonadoRequest>
<cli:DatosAcceso>
  <tel:nombreAplicacion>AAAA</tel:nombreAplicacion>
</cli:DatosAcceso>
<cli:DatosCelular>
  <tel:numCelular>BBBB</tel:numCelular>
  <tel:numAbonado></tel:numAbonado>
  <tel:codigoCliente></tel:codigoCliente>
</cli:DatosCelular>
</cli:ConsultaAbonadoRequest>
</soapenv:Body>
</soapenv:Envelope>

I'm trying to make a SOAP call with ksoap2. I need to send this kind of request. And i spent 3 hours already reading and still can't create sub nodes please help me to make correct envelope

Thank you


Solution

  • In ksoap2 projects wiki page, Adding an array of complex objects to the request chapter:

    To get this xml:

    <users>
      <user>
         <name>Jonh</name>
         <age>12</age>
      </user>
      <user>
         <name>Marie</name>
         <age>27</age>
      </user>
    </users>
    

    You would do this:

    SoapObject users = new SoapObject(NAMESPACE, "users");
    SoapObject john = new SoapObject(NAMESPACE, "user");
    john.addProperty("name", "john");
    john.addProperty("age", 12);
    SoapObject marie = new SoapObject(NAMESPACE, "user");
    john.addProperty("name", "marie");
    john.addProperty("age", 27);
    users.addSoapObject(john);
    users.addSoapObject(marie);
    

    This may help you.