Hello,

Firts i am new to java and android development, i am trying to call asmx 
web service that returns a class with three members as this example 
http://seesharpgears.blogspot.com/2010/10/ksoap-android-web-service-tutorial-with.html

but i am getting an while executing the code below

the error comes from this line             C.CategoryId = 
 Integer.parseInt(response.getProperty(0).toString());


and the error is java.lang.NumberFormatException: unable to parse 
'anyType{CategoryId=10055; Name=my name;Description=my Desc;}' as integer


  public void WebServiceCallExample()
    {
    
        String NAMESPACE = "http://tempuri.org/";;
        String METHOD_NAME = "GetCategoryById";
        String SOAP_ACTION = "http://tempuri.org/GetCategoryById";;
        String URL = 
"http://ZarqaLaptop.cigalah.com.sa/AndroidService/Service.asmx";;
        
        SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
        
        /*
        * Create Category with Id to be passed as an argument
        * 
        */
        Category C = new Category();
        C.CategoryId = 10000;
        
        /*
         * Set the category to be the argument of the web service method
         * 
         * */
        PropertyInfo pi = new PropertyInfo();
        pi.setName("C");
        pi.setValue(C);
        pi.setType(C.getClass());
        Request.addProperty(pi);
        
        /*
         * Set the web service envelope
         * 
         * */
        SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(Request);
        
        envelope.addMapping(NAMESPACE, "Category",new 
Category().getClass());
        HttpTransportSE  androidHttpTransport = new HttpTransportSE(URL);
        /*
         * Call the web service and retrieve result ... how luvly <3
         * 
         * */
        TextView tv = (TextView)findViewById(R.id.textView1);
        try
        {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapObject response = (SoapObject)envelope.bodyIn;
            C.CategoryId = 
 Integer.parseInt(response.getProperty(0).toString());
            C.Name =  response.getProperty(1).toString();
            C.Description = (String) response.getProperty(2).toString();

            tv.setText("CategoryId: " +C.CategoryId + " Name: " + C.Name + 
" Description " + C.Description);
        }
        catch(Exception e)
        {
        tv.setText(e.toString());
            e.printStackTrace();
        } 
    }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to