views:

247

answers:

1

Hi everyone,I'm programming an application who must send coordinate and request to a WebServices this is my code:

      private String SOAP_ACTION = "getAllPositions";
      private String METHOD_NAME = "getAllPositions";
      private String NAMESPACE = "http://session/";
      private static final String URL ="http://192.41.218.56:8080/WSGeoEAR-WSGeoServer/NavFinderBean?WSDL"; 


      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.main); 




         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

          request.addProperty("idUtente",1);     



          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
          envelope.dotNet = true; 
          envelope.setOutputSoapObject(request);


          AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
          androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
          androidHttpTransport.debug = true;

          try{
          androidHttpTransport.call(SOAP_ACTION, envelope);
          SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;

          ArrayList<position> resultData = (ArrayList<position>)resultsRequestSOAP.getProperty("getAllPositionsResponse");

          for(position p : resultData)
          {

              ((TextView)findViewById(R.id.lblStatus)).setText(p.getAllInformation());  
          }        
            } catch(Exception E) {
                  ((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
                }
              }

          }

I've also create a class position.

It doesn't work,can someone help me?Thanks

A: 

I am facing similar problems too... Well as for that above, you should rename the property to "getAllPositions". Then it will return the property, but unfortunately, it will start throwing illegal cast exception, meaning you cannot cast the response to Array.

Guys please, if anyone knows how to cast the response to an array of objects, please let me know

DFDF