Hi.

I implemented a process that do multiple web service request to fill the 
tables one by one, but I'm having some problems for example:

- The same process on my Razr(Android 4.0.4) the process completed 
normally, but in a smartphone with Android(2.2) for example, I get errors 
like 'SocketTimeout', connections problems and exceptions (FutureTask).

The process:

on my doInBackground I'm calling all the requests:

                @Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
 Cliente cliente = new Cliente();
cliente.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
cliente.importarDados();
 TabelaPreco tabelaPreco = new TabelaPreco();
tabelaPreco.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
tabelaPreco.importarDados();
 ClienteEndereco clienteEndereco = new ClienteEndereco();
clienteEndereco.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
clienteEndereco.importarDados();
 Comprador comprador = new Comprador();
comprador.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
comprador.importarDados();
 ProdutoPreco produtoPreco = new ProdutoPreco();
produtoPreco.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
produtoPreco.importarDados();
 Embalagem embalagem = new Embalagem();
embalagem.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
embalagem.importarDados();
 Produto produto = new Produto();
produto.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
produto.importarDados();
 Grupo grupo = new Grupo();
grupo.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
grupo.importarDados();
 FormaPagamento formaPagamento = new FormaPagamento();
formaPagamento.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
formaPagamento.importarDados();
 Cidade cidade = new Cidade();
cidade.setWsRepresentante(getSharedPreferences("PREFS_PRIVATE", 
MODE_PRIVATE).getInt("representante", 0));
cidade.importarDados();
 return null;
}

This importarDados() call the super method from each class that execute 
this process that fill the table with the results:

                        DataBase = new 
DadosBD(Singleton.getContextoAplicacao());
SoapObject request = new SoapObject(this.getWsNameSpace(), 
this.getWsNomeMetodo());
request.addProperty("representante", WsRepresentante);
SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = false;
envelope.setOutputSoapObject(request);
 HttpTransportSE httpTransport = new HttpTransportSE(this.getWsUrl());
httpTransport.call(this.getWsNameSpace() + "" + this.getWsNomeMetodo(), 
envelope);
SoapObject result = (SoapObject) envelope.getResponse();
 if (result != null) {
 int resultCount = result.getPropertyCount();
 if(resultCount > 0){
 SoapObject objResult = new SoapObject();
SoapObject objSoap = new SoapObject();
 objResult = (SoapObject) result.getProperty(1);
if(objResult.getPropertyCount() > 0){
 objSoap = (SoapObject) objResult.getProperty(0);
int propertyResultCount = objSoap.getPropertyCount();
                
                if (propertyResultCount > 0){

                 DataBase.BeginTransaction();
                 
                 SQLiteStatement stmtInsert = 
DataBase.getDataBase().compileStatement(DataBase.ExecInsertBuilder(Tabela, 
TabelaColunaComposta));
                 SQLiteStatement stmtSelect = 
DataBase.getDataBase().compileStatement(DataBase.ExecSelectBuilder(false, 
Tabela, TabelaSelecaoArgumentos, TabelaSelecao, TabelaGroupBy, 
TabelaHaving, TabelaOrderBy, "1"));
                 SQLiteStatement stmtUpdate = 
DataBase.getDataBase().compileStatement(DataBase.ExecUpdateBuilder(Tabela, 
TabelaColunaComposta, TabelaWhereArgumentos));
                 
                 this.Dados = new ContentValues();
                 
                 for (int currentProperty = 0; currentProperty < 
propertyResultCount; currentProperty++) {
             
                        SoapObject obj = (SoapObject) 
objSoap.getProperty(currentProperty);
                        int attributeResultCount = obj.getPropertyCount();
                        
                        for(int index = 0; index < attributeResultCount; 
index++){
                         
                         PropertyInfo pi = new PropertyInfo();
                         obj.getPropertyInfo(index, pi);
                         stmtInsert.bindString(index + 1, 
((pi.getValue().toString().equals("anyType{}")?(""):(pi.getValue().toString()))));
                         stmtUpdate.bindString(index + 1, 
((pi.getValue().toString().equals("anyType{}")?(""):(pi.getValue().toString()))));
                         this.Dados.put(pi.name.toString(), 
((pi.getValue().toString().equals("anyType{}")?(""):(pi.getValue().toString()))));
                        }
                        
                        for (int i = 0; i < this.getCamposPK().length; i++) 
{
                         stmtSelect.bindString(i + 1, 
this.Dados.get(CamposPK[i].toString()).toString());
                        }
                        
                        if(!(stmtSelect.simpleQueryForLong()==1)){
                         stmtInsert.executeInsert();
                        }else{
                         stmtUpdate.execute();
                        }
                    }
                 DataBase.SetTransaction();
                 DataBase.EndTransaction();
                }
}
}
}

*How can I implement this process using AsyncTask? I need to create one 
AsyncTask to each class?*

This requests doesn't need to be executed paralelly...

*How can I improve the security of this process?*
*
*
Thanks in advance.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to