Send json, gson via KSoap on Android

1

It happens that I am trying to send what has a Json file to a WebService made in C #, I have to send it the string that contains the Json file from android, what I have to send in this case is the "saved" variable that the I think so from a Shared Preference

carrito=getSharedPreferences("carrito",MODE_PRIVATE);
        final String guardado = carrito.getString("cesta","");
        ////gson convierte el elemento guardado a un arraylist
 final Type type = new TypeToken<ArrayList<Elemento>>(){}.getType();
cesta=gson.fromJson(guardado,type);

the data contained in that variable are:

[
  {
    "cantidad": 3,
    "monto": 27.96,
    "nombre": "Churrasco",
    "precio": 6.99
  }
]

This is my code:

 @Override
            public void onClick(View view) {
                Thread tr= new Thread(){
                    @Override
                    public void run() {
                        try {
                            String NAMESPACE = "http://tempuri.org/";
                            String URL = "http://192.168.43.57/Publicaciones/WebServiceCarrito.asmx";
                            String METHOD_NAME = "insertarJson";
                            String SOAP_ACTION="http://tempuri.org/insertarJson";
                            SoapPrimitive resultsRequestSOAP=null;
                            SoapObject request=new SoapObject(NAMESPACE,METHOD_NAME);

                            request.addProperty("json", guardado);


                            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
                            envelope.dotNet=true;
                            envelope.setOutputSoapObject(request);
                            HttpTransportSE transporte = new HttpTransportSE(URL);

                            try {
                                transporte.call(SOAP_ACTION,envelope);
                                final SoapObject soap = (SoapObject)envelope.getResponse();
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        Toast.makeText(getApplicationContext(),"¡Escoge lo que quieras!",Toast.LENGTH_SHORT).show();

                                    }
                                });
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                        }catch (Exception e){
                            e.printStackTrace();
                        }


                    }
                };
                tr.start();

When executing the function nothing happens, android does not send the data, I tried the connection and it works correctly. I would like to know if there is a shipping method and if so, what it is.

    
asked by Yonatan Ulises Segura 17.05.2018 в 07:49
source

0 answers