Question

I have a problem while calling the webservice, I have a .NET web service in the server and I am using KSOAP(ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar) in Android. While running the program I got an runtime Exception named "org.ksoap2.serialization.SoapPrimitive".

I tried with the options that i readed in the link: How to call a .NET Webservice from Android using KSOAP2? and kSoap2 Android -- Cast Class Exception (SoapObject) but nothing help me

This my code:

try{
            //Conexión a Web Service
            SoapObject Solicitud = new SoapObject(NAMESPACE, METODO);

            PropertyInfo sector = new PropertyInfo();
            sector.setName("sector");
            sector.setValue(sectorX.toString());
            Solicitud.addProperty(sector);

            SoapSerializationEnvelope Envoltorio = new SoapSerializationEnvelope (SoapEnvelope.VER12);
            Envoltorio.dotNet = true;

            Envoltorio.setOutputSoapObject (Solicitud);

            HttpTransportSE TransporteHttp = new HttpTransportSE(URL);
            TransporteHttp.call (SOAP_ACTION, Envoltorio);

          //Obtencion de datos
            SoapObject resultado = (SoapObject)Envoltorio.getResponse();

            final String[] testValues = new String[resultado.getPropertyCount()];
            final Number[] serie = new Number[resultado.getPropertyCount()];

            for(int i= 0; i< resultado.getPropertyCount(); i++){
                String x = ""; 
                SoapObject wii = (SoapObject)resultado.getProperty(i);
                x += wii.getPropertyAsString(1);                
                testValues[i] = wii.getPropertyAsString(1);
                x.trim();
                serie[i]=Integer.parseInt(x);
            }

        ArrayAdapter<String> adaptador = new ArrayAdapter<String>(this, R.layout.lista_sectores, testValues);
        final ListView LstOpciones = (ListView) findViewById(R.id.LstOpciones);
        LstOpciones.setAdapter(adaptador);

        LstOpciones.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View itemClicked,
                    int position, long id) {
                // TODO Auto-generated method stub
                TextView textview = (TextView)itemClicked;
                String strText = textview.getText().toString(); 
                seleccion.setText("Seleccionado: " + strText);

            } catch (Exception e){
        txtMensaje.setText(e.getMessage());
            }

Where sectorX it's a String parameter that I give to WS.

I tried the Web service without parameters and works! The problem is when I send parameter... I guess :/

Was it helpful?

Solution

There is no exception of that name. You probably get a class cast exception. If you debug you will probably find that your response is a SoapObject. So then you use getProperty or getAttribute or whatever on it. IF you set a break point you will be able to browse the object graph and assemble your parse code manually ..

Maybe post the stacktrace somewhere..

OTHER TIPS

You can try using only 'Object' instead of using 'SoapObject'. It works for me. Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top