Hello All,
I am having some serious difficulty using KSoap2 to connect to a
VB.Net webservice and am hoping I could get some help from someone who
is smarter than me. I have been trying to work this out for 2 weeks
with no luck.


So this is my problem. Using KSoap2 on the Android platform I have
successfully queried a super simple web service that I created using
vb.net (It can be found at 
http://gershwinsolutions.ftpaccess.cc/2dowebservice.asmx)
I receive a XML result which looks quite reasonable to me.

ReturnCustomerObject2Response{
ReturnCustomerObject2Result=anyType{CustomerID=1; FirstName=This is a
test; };
}


However at the point where I try to cast the object I am returning
from the webservice into a KvmSerializable object (as required by
KSoap2) I receive a java.lang.ClassCastException.


This is my object (I have excluded imports for brevity):

public class Customer extends BaseObject {

        private int m_CustomerID;
        private String m_FirstName;
        public static Class<? extends Customer> Customer_CLASS = new Customer
().getClass();



        public void setCustomerID(int CustomerID) {
                m_CustomerID = CustomerID;
        }
        public int getCustomerID() {
                return m_CustomerID;
        }
        public void setFirstName(String FirstName) {
                m_FirstName = FirstName;
        }
        public String getFirstName() {
                return m_FirstName;
        }


    public void getPropertyInfo(int index, Hashtable properties,
PropertyInfo info) {
        switch (index)
        {
        case 0:
            info.type = PropertyInfo.INTEGER_CLASS;
            info.name = "CustomerID";
            break;
        case 1:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "FirstName";
            break;
        default:
            break;

        }
    }


        @Override
        public Object getProperty(int index)
    {
                switch (index) {
        case 0:
            return m_CustomerID;
        case 1:
            return m_FirstName;
        default:
            return null;
        }
    }

        @Override
    public int getPropertyCount() {
        return 2;
    }


        @Override
        public void setProperty(int index, Object value) {

                switch (index) {
        case 0:
            m_CustomerID = Integer.parseInt(value.toString());
            break;
        case 1:
                 m_FirstName = value.toString();
             break;
        default:
            break;
        }

        }
}


private static final String SOAP_ACTION = "http://tempuri.org/
ReturnCustomerObject2";
private static final String METHOD_NAME = "ReturnCustomerObject2";
private static final String NAMESPACE = "http://tempuri.org/";;
private static final String URL = "http://
10.0.2.2/2DoWebService.asmx";

public Boolean ExecuteSoapAction() {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope
(SoapEnvelope.VER11);
        envelope.encodingStyle = SoapSerializationEnvelope.XSD;
        envelope.setOutputSoapObject(request);
        envelope.addMapping("http://tempuri.org/ReturnCustomerObject2";,
"ReturnCustomerObject2", new Customer().getClass());

        envelope.dotNet = true;

        Customer Cust = new Customer();

        HttpTransportSE HttpTransport = new HttpTransportSE(URL);
        HttpTransport.debug = true;
        try {
                HttpTransport.call(SOAP_ACTION, envelope);
//HERE IS WHERE IT ALL GOES HORRIBLY WRONG!!
                Cust = (Customer) envelope.getResponse();
        }
        catch (Exception ex) {
                ex.printStackTrace();
        }
        return false;
    }

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

Reply via email to