Ksoap复合型

时间:2016-10-14 20:42:57

标签: android ksoap2

我是Android开发的新手,我面临着使用xml的问题,这很复杂。任何人都可以帮我一把吗?如何编写httpTransportSE

下面的

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

1 个答案:

答案 0 :(得分:0)

经过多次研究,我设法解决了这个问题, 遵循以下代码:

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();
        }
    }