Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private boolean enviarColeta(Coleta coleta) {
- String methodName = "ImpGar";
- SoapObject request = new SoapObject(WSBase.NAMESPACE, methodName);
- request.addProperty("user", "pedsite");
- request.addProperty("password", "pedsite");
- request.addProperty("encryption", 0);
- CadastrosImpGarIn coletaEnv = new CadastrosImpGarIn();
- coletaEnv.setCodCli((int) coleta.getIdCliente());
- coletaEnv.setCodEmp((int) coleta.getIdCliente());
- coletaEnv.setCodFil(1); //Filial da Kania - padrão 1
- coletaEnv.setCodMot((int) coleta.getIdMotorista());
- coletaEnv.setDatCol(DateUtils.dateToString(coleta.getDataHora()));
- coletaEnv.setNumDoc(coleta.getProtocolo());
- List<CadastrosImpGarInTabBat> baterias = new ArrayList<CadastrosImpGarInTabBat>();
- for (ColetaItem item : coleta.getBaterias()) {
- baterias.add(new CadastrosImpGarInTabBat(
- item.getCodigoBarras(),
- item.getBateria().getReferencia(),
- DateUtils.dateToString(item.getDataFabricacao()),
- DateUtils.dateToString(item.getDataVencimento()),
- String.valueOf(item.getIdDefeito()),
- item.getDefeito().getDescricao()
- ));
- }
- Vector<CadastrosImpGarInTabBat> vItens = new Vector<CadastrosImpGarInTabBat>();
- vItens.setSize(baterias.size());
- Collections.copy(vItens, baterias);
- coletaEnv.setTabBat(vItens);
- PropertyInfo pi = new PropertyInfo();
- pi.setName("parameters");
- pi.setValue(coletaEnv);
- pi.setType(coletaEnv.getClass());
- request.addProperty("parameters", coletaEnv);
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- envelope.setOutputSoapObject(request);
- envelope.addMapping(WSBase.NAMESPACE, "CadastrosImpGarIn", new CadastrosImpGarIn().getClass());
- HttpTransportSE transportSE = new HttpTransportSE(WSBase.URL);
- try {
- transportSE.debug = true;
- transportSE.call(WSBase.SOAP_ACTION + methodName, envelope);
- SoapObject response = (SoapObject) envelope.bodyIn;
- //String xmlResponse = transportSE.responseDump; //XML Response
- new Alerta(context, response.getAttribute("desRet").toString());
- return false;
- } catch (Exception e) {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement