Ksoap 复杂类型
Ksoap complex type
我是 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>
经过大量研究,我设法解决了这个问题,
遵循代码:
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();
}
}
我是 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>
经过大量研究,我设法解决了这个问题, 遵循代码:
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();
}
}