Search code examples
androidksoap2

Ksoap complex type


I am new to Android development, and I am facing a problem to consume an xml, it is complex. Can anyone give me a hand? how to write httpTransportSE

below is the xml

1. <soapenv:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:lis="ListaDetalhe">    <soapenv:Header/>    <soapenv:Body>
          <lis:ListaDetalhe soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <Autenticacao xsi:type="urn:Autenticacao" xmlns:urn="urn:RouterBoxMobile">
                <ChaveIntegracao xsi:type="xsd:string"></ChaveIntegracao>
             </Autenticacao>
             <tlDadosTitulosDetalhe xsi:type="urn:tlDadosTitulosDetalhe" xmlns:urn="urn:RouterBoxMobile">
                <ID_Titulo xsi:type="xsd:int">1</ID_Titulo>
             </tlDadosTitulosDetalhe>
          </lis:ListaDetalhe>    </soapenv:Body> </soapenv:Envelope>

Solution

  • I managed to solve the problem after much research, follows the code:

    private void listaDetalhes(){
    
    
            SoapObject request = new SoapObject("urn:RouterBoxMobile","ListaDetalhe");
    
    
            SoapObject chaveIntegracao = new SoapObject("urn:RouterBoxMobile","ListaDetalhe");
    
            chaveIntegracao.addProperty("ChaveIntegracao","##########");
            request.addProperty("Autenticacao",chaveIntegracao);
    
    
            SoapObject tlDadosTitulosDetalhe = new SoapObject("urn:RouterBoxMobile","ListaDetalhe");
            SoapObject idTitulo = new SoapObject("urn:RouterBoxMobile","ListaDetalhe");
    
            idTitulo.addProperty("ID_Titulo",1);
            tlDadosTitulosDetalhe.addProperty("tlDadosTitulosDetalhe" ,idTitulo);
    
            request.addProperty("tlDadosTitulosDetalhe",idTitulo);
    
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
    
    
    
    
             envelope.setOutputSoapObject(request);
    
    
    
    
    
            Log.i("Testando web Service","");
            String url="####################################################";
    
            HttpTransportSE httpTransport = new HttpTransportSE(url);
            httpTransport.debug = true;
    
    
    
    
    
    
            try {
    
    
                httpTransport.call("",envelope);
    
                Log.i("Request",httpTransport.requestDump.toString());
                SoapPrimitive msg = (SoapPrimitive)envelope.getResponse();
    
                Log.d("RouterBox", "Detalhes: " + msg);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (XmlPullParserException e) {
                e.printStackTrace();
            }
        }