Advertisement
felipearon

enviarColeta()

Jun 24th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. private boolean enviarColeta(Coleta coleta) {
  2.        
  3.         String methodName = "ImpGar";
  4.        
  5.         SoapObject request = new SoapObject(WSBase.NAMESPACE, methodName);
  6.         request.addProperty("user", "pedsite");
  7.         request.addProperty("password", "pedsite");
  8.         request.addProperty("encryption", 0);
  9.        
  10.         CadastrosImpGarIn coletaEnv = new CadastrosImpGarIn();
  11.         coletaEnv.setCodCli((int) coleta.getIdCliente());
  12.         coletaEnv.setCodEmp((int) coleta.getIdCliente());
  13.         coletaEnv.setCodFil(1); //Filial da Kania - padrão 1
  14.         coletaEnv.setCodMot((int) coleta.getIdMotorista());
  15.         coletaEnv.setDatCol(DateUtils.dateToString(coleta.getDataHora()));
  16.         coletaEnv.setNumDoc(coleta.getProtocolo());
  17.        
  18.         List<CadastrosImpGarInTabBat> baterias = new ArrayList<CadastrosImpGarInTabBat>();
  19.        
  20.         for (ColetaItem item : coleta.getBaterias()) {
  21.            
  22.             baterias.add(new CadastrosImpGarInTabBat(
  23.                     item.getCodigoBarras(),
  24.                     item.getBateria().getReferencia(),
  25.                     DateUtils.dateToString(item.getDataFabricacao()),
  26.                     DateUtils.dateToString(item.getDataVencimento()),
  27.                     String.valueOf(item.getIdDefeito()),
  28.                     item.getDefeito().getDescricao()
  29.                 ));        
  30.         }
  31.        
  32.         Vector<CadastrosImpGarInTabBat> vItens = new Vector<CadastrosImpGarInTabBat>();
  33.         vItens.setSize(baterias.size());
  34.         Collections.copy(vItens, baterias);    
  35.         coletaEnv.setTabBat(vItens);
  36.        
  37.         PropertyInfo pi = new PropertyInfo();
  38.         pi.setName("parameters");
  39.         pi.setValue(coletaEnv);
  40.         pi.setType(coletaEnv.getClass());
  41.         request.addProperty("parameters", coletaEnv);
  42.        
  43.         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
  44.         envelope.setOutputSoapObject(request);     
  45.         envelope.addMapping(WSBase.NAMESPACE, "CadastrosImpGarIn", new CadastrosImpGarIn().getClass());
  46.        
  47.         HttpTransportSE transportSE = new HttpTransportSE(WSBase.URL);
  48.         try {
  49.            
  50.             transportSE.debug = true;
  51.             transportSE.call(WSBase.SOAP_ACTION + methodName, envelope);
  52.            
  53.             SoapObject response = (SoapObject) envelope.bodyIn;
  54.             //String xmlResponse = transportSE.responseDump; //XML Response
  55.             new Alerta(context, response.getAttribute("desRet").toString());
  56.             return false;
  57.            
  58.         } catch (Exception e) {
  59.             return false;
  60.         }
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement